babylon.module.d.ts 5.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. let Epsilon: number;
  272. export { Epsilon };
  273. /**
  274. * Class used to hold a RBG color
  275. */
  276. export class Color3 {
  277. /**
  278. * Defines the red component (between 0 and 1, default is 0)
  279. */
  280. r: number;
  281. /**
  282. * Defines the green component (between 0 and 1, default is 0)
  283. */
  284. g: number;
  285. /**
  286. * Defines the blue component (between 0 and 1, default is 0)
  287. */
  288. b: number;
  289. /**
  290. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  291. * @param r defines the red component (between 0 and 1, default is 0)
  292. * @param g defines the green component (between 0 and 1, default is 0)
  293. * @param b defines the blue component (between 0 and 1, default is 0)
  294. */
  295. constructor(
  296. /**
  297. * Defines the red component (between 0 and 1, default is 0)
  298. */
  299. r?: number,
  300. /**
  301. * Defines the green component (between 0 and 1, default is 0)
  302. */
  303. g?: number,
  304. /**
  305. * Defines the blue component (between 0 and 1, default is 0)
  306. */
  307. b?: number);
  308. /**
  309. * Creates a string with the Color3 current values
  310. * @returns the string representation of the Color3 object
  311. */
  312. toString(): string;
  313. /**
  314. * Returns the string "Color3"
  315. * @returns "Color3"
  316. */
  317. getClassName(): string;
  318. /**
  319. * Compute the Color3 hash code
  320. * @returns an unique number that can be used to hash Color3 objects
  321. */
  322. getHashCode(): number;
  323. /**
  324. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  325. * @param array defines the array where to store the r,g,b components
  326. * @param index defines an optional index in the target array to define where to start storing values
  327. * @returns the current Color3 object
  328. */
  329. toArray(array: FloatArray, index?: number): Color3;
  330. /**
  331. * Returns a new Color4 object from the current Color3 and the given alpha
  332. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  333. * @returns a new Color4 object
  334. */
  335. toColor4(alpha?: number): Color4;
  336. /**
  337. * Returns a new array populated with 3 numeric elements : red, green and blue values
  338. * @returns the new array
  339. */
  340. asArray(): number[];
  341. /**
  342. * Returns the luminance value
  343. * @returns a float value
  344. */
  345. toLuminance(): number;
  346. /**
  347. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  348. * @param otherColor defines the second operand
  349. * @returns the new Color3 object
  350. */
  351. multiply(otherColor: DeepImmutable<Color3>): Color3;
  352. /**
  353. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  354. * @param otherColor defines the second operand
  355. * @param result defines the Color3 object where to store the result
  356. * @returns the current Color3
  357. */
  358. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  359. /**
  360. * Determines equality between Color3 objects
  361. * @param otherColor defines the second operand
  362. * @returns true if the rgb values are equal to the given ones
  363. */
  364. equals(otherColor: DeepImmutable<Color3>): boolean;
  365. /**
  366. * Determines equality between the current Color3 object and a set of r,b,g values
  367. * @param r defines the red component to check
  368. * @param g defines the green component to check
  369. * @param b defines the blue component to check
  370. * @returns true if the rgb values are equal to the given ones
  371. */
  372. equalsFloats(r: number, g: number, b: number): boolean;
  373. /**
  374. * Multiplies in place each rgb value by scale
  375. * @param scale defines the scaling factor
  376. * @returns the updated Color3
  377. */
  378. scale(scale: number): Color3;
  379. /**
  380. * Multiplies the rgb values by scale and stores the result into "result"
  381. * @param scale defines the scaling factor
  382. * @param result defines the Color3 object where to store the result
  383. * @returns the unmodified current Color3
  384. */
  385. scaleToRef(scale: number, result: Color3): Color3;
  386. /**
  387. * Scale the current Color3 values by a factor and add the result to a given Color3
  388. * @param scale defines the scale factor
  389. * @param result defines color to store the result into
  390. * @returns the unmodified current Color3
  391. */
  392. scaleAndAddToRef(scale: number, result: Color3): Color3;
  393. /**
  394. * Clamps the rgb values by the min and max values and stores the result into "result"
  395. * @param min defines minimum clamping value (default is 0)
  396. * @param max defines maximum clamping value (default is 1)
  397. * @param result defines color to store the result into
  398. * @returns the original Color3
  399. */
  400. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  401. /**
  402. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  403. * @param otherColor defines the second operand
  404. * @returns the new Color3
  405. */
  406. add(otherColor: DeepImmutable<Color3>): Color3;
  407. /**
  408. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  409. * @param otherColor defines the second operand
  410. * @param result defines Color3 object to store the result into
  411. * @returns the unmodified current Color3
  412. */
  413. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  414. /**
  415. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  416. * @param otherColor defines the second operand
  417. * @returns the new Color3
  418. */
  419. subtract(otherColor: DeepImmutable<Color3>): Color3;
  420. /**
  421. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  422. * @param otherColor defines the second operand
  423. * @param result defines Color3 object to store the result into
  424. * @returns the unmodified current Color3
  425. */
  426. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  427. /**
  428. * Copy the current object
  429. * @returns a new Color3 copied the current one
  430. */
  431. clone(): Color3;
  432. /**
  433. * Copies the rgb values from the source in the current Color3
  434. * @param source defines the source Color3 object
  435. * @returns the updated Color3 object
  436. */
  437. copyFrom(source: DeepImmutable<Color3>): Color3;
  438. /**
  439. * Updates the Color3 rgb values from the given floats
  440. * @param r defines the red component to read from
  441. * @param g defines the green component to read from
  442. * @param b defines the blue component to read from
  443. * @returns the current Color3 object
  444. */
  445. copyFromFloats(r: number, g: number, b: number): Color3;
  446. /**
  447. * Updates the Color3 rgb values from the given floats
  448. * @param r defines the red component to read from
  449. * @param g defines the green component to read from
  450. * @param b defines the blue component to read from
  451. * @returns the current Color3 object
  452. */
  453. set(r: number, g: number, b: number): Color3;
  454. /**
  455. * Compute the Color3 hexadecimal code as a string
  456. * @returns a string containing the hexadecimal representation of the Color3 object
  457. */
  458. toHexString(): string;
  459. /**
  460. * Computes a new Color3 converted from the current one to linear space
  461. * @returns a new Color3 object
  462. */
  463. toLinearSpace(): Color3;
  464. /**
  465. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  466. * @param convertedColor defines the Color3 object where to store the linear space version
  467. * @returns the unmodified Color3
  468. */
  469. toLinearSpaceToRef(convertedColor: Color3): Color3;
  470. /**
  471. * Computes a new Color3 converted from the current one to gamma space
  472. * @returns a new Color3 object
  473. */
  474. toGammaSpace(): Color3;
  475. /**
  476. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  477. * @param convertedColor defines the Color3 object where to store the gamma space version
  478. * @returns the unmodified Color3
  479. */
  480. toGammaSpaceToRef(convertedColor: Color3): Color3;
  481. private static _BlackReadOnly;
  482. /**
  483. * Creates a new Color3 from the string containing valid hexadecimal values
  484. * @param hex defines a string containing valid hexadecimal values
  485. * @returns a new Color3 object
  486. */
  487. static FromHexString(hex: string): Color3;
  488. /**
  489. * Creates a new Vector3 from the starting index of the given array
  490. * @param array defines the source array
  491. * @param offset defines an offset in the source array
  492. * @returns a new Color3 object
  493. */
  494. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  495. /**
  496. * Creates a new Color3 from integer values (< 256)
  497. * @param r defines the red component to read from (value between 0 and 255)
  498. * @param g defines the green component to read from (value between 0 and 255)
  499. * @param b defines the blue component to read from (value between 0 and 255)
  500. * @returns a new Color3 object
  501. */
  502. static FromInts(r: number, g: number, b: number): Color3;
  503. /**
  504. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  505. * @param start defines the start Color3 value
  506. * @param end defines the end Color3 value
  507. * @param amount defines the gradient value between start and end
  508. * @returns a new Color3 object
  509. */
  510. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  511. /**
  512. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  513. * @param left defines the start value
  514. * @param right defines the end value
  515. * @param amount defines the gradient factor
  516. * @param result defines the Color3 object where to store the result
  517. */
  518. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  519. /**
  520. * Returns a Color3 value containing a red color
  521. * @returns a new Color3 object
  522. */
  523. static Red(): Color3;
  524. /**
  525. * Returns a Color3 value containing a green color
  526. * @returns a new Color3 object
  527. */
  528. static Green(): Color3;
  529. /**
  530. * Returns a Color3 value containing a blue color
  531. * @returns a new Color3 object
  532. */
  533. static Blue(): Color3;
  534. /**
  535. * Returns a Color3 value containing a black color
  536. * @returns a new Color3 object
  537. */
  538. static Black(): Color3;
  539. /**
  540. * Gets a Color3 value containing a black color that must not be updated
  541. */
  542. static readonly BlackReadOnly: DeepImmutable<Color3>;
  543. /**
  544. * Returns a Color3 value containing a white color
  545. * @returns a new Color3 object
  546. */
  547. static White(): Color3;
  548. /**
  549. * Returns a Color3 value containing a purple color
  550. * @returns a new Color3 object
  551. */
  552. static Purple(): Color3;
  553. /**
  554. * Returns a Color3 value containing a magenta color
  555. * @returns a new Color3 object
  556. */
  557. static Magenta(): Color3;
  558. /**
  559. * Returns a Color3 value containing a yellow color
  560. * @returns a new Color3 object
  561. */
  562. static Yellow(): Color3;
  563. /**
  564. * Returns a Color3 value containing a gray color
  565. * @returns a new Color3 object
  566. */
  567. static Gray(): Color3;
  568. /**
  569. * Returns a Color3 value containing a teal color
  570. * @returns a new Color3 object
  571. */
  572. static Teal(): Color3;
  573. /**
  574. * Returns a Color3 value containing a random color
  575. * @returns a new Color3 object
  576. */
  577. static Random(): Color3;
  578. }
  579. /**
  580. * Class used to hold a RBGA color
  581. */
  582. export class Color4 {
  583. /**
  584. * Defines the red component (between 0 and 1, default is 0)
  585. */
  586. r: number;
  587. /**
  588. * Defines the green component (between 0 and 1, default is 0)
  589. */
  590. g: number;
  591. /**
  592. * Defines the blue component (between 0 and 1, default is 0)
  593. */
  594. b: number;
  595. /**
  596. * Defines the alpha component (between 0 and 1, default is 1)
  597. */
  598. a: number;
  599. /**
  600. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  601. * @param r defines the red component (between 0 and 1, default is 0)
  602. * @param g defines the green component (between 0 and 1, default is 0)
  603. * @param b defines the blue component (between 0 and 1, default is 0)
  604. * @param a defines the alpha component (between 0 and 1, default is 1)
  605. */
  606. constructor(
  607. /**
  608. * Defines the red component (between 0 and 1, default is 0)
  609. */
  610. r?: number,
  611. /**
  612. * Defines the green component (between 0 and 1, default is 0)
  613. */
  614. g?: number,
  615. /**
  616. * Defines the blue component (between 0 and 1, default is 0)
  617. */
  618. b?: number,
  619. /**
  620. * Defines the alpha component (between 0 and 1, default is 1)
  621. */
  622. a?: number);
  623. /**
  624. * Adds in place the given Color4 values to the current Color4 object
  625. * @param right defines the second operand
  626. * @returns the current updated Color4 object
  627. */
  628. addInPlace(right: DeepImmutable<Color4>): Color4;
  629. /**
  630. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  631. * @returns the new array
  632. */
  633. asArray(): number[];
  634. /**
  635. * Stores from the starting index in the given array the Color4 successive values
  636. * @param array defines the array where to store the r,g,b components
  637. * @param index defines an optional index in the target array to define where to start storing values
  638. * @returns the current Color4 object
  639. */
  640. toArray(array: number[], index?: number): Color4;
  641. /**
  642. * Determines equality between Color4 objects
  643. * @param otherColor defines the second operand
  644. * @returns true if the rgba values are equal to the given ones
  645. */
  646. equals(otherColor: DeepImmutable<Color4>): boolean;
  647. /**
  648. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  649. * @param right defines the second operand
  650. * @returns a new Color4 object
  651. */
  652. add(right: DeepImmutable<Color4>): Color4;
  653. /**
  654. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  655. * @param right defines the second operand
  656. * @returns a new Color4 object
  657. */
  658. subtract(right: DeepImmutable<Color4>): Color4;
  659. /**
  660. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  661. * @param right defines the second operand
  662. * @param result defines the Color4 object where to store the result
  663. * @returns the current Color4 object
  664. */
  665. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  666. /**
  667. * Creates a new Color4 with the current Color4 values multiplied by scale
  668. * @param scale defines the scaling factor to apply
  669. * @returns a new Color4 object
  670. */
  671. scale(scale: number): Color4;
  672. /**
  673. * Multiplies the current Color4 values by scale and stores the result in "result"
  674. * @param scale defines the scaling factor to apply
  675. * @param result defines the Color4 object where to store the result
  676. * @returns the current unmodified Color4
  677. */
  678. scaleToRef(scale: number, result: Color4): Color4;
  679. /**
  680. * Scale the current Color4 values by a factor and add the result to a given Color4
  681. * @param scale defines the scale factor
  682. * @param result defines the Color4 object where to store the result
  683. * @returns the unmodified current Color4
  684. */
  685. scaleAndAddToRef(scale: number, result: Color4): Color4;
  686. /**
  687. * Clamps the rgb values by the min and max values and stores the result into "result"
  688. * @param min defines minimum clamping value (default is 0)
  689. * @param max defines maximum clamping value (default is 1)
  690. * @param result defines color to store the result into.
  691. * @returns the cuurent Color4
  692. */
  693. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  694. /**
  695. * Multipy an Color4 value by another and return a new Color4 object
  696. * @param color defines the Color4 value to multiply by
  697. * @returns a new Color4 object
  698. */
  699. multiply(color: Color4): Color4;
  700. /**
  701. * Multipy a Color4 value by another and push the result in a reference value
  702. * @param color defines the Color4 value to multiply by
  703. * @param result defines the Color4 to fill the result in
  704. * @returns the result Color4
  705. */
  706. multiplyToRef(color: Color4, result: Color4): Color4;
  707. /**
  708. * Creates a string with the Color4 current values
  709. * @returns the string representation of the Color4 object
  710. */
  711. toString(): string;
  712. /**
  713. * Returns the string "Color4"
  714. * @returns "Color4"
  715. */
  716. getClassName(): string;
  717. /**
  718. * Compute the Color4 hash code
  719. * @returns an unique number that can be used to hash Color4 objects
  720. */
  721. getHashCode(): number;
  722. /**
  723. * Creates a new Color4 copied from the current one
  724. * @returns a new Color4 object
  725. */
  726. clone(): Color4;
  727. /**
  728. * Copies the given Color4 values into the current one
  729. * @param source defines the source Color4 object
  730. * @returns the current updated Color4 object
  731. */
  732. copyFrom(source: Color4): Color4;
  733. /**
  734. * Copies the given float values into the current one
  735. * @param r defines the red component to read from
  736. * @param g defines the green component to read from
  737. * @param b defines the blue component to read from
  738. * @param a defines the alpha component to read from
  739. * @returns the current updated Color4 object
  740. */
  741. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  742. /**
  743. * Copies the given float values into the current one
  744. * @param r defines the red component to read from
  745. * @param g defines the green component to read from
  746. * @param b defines the blue component to read from
  747. * @param a defines the alpha component to read from
  748. * @returns the current updated Color4 object
  749. */
  750. set(r: number, g: number, b: number, a: number): Color4;
  751. /**
  752. * Compute the Color4 hexadecimal code as a string
  753. * @returns a string containing the hexadecimal representation of the Color4 object
  754. */
  755. toHexString(): string;
  756. /**
  757. * Computes a new Color4 converted from the current one to linear space
  758. * @returns a new Color4 object
  759. */
  760. toLinearSpace(): Color4;
  761. /**
  762. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  763. * @param convertedColor defines the Color4 object where to store the linear space version
  764. * @returns the unmodified Color4
  765. */
  766. toLinearSpaceToRef(convertedColor: Color4): Color4;
  767. /**
  768. * Computes a new Color4 converted from the current one to gamma space
  769. * @returns a new Color4 object
  770. */
  771. toGammaSpace(): Color4;
  772. /**
  773. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  774. * @param convertedColor defines the Color4 object where to store the gamma space version
  775. * @returns the unmodified Color4
  776. */
  777. toGammaSpaceToRef(convertedColor: Color4): Color4;
  778. /**
  779. * Creates a new Color4 from the string containing valid hexadecimal values
  780. * @param hex defines a string containing valid hexadecimal values
  781. * @returns a new Color4 object
  782. */
  783. static FromHexString(hex: string): Color4;
  784. /**
  785. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  786. * @param left defines the start value
  787. * @param right defines the end value
  788. * @param amount defines the gradient factor
  789. * @returns a new Color4 object
  790. */
  791. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  792. /**
  793. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  794. * @param left defines the start value
  795. * @param right defines the end value
  796. * @param amount defines the gradient factor
  797. * @param result defines the Color4 object where to store data
  798. */
  799. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  800. /**
  801. * Creates a new Color4 from a Color3 and an alpha value
  802. * @param color3 defines the source Color3 to read from
  803. * @param alpha defines the alpha component (1.0 by default)
  804. * @returns a new Color4 object
  805. */
  806. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  807. /**
  808. * Creates a new Color4 from the starting index element of the given array
  809. * @param array defines the source array to read from
  810. * @param offset defines the offset in the source array
  811. * @returns a new Color4 object
  812. */
  813. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  814. /**
  815. * Creates a new Color3 from integer values (< 256)
  816. * @param r defines the red component to read from (value between 0 and 255)
  817. * @param g defines the green component to read from (value between 0 and 255)
  818. * @param b defines the blue component to read from (value between 0 and 255)
  819. * @param a defines the alpha component to read from (value between 0 and 255)
  820. * @returns a new Color3 object
  821. */
  822. static FromInts(r: number, g: number, b: number, a: number): Color4;
  823. /**
  824. * Check the content of a given array and convert it to an array containing RGBA data
  825. * If the original array was already containing count * 4 values then it is returned directly
  826. * @param colors defines the array to check
  827. * @param count defines the number of RGBA data to expect
  828. * @returns an array containing count * 4 values (RGBA)
  829. */
  830. static CheckColors4(colors: number[], count: number): number[];
  831. }
  832. /**
  833. * Class representing a vector containing 2 coordinates
  834. */
  835. export class Vector2 {
  836. /** defines the first coordinate */
  837. x: number;
  838. /** defines the second coordinate */
  839. y: number;
  840. /**
  841. * Creates a new Vector2 from the given x and y coordinates
  842. * @param x defines the first coordinate
  843. * @param y defines the second coordinate
  844. */
  845. constructor(
  846. /** defines the first coordinate */
  847. x?: number,
  848. /** defines the second coordinate */
  849. y?: number);
  850. /**
  851. * Gets a string with the Vector2 coordinates
  852. * @returns a string with the Vector2 coordinates
  853. */
  854. toString(): string;
  855. /**
  856. * Gets class name
  857. * @returns the string "Vector2"
  858. */
  859. getClassName(): string;
  860. /**
  861. * Gets current vector hash code
  862. * @returns the Vector2 hash code as a number
  863. */
  864. getHashCode(): number;
  865. /**
  866. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  867. * @param array defines the source array
  868. * @param index defines the offset in source array
  869. * @returns the current Vector2
  870. */
  871. toArray(array: FloatArray, index?: number): Vector2;
  872. /**
  873. * Copy the current vector to an array
  874. * @returns a new array with 2 elements: the Vector2 coordinates.
  875. */
  876. asArray(): number[];
  877. /**
  878. * Sets the Vector2 coordinates with the given Vector2 coordinates
  879. * @param source defines the source Vector2
  880. * @returns the current updated Vector2
  881. */
  882. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  883. /**
  884. * Sets the Vector2 coordinates with the given floats
  885. * @param x defines the first coordinate
  886. * @param y defines the second coordinate
  887. * @returns the current updated Vector2
  888. */
  889. copyFromFloats(x: number, y: number): Vector2;
  890. /**
  891. * Sets the Vector2 coordinates with the given floats
  892. * @param x defines the first coordinate
  893. * @param y defines the second coordinate
  894. * @returns the current updated Vector2
  895. */
  896. set(x: number, y: number): Vector2;
  897. /**
  898. * Add another vector with the current one
  899. * @param otherVector defines the other vector
  900. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  901. */
  902. add(otherVector: DeepImmutable<Vector2>): Vector2;
  903. /**
  904. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  905. * @param otherVector defines the other vector
  906. * @param result defines the target vector
  907. * @returns the unmodified current Vector2
  908. */
  909. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  910. /**
  911. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  912. * @param otherVector defines the other vector
  913. * @returns the current updated Vector2
  914. */
  915. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  916. /**
  917. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  918. * @param otherVector defines the other vector
  919. * @returns a new Vector2
  920. */
  921. addVector3(otherVector: Vector3): Vector2;
  922. /**
  923. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  924. * @param otherVector defines the other vector
  925. * @returns a new Vector2
  926. */
  927. subtract(otherVector: Vector2): Vector2;
  928. /**
  929. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  930. * @param otherVector defines the other vector
  931. * @param result defines the target vector
  932. * @returns the unmodified current Vector2
  933. */
  934. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  935. /**
  936. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  937. * @param otherVector defines the other vector
  938. * @returns the current updated Vector2
  939. */
  940. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  941. /**
  942. * Multiplies in place the current Vector2 coordinates by the given ones
  943. * @param otherVector defines the other vector
  944. * @returns the current updated Vector2
  945. */
  946. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  947. /**
  948. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  949. * @param otherVector defines the other vector
  950. * @returns a new Vector2
  951. */
  952. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  953. /**
  954. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  955. * @param otherVector defines the other vector
  956. * @param result defines the target vector
  957. * @returns the unmodified current Vector2
  958. */
  959. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  960. /**
  961. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  962. * @param x defines the first coordinate
  963. * @param y defines the second coordinate
  964. * @returns a new Vector2
  965. */
  966. multiplyByFloats(x: number, y: number): Vector2;
  967. /**
  968. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  969. * @param otherVector defines the other vector
  970. * @returns a new Vector2
  971. */
  972. divide(otherVector: Vector2): Vector2;
  973. /**
  974. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  975. * @param otherVector defines the other vector
  976. * @param result defines the target vector
  977. * @returns the unmodified current Vector2
  978. */
  979. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  980. /**
  981. * Divides the current Vector2 coordinates by the given ones
  982. * @param otherVector defines the other vector
  983. * @returns the current updated Vector2
  984. */
  985. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  986. /**
  987. * Gets a new Vector2 with current Vector2 negated coordinates
  988. * @returns a new Vector2
  989. */
  990. negate(): Vector2;
  991. /**
  992. * Multiply the Vector2 coordinates by scale
  993. * @param scale defines the scaling factor
  994. * @returns the current updated Vector2
  995. */
  996. scaleInPlace(scale: number): Vector2;
  997. /**
  998. * Returns a new Vector2 scaled by "scale" from the current Vector2
  999. * @param scale defines the scaling factor
  1000. * @returns a new Vector2
  1001. */
  1002. scale(scale: number): Vector2;
  1003. /**
  1004. * Scale the current Vector2 values by a factor to a given Vector2
  1005. * @param scale defines the scale factor
  1006. * @param result defines the Vector2 object where to store the result
  1007. * @returns the unmodified current Vector2
  1008. */
  1009. scaleToRef(scale: number, result: Vector2): Vector2;
  1010. /**
  1011. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1012. * @param scale defines the scale factor
  1013. * @param result defines the Vector2 object where to store the result
  1014. * @returns the unmodified current Vector2
  1015. */
  1016. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1017. /**
  1018. * Gets a boolean if two vectors are equals
  1019. * @param otherVector defines the other vector
  1020. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1021. */
  1022. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1023. /**
  1024. * Gets a boolean if two vectors are equals (using an epsilon value)
  1025. * @param otherVector defines the other vector
  1026. * @param epsilon defines the minimal distance to consider equality
  1027. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1028. */
  1029. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1030. /**
  1031. * Gets a new Vector2 from current Vector2 floored values
  1032. * @returns a new Vector2
  1033. */
  1034. floor(): Vector2;
  1035. /**
  1036. * Gets a new Vector2 from current Vector2 floored values
  1037. * @returns a new Vector2
  1038. */
  1039. fract(): Vector2;
  1040. /**
  1041. * Gets the length of the vector
  1042. * @returns the vector length (float)
  1043. */
  1044. length(): number;
  1045. /**
  1046. * Gets the vector squared length
  1047. * @returns the vector squared length (float)
  1048. */
  1049. lengthSquared(): number;
  1050. /**
  1051. * Normalize the vector
  1052. * @returns the current updated Vector2
  1053. */
  1054. normalize(): Vector2;
  1055. /**
  1056. * Gets a new Vector2 copied from the Vector2
  1057. * @returns a new Vector2
  1058. */
  1059. clone(): Vector2;
  1060. /**
  1061. * Gets a new Vector2(0, 0)
  1062. * @returns a new Vector2
  1063. */
  1064. static Zero(): Vector2;
  1065. /**
  1066. * Gets a new Vector2(1, 1)
  1067. * @returns a new Vector2
  1068. */
  1069. static One(): Vector2;
  1070. /**
  1071. * Gets a new Vector2 set from the given index element of the given array
  1072. * @param array defines the data source
  1073. * @param offset defines the offset in the data source
  1074. * @returns a new Vector2
  1075. */
  1076. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1077. /**
  1078. * Sets "result" from the given index element of the given array
  1079. * @param array defines the data source
  1080. * @param offset defines the offset in the data source
  1081. * @param result defines the target vector
  1082. */
  1083. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1084. /**
  1085. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1086. * @param value1 defines 1st point of control
  1087. * @param value2 defines 2nd point of control
  1088. * @param value3 defines 3rd point of control
  1089. * @param value4 defines 4th point of control
  1090. * @param amount defines the interpolation factor
  1091. * @returns a new Vector2
  1092. */
  1093. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1094. /**
  1095. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1096. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1097. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1098. * @param value defines the value to clamp
  1099. * @param min defines the lower limit
  1100. * @param max defines the upper limit
  1101. * @returns a new Vector2
  1102. */
  1103. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1104. /**
  1105. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1106. * @param value1 defines the 1st control point
  1107. * @param tangent1 defines the outgoing tangent
  1108. * @param value2 defines the 2nd control point
  1109. * @param tangent2 defines the incoming tangent
  1110. * @param amount defines the interpolation factor
  1111. * @returns a new Vector2
  1112. */
  1113. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1114. /**
  1115. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1116. * @param start defines the start vector
  1117. * @param end defines the end vector
  1118. * @param amount defines the interpolation factor
  1119. * @returns a new Vector2
  1120. */
  1121. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1122. /**
  1123. * Gets the dot product of the vector "left" and the vector "right"
  1124. * @param left defines first vector
  1125. * @param right defines second vector
  1126. * @returns the dot product (float)
  1127. */
  1128. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1129. /**
  1130. * Returns a new Vector2 equal to the normalized given vector
  1131. * @param vector defines the vector to normalize
  1132. * @returns a new Vector2
  1133. */
  1134. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1135. /**
  1136. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1137. * @param left defines 1st vector
  1138. * @param right defines 2nd vector
  1139. * @returns a new Vector2
  1140. */
  1141. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1142. /**
  1143. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1144. * @param left defines 1st vector
  1145. * @param right defines 2nd vector
  1146. * @returns a new Vector2
  1147. */
  1148. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1149. /**
  1150. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1151. * @param vector defines the vector to transform
  1152. * @param transformation defines the matrix to apply
  1153. * @returns a new Vector2
  1154. */
  1155. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1156. /**
  1157. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1158. * @param vector defines the vector to transform
  1159. * @param transformation defines the matrix to apply
  1160. * @param result defines the target vector
  1161. */
  1162. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1163. /**
  1164. * Determines if a given vector is included in a triangle
  1165. * @param p defines the vector to test
  1166. * @param p0 defines 1st triangle point
  1167. * @param p1 defines 2nd triangle point
  1168. * @param p2 defines 3rd triangle point
  1169. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1170. */
  1171. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1172. /**
  1173. * Gets the distance between the vectors "value1" and "value2"
  1174. * @param value1 defines first vector
  1175. * @param value2 defines second vector
  1176. * @returns the distance between vectors
  1177. */
  1178. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1179. /**
  1180. * Returns the squared distance between the vectors "value1" and "value2"
  1181. * @param value1 defines first vector
  1182. * @param value2 defines second vector
  1183. * @returns the squared distance between vectors
  1184. */
  1185. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1186. /**
  1187. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1188. * @param value1 defines first vector
  1189. * @param value2 defines second vector
  1190. * @returns a new Vector2
  1191. */
  1192. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1193. /**
  1194. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1195. * @param p defines the middle point
  1196. * @param segA defines one point of the segment
  1197. * @param segB defines the other point of the segment
  1198. * @returns the shortest distance
  1199. */
  1200. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1201. }
  1202. /**
  1203. * Classed used to store (x,y,z) vector representation
  1204. * A Vector3 is the main object used in 3D geometry
  1205. * It can represent etiher the coordinates of a point the space, either a direction
  1206. * Reminder: js uses a left handed forward facing system
  1207. */
  1208. export class Vector3 {
  1209. /**
  1210. * Defines the first coordinates (on X axis)
  1211. */
  1212. x: number;
  1213. /**
  1214. * Defines the second coordinates (on Y axis)
  1215. */
  1216. y: number;
  1217. /**
  1218. * Defines the third coordinates (on Z axis)
  1219. */
  1220. z: number;
  1221. private static _UpReadOnly;
  1222. /**
  1223. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1224. * @param x defines the first coordinates (on X axis)
  1225. * @param y defines the second coordinates (on Y axis)
  1226. * @param z defines the third coordinates (on Z axis)
  1227. */
  1228. constructor(
  1229. /**
  1230. * Defines the first coordinates (on X axis)
  1231. */
  1232. x?: number,
  1233. /**
  1234. * Defines the second coordinates (on Y axis)
  1235. */
  1236. y?: number,
  1237. /**
  1238. * Defines the third coordinates (on Z axis)
  1239. */
  1240. z?: number);
  1241. /**
  1242. * Creates a string representation of the Vector3
  1243. * @returns a string with the Vector3 coordinates.
  1244. */
  1245. toString(): string;
  1246. /**
  1247. * Gets the class name
  1248. * @returns the string "Vector3"
  1249. */
  1250. getClassName(): string;
  1251. /**
  1252. * Creates the Vector3 hash code
  1253. * @returns a number which tends to be unique between Vector3 instances
  1254. */
  1255. getHashCode(): number;
  1256. /**
  1257. * Creates an array containing three elements : the coordinates of the Vector3
  1258. * @returns a new array of numbers
  1259. */
  1260. asArray(): number[];
  1261. /**
  1262. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1263. * @param array defines the destination array
  1264. * @param index defines the offset in the destination array
  1265. * @returns the current Vector3
  1266. */
  1267. toArray(array: FloatArray, index?: number): Vector3;
  1268. /**
  1269. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1270. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1271. */
  1272. toQuaternion(): Quaternion;
  1273. /**
  1274. * Adds the given vector to the current Vector3
  1275. * @param otherVector defines the second operand
  1276. * @returns the current updated Vector3
  1277. */
  1278. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1279. /**
  1280. * Adds the given coordinates to the current Vector3
  1281. * @param x defines the x coordinate of the operand
  1282. * @param y defines the y coordinate of the operand
  1283. * @param z defines the z coordinate of the operand
  1284. * @returns the current updated Vector3
  1285. */
  1286. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1287. /**
  1288. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1289. * @param otherVector defines the second operand
  1290. * @returns the resulting Vector3
  1291. */
  1292. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1293. /**
  1294. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1295. * @param otherVector defines the second operand
  1296. * @param result defines the Vector3 object where to store the result
  1297. * @returns the current Vector3
  1298. */
  1299. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1300. /**
  1301. * Subtract the given vector from the current Vector3
  1302. * @param otherVector defines the second operand
  1303. * @returns the current updated Vector3
  1304. */
  1305. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1306. /**
  1307. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1308. * @param otherVector defines the second operand
  1309. * @returns the resulting Vector3
  1310. */
  1311. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1312. /**
  1313. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1314. * @param otherVector defines the second operand
  1315. * @param result defines the Vector3 object where to store the result
  1316. * @returns the current Vector3
  1317. */
  1318. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1319. /**
  1320. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1321. * @param x defines the x coordinate of the operand
  1322. * @param y defines the y coordinate of the operand
  1323. * @param z defines the z coordinate of the operand
  1324. * @returns the resulting Vector3
  1325. */
  1326. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1327. /**
  1328. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1329. * @param x defines the x coordinate of the operand
  1330. * @param y defines the y coordinate of the operand
  1331. * @param z defines the z coordinate of the operand
  1332. * @param result defines the Vector3 object where to store the result
  1333. * @returns the current Vector3
  1334. */
  1335. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1336. /**
  1337. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1338. * @returns a new Vector3
  1339. */
  1340. negate(): Vector3;
  1341. /**
  1342. * Multiplies the Vector3 coordinates by the float "scale"
  1343. * @param scale defines the multiplier factor
  1344. * @returns the current updated Vector3
  1345. */
  1346. scaleInPlace(scale: number): Vector3;
  1347. /**
  1348. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1349. * @param scale defines the multiplier factor
  1350. * @returns a new Vector3
  1351. */
  1352. scale(scale: number): Vector3;
  1353. /**
  1354. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1355. * @param scale defines the multiplier factor
  1356. * @param result defines the Vector3 object where to store the result
  1357. * @returns the current Vector3
  1358. */
  1359. scaleToRef(scale: number, result: Vector3): Vector3;
  1360. /**
  1361. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1362. * @param scale defines the scale factor
  1363. * @param result defines the Vector3 object where to store the result
  1364. * @returns the unmodified current Vector3
  1365. */
  1366. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1367. /**
  1368. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1369. * @param otherVector defines the second operand
  1370. * @returns true if both vectors are equals
  1371. */
  1372. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1373. /**
  1374. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1375. * @param otherVector defines the second operand
  1376. * @param epsilon defines the minimal distance to define values as equals
  1377. * @returns true if both vectors are distant less than epsilon
  1378. */
  1379. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1380. /**
  1381. * Returns true if the current Vector3 coordinates equals the given floats
  1382. * @param x defines the x coordinate of the operand
  1383. * @param y defines the y coordinate of the operand
  1384. * @param z defines the z coordinate of the operand
  1385. * @returns true if both vectors are equals
  1386. */
  1387. equalsToFloats(x: number, y: number, z: number): boolean;
  1388. /**
  1389. * Multiplies the current Vector3 coordinates by the given ones
  1390. * @param otherVector defines the second operand
  1391. * @returns the current updated Vector3
  1392. */
  1393. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1394. /**
  1395. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1396. * @param otherVector defines the second operand
  1397. * @returns the new Vector3
  1398. */
  1399. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1400. /**
  1401. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1402. * @param otherVector defines the second operand
  1403. * @param result defines the Vector3 object where to store the result
  1404. * @returns the current Vector3
  1405. */
  1406. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1407. /**
  1408. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1409. * @param x defines the x coordinate of the operand
  1410. * @param y defines the y coordinate of the operand
  1411. * @param z defines the z coordinate of the operand
  1412. * @returns the new Vector3
  1413. */
  1414. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1415. /**
  1416. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1417. * @param otherVector defines the second operand
  1418. * @returns the new Vector3
  1419. */
  1420. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1421. /**
  1422. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1423. * @param otherVector defines the second operand
  1424. * @param result defines the Vector3 object where to store the result
  1425. * @returns the current Vector3
  1426. */
  1427. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1428. /**
  1429. * Divides the current Vector3 coordinates by the given ones.
  1430. * @param otherVector defines the second operand
  1431. * @returns the current updated Vector3
  1432. */
  1433. divideInPlace(otherVector: Vector3): Vector3;
  1434. /**
  1435. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1436. * @param other defines the second operand
  1437. * @returns the current updated Vector3
  1438. */
  1439. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1440. /**
  1441. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1442. * @param other defines the second operand
  1443. * @returns the current updated Vector3
  1444. */
  1445. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1446. /**
  1447. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1448. * @param x defines the x coordinate of the operand
  1449. * @param y defines the y coordinate of the operand
  1450. * @param z defines the z coordinate of the operand
  1451. * @returns the current updated Vector3
  1452. */
  1453. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1454. /**
  1455. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1456. * @param x defines the x coordinate of the operand
  1457. * @param y defines the y coordinate of the operand
  1458. * @param z defines the z coordinate of the operand
  1459. * @returns the current updated Vector3
  1460. */
  1461. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1462. /**
  1463. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1464. * Check if is non uniform within a certain amount of decimal places to account for this
  1465. * @param epsilon the amount the values can differ
  1466. * @returns if the the vector is non uniform to a certain number of decimal places
  1467. */
  1468. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1469. /**
  1470. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1471. */
  1472. readonly isNonUniform: boolean;
  1473. /**
  1474. * Gets a new Vector3 from current Vector3 floored values
  1475. * @returns a new Vector3
  1476. */
  1477. floor(): Vector3;
  1478. /**
  1479. * Gets a new Vector3 from current Vector3 floored values
  1480. * @returns a new Vector3
  1481. */
  1482. fract(): Vector3;
  1483. /**
  1484. * Gets the length of the Vector3
  1485. * @returns the length of the Vecto3
  1486. */
  1487. length(): number;
  1488. /**
  1489. * Gets the squared length of the Vector3
  1490. * @returns squared length of the Vector3
  1491. */
  1492. lengthSquared(): number;
  1493. /**
  1494. * Normalize the current Vector3.
  1495. * Please note that this is an in place operation.
  1496. * @returns the current updated Vector3
  1497. */
  1498. normalize(): Vector3;
  1499. /**
  1500. * Reorders the x y z properties of the vector in place
  1501. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1502. * @returns the current updated vector
  1503. */
  1504. reorderInPlace(order: string): this;
  1505. /**
  1506. * Rotates the vector around 0,0,0 by a quaternion
  1507. * @param quaternion the rotation quaternion
  1508. * @param result vector to store the result
  1509. * @returns the resulting vector
  1510. */
  1511. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1512. /**
  1513. * Rotates a vector around a given point
  1514. * @param quaternion the rotation quaternion
  1515. * @param point the point to rotate around
  1516. * @param result vector to store the result
  1517. * @returns the resulting vector
  1518. */
  1519. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1520. /**
  1521. * Normalize the current Vector3 with the given input length.
  1522. * Please note that this is an in place operation.
  1523. * @param len the length of the vector
  1524. * @returns the current updated Vector3
  1525. */
  1526. normalizeFromLength(len: number): Vector3;
  1527. /**
  1528. * Normalize the current Vector3 to a new vector
  1529. * @returns the new Vector3
  1530. */
  1531. normalizeToNew(): Vector3;
  1532. /**
  1533. * Normalize the current Vector3 to the reference
  1534. * @param reference define the Vector3 to update
  1535. * @returns the updated Vector3
  1536. */
  1537. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1538. /**
  1539. * Creates a new Vector3 copied from the current Vector3
  1540. * @returns the new Vector3
  1541. */
  1542. clone(): Vector3;
  1543. /**
  1544. * Copies the given vector coordinates to the current Vector3 ones
  1545. * @param source defines the source Vector3
  1546. * @returns the current updated Vector3
  1547. */
  1548. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1549. /**
  1550. * Copies the given floats to the current Vector3 coordinates
  1551. * @param x defines the x coordinate of the operand
  1552. * @param y defines the y coordinate of the operand
  1553. * @param z defines the z coordinate of the operand
  1554. * @returns the current updated Vector3
  1555. */
  1556. copyFromFloats(x: number, y: number, z: number): Vector3;
  1557. /**
  1558. * Copies the given floats to the current Vector3 coordinates
  1559. * @param x defines the x coordinate of the operand
  1560. * @param y defines the y coordinate of the operand
  1561. * @param z defines the z coordinate of the operand
  1562. * @returns the current updated Vector3
  1563. */
  1564. set(x: number, y: number, z: number): Vector3;
  1565. /**
  1566. * Copies the given float to the current Vector3 coordinates
  1567. * @param v defines the x, y and z coordinates of the operand
  1568. * @returns the current updated Vector3
  1569. */
  1570. setAll(v: number): Vector3;
  1571. /**
  1572. * Get the clip factor between two vectors
  1573. * @param vector0 defines the first operand
  1574. * @param vector1 defines the second operand
  1575. * @param axis defines the axis to use
  1576. * @param size defines the size along the axis
  1577. * @returns the clip factor
  1578. */
  1579. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1580. /**
  1581. * Get angle between two vectors
  1582. * @param vector0 angle between vector0 and vector1
  1583. * @param vector1 angle between vector0 and vector1
  1584. * @param normal direction of the normal
  1585. * @return the angle between vector0 and vector1
  1586. */
  1587. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1588. /**
  1589. * Returns a new Vector3 set from the index "offset" of the given array
  1590. * @param array defines the source array
  1591. * @param offset defines the offset in the source array
  1592. * @returns the new Vector3
  1593. */
  1594. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1595. /**
  1596. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1597. * This function is deprecated. Use FromArray instead
  1598. * @param array defines the source array
  1599. * @param offset defines the offset in the source array
  1600. * @returns the new Vector3
  1601. */
  1602. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1603. /**
  1604. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1605. * @param array defines the source array
  1606. * @param offset defines the offset in the source array
  1607. * @param result defines the Vector3 where to store the result
  1608. */
  1609. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1610. /**
  1611. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1612. * This function is deprecated. Use FromArrayToRef instead.
  1613. * @param array defines the source array
  1614. * @param offset defines the offset in the source array
  1615. * @param result defines the Vector3 where to store the result
  1616. */
  1617. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1618. /**
  1619. * Sets the given vector "result" with the given floats.
  1620. * @param x defines the x coordinate of the source
  1621. * @param y defines the y coordinate of the source
  1622. * @param z defines the z coordinate of the source
  1623. * @param result defines the Vector3 where to store the result
  1624. */
  1625. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1626. /**
  1627. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1628. * @returns a new empty Vector3
  1629. */
  1630. static Zero(): Vector3;
  1631. /**
  1632. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1633. * @returns a new unit Vector3
  1634. */
  1635. static One(): Vector3;
  1636. /**
  1637. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1638. * @returns a new up Vector3
  1639. */
  1640. static Up(): Vector3;
  1641. /**
  1642. * Gets a up Vector3 that must not be updated
  1643. */
  1644. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1647. * @returns a new down Vector3
  1648. */
  1649. static Down(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1652. * @returns a new forward Vector3
  1653. */
  1654. static Forward(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1657. * @returns a new forward Vector3
  1658. */
  1659. static Backward(): Vector3;
  1660. /**
  1661. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1662. * @returns a new right Vector3
  1663. */
  1664. static Right(): Vector3;
  1665. /**
  1666. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1667. * @returns a new left Vector3
  1668. */
  1669. static Left(): Vector3;
  1670. /**
  1671. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1672. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1673. * @param vector defines the Vector3 to transform
  1674. * @param transformation defines the transformation matrix
  1675. * @returns the transformed Vector3
  1676. */
  1677. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1678. /**
  1679. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1680. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1681. * @param vector defines the Vector3 to transform
  1682. * @param transformation defines the transformation matrix
  1683. * @param result defines the Vector3 where to store the result
  1684. */
  1685. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1686. /**
  1687. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1688. * This method computes tranformed coordinates only, not transformed direction vectors
  1689. * @param x define the x coordinate of the source vector
  1690. * @param y define the y coordinate of the source vector
  1691. * @param z define the z coordinate of the source vector
  1692. * @param transformation defines the transformation matrix
  1693. * @param result defines the Vector3 where to store the result
  1694. */
  1695. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1696. /**
  1697. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1698. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1699. * @param vector defines the Vector3 to transform
  1700. * @param transformation defines the transformation matrix
  1701. * @returns the new Vector3
  1702. */
  1703. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1704. /**
  1705. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1706. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1707. * @param vector defines the Vector3 to transform
  1708. * @param transformation defines the transformation matrix
  1709. * @param result defines the Vector3 where to store the result
  1710. */
  1711. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1712. /**
  1713. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1714. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1715. * @param x define the x coordinate of the source vector
  1716. * @param y define the y coordinate of the source vector
  1717. * @param z define the z coordinate of the source vector
  1718. * @param transformation defines the transformation matrix
  1719. * @param result defines the Vector3 where to store the result
  1720. */
  1721. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1722. /**
  1723. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1724. * @param value1 defines the first control point
  1725. * @param value2 defines the second control point
  1726. * @param value3 defines the third control point
  1727. * @param value4 defines the fourth control point
  1728. * @param amount defines the amount on the spline to use
  1729. * @returns the new Vector3
  1730. */
  1731. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1732. /**
  1733. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1734. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1735. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1736. * @param value defines the current value
  1737. * @param min defines the lower range value
  1738. * @param max defines the upper range value
  1739. * @returns the new Vector3
  1740. */
  1741. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1742. /**
  1743. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1744. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1745. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1746. * @param value defines the current value
  1747. * @param min defines the lower range value
  1748. * @param max defines the upper range value
  1749. * @param result defines the Vector3 where to store the result
  1750. */
  1751. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1752. /**
  1753. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1754. * @param value1 defines the first control point
  1755. * @param tangent1 defines the first tangent vector
  1756. * @param value2 defines the second control point
  1757. * @param tangent2 defines the second tangent vector
  1758. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1759. * @returns the new Vector3
  1760. */
  1761. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1762. /**
  1763. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1764. * @param start defines the start value
  1765. * @param end defines the end value
  1766. * @param amount max defines amount between both (between 0 and 1)
  1767. * @returns the new Vector3
  1768. */
  1769. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1770. /**
  1771. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1772. * @param start defines the start value
  1773. * @param end defines the end value
  1774. * @param amount max defines amount between both (between 0 and 1)
  1775. * @param result defines the Vector3 where to store the result
  1776. */
  1777. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1778. /**
  1779. * Returns the dot product (float) between the vectors "left" and "right"
  1780. * @param left defines the left operand
  1781. * @param right defines the right operand
  1782. * @returns the dot product
  1783. */
  1784. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1785. /**
  1786. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1787. * The cross product is then orthogonal to both "left" and "right"
  1788. * @param left defines the left operand
  1789. * @param right defines the right operand
  1790. * @returns the cross product
  1791. */
  1792. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the cross product of "left" and "right"
  1795. * The cross product is then orthogonal to both "left" and "right"
  1796. * @param left defines the left operand
  1797. * @param right defines the right operand
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1801. /**
  1802. * Returns a new Vector3 as the normalization of the given vector
  1803. * @param vector defines the Vector3 to normalize
  1804. * @returns the new Vector3
  1805. */
  1806. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1807. /**
  1808. * Sets the given vector "result" with the normalization of the given first vector
  1809. * @param vector defines the Vector3 to normalize
  1810. * @param result defines the Vector3 where to store the result
  1811. */
  1812. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1813. /**
  1814. * Project a Vector3 onto screen space
  1815. * @param vector defines the Vector3 to project
  1816. * @param world defines the world matrix to use
  1817. * @param transform defines the transform (view x projection) matrix to use
  1818. * @param viewport defines the screen viewport to use
  1819. * @returns the new Vector3
  1820. */
  1821. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1822. /** @hidden */
  1823. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1824. /**
  1825. * Unproject from screen space to object space
  1826. * @param source defines the screen space Vector3 to use
  1827. * @param viewportWidth defines the current width of the viewport
  1828. * @param viewportHeight defines the current height of the viewport
  1829. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1830. * @param transform defines the transform (view x projection) matrix to use
  1831. * @returns the new Vector3
  1832. */
  1833. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1834. /**
  1835. * Unproject from screen space to object space
  1836. * @param source defines the screen space Vector3 to use
  1837. * @param viewportWidth defines the current width of the viewport
  1838. * @param viewportHeight defines the current height of the viewport
  1839. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1840. * @param view defines the view matrix to use
  1841. * @param projection defines the projection matrix to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1845. /**
  1846. * Unproject from screen space to object space
  1847. * @param source defines the screen space Vector3 to use
  1848. * @param viewportWidth defines the current width of the viewport
  1849. * @param viewportHeight defines the current height of the viewport
  1850. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1851. * @param view defines the view matrix to use
  1852. * @param projection defines the projection matrix to use
  1853. * @param result defines the Vector3 where to store the result
  1854. */
  1855. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1856. /**
  1857. * Unproject from screen space to object space
  1858. * @param sourceX defines the screen space x coordinate to use
  1859. * @param sourceY defines the screen space y coordinate to use
  1860. * @param sourceZ defines the screen space z coordinate to use
  1861. * @param viewportWidth defines the current width of the viewport
  1862. * @param viewportHeight defines the current height of the viewport
  1863. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1864. * @param view defines the view matrix to use
  1865. * @param projection defines the projection matrix to use
  1866. * @param result defines the Vector3 where to store the result
  1867. */
  1868. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1869. /**
  1870. * Gets the minimal coordinate values between two Vector3
  1871. * @param left defines the first operand
  1872. * @param right defines the second operand
  1873. * @returns the new Vector3
  1874. */
  1875. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1876. /**
  1877. * Gets the maximal coordinate values between two Vector3
  1878. * @param left defines the first operand
  1879. * @param right defines the second operand
  1880. * @returns the new Vector3
  1881. */
  1882. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1883. /**
  1884. * Returns the distance between the vectors "value1" and "value2"
  1885. * @param value1 defines the first operand
  1886. * @param value2 defines the second operand
  1887. * @returns the distance
  1888. */
  1889. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1890. /**
  1891. * Returns the squared distance between the vectors "value1" and "value2"
  1892. * @param value1 defines the first operand
  1893. * @param value2 defines the second operand
  1894. * @returns the squared distance
  1895. */
  1896. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1897. /**
  1898. * Returns a new Vector3 located at the center between "value1" and "value2"
  1899. * @param value1 defines the first operand
  1900. * @param value2 defines the second operand
  1901. * @returns the new Vector3
  1902. */
  1903. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1904. /**
  1905. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1906. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1907. * to something in order to rotate it from its local system to the given target system
  1908. * Note: axis1, axis2 and axis3 are normalized during this operation
  1909. * @param axis1 defines the first axis
  1910. * @param axis2 defines the second axis
  1911. * @param axis3 defines the third axis
  1912. * @returns a new Vector3
  1913. */
  1914. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1915. /**
  1916. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1917. * @param axis1 defines the first axis
  1918. * @param axis2 defines the second axis
  1919. * @param axis3 defines the third axis
  1920. * @param ref defines the Vector3 where to store the result
  1921. */
  1922. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1923. }
  1924. /**
  1925. * Vector4 class created for EulerAngle class conversion to Quaternion
  1926. */
  1927. export class Vector4 {
  1928. /** x value of the vector */
  1929. x: number;
  1930. /** y value of the vector */
  1931. y: number;
  1932. /** z value of the vector */
  1933. z: number;
  1934. /** w value of the vector */
  1935. w: number;
  1936. /**
  1937. * Creates a Vector4 object from the given floats.
  1938. * @param x x value of the vector
  1939. * @param y y value of the vector
  1940. * @param z z value of the vector
  1941. * @param w w value of the vector
  1942. */
  1943. constructor(
  1944. /** x value of the vector */
  1945. x: number,
  1946. /** y value of the vector */
  1947. y: number,
  1948. /** z value of the vector */
  1949. z: number,
  1950. /** w value of the vector */
  1951. w: number);
  1952. /**
  1953. * Returns the string with the Vector4 coordinates.
  1954. * @returns a string containing all the vector values
  1955. */
  1956. toString(): string;
  1957. /**
  1958. * Returns the string "Vector4".
  1959. * @returns "Vector4"
  1960. */
  1961. getClassName(): string;
  1962. /**
  1963. * Returns the Vector4 hash code.
  1964. * @returns a unique hash code
  1965. */
  1966. getHashCode(): number;
  1967. /**
  1968. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1969. * @returns the resulting array
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Populates the given array from the given index with the Vector4 coordinates.
  1974. * @param array array to populate
  1975. * @param index index of the array to start at (default: 0)
  1976. * @returns the Vector4.
  1977. */
  1978. toArray(array: FloatArray, index?: number): Vector4;
  1979. /**
  1980. * Adds the given vector to the current Vector4.
  1981. * @param otherVector the vector to add
  1982. * @returns the updated Vector4.
  1983. */
  1984. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1985. /**
  1986. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1987. * @param otherVector the vector to add
  1988. * @returns the resulting vector
  1989. */
  1990. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1991. /**
  1992. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1993. * @param otherVector the vector to add
  1994. * @param result the vector to store the result
  1995. * @returns the current Vector4.
  1996. */
  1997. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1998. /**
  1999. * Subtract in place the given vector from the current Vector4.
  2000. * @param otherVector the vector to subtract
  2001. * @returns the updated Vector4.
  2002. */
  2003. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2004. /**
  2005. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2006. * @param otherVector the vector to add
  2007. * @returns the new vector with the result
  2008. */
  2009. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2010. /**
  2011. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2012. * @param otherVector the vector to subtract
  2013. * @param result the vector to store the result
  2014. * @returns the current Vector4.
  2015. */
  2016. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2017. /**
  2018. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2019. */
  2020. /**
  2021. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2022. * @param x value to subtract
  2023. * @param y value to subtract
  2024. * @param z value to subtract
  2025. * @param w value to subtract
  2026. * @returns new vector containing the result
  2027. */
  2028. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2029. /**
  2030. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2031. * @param x value to subtract
  2032. * @param y value to subtract
  2033. * @param z value to subtract
  2034. * @param w value to subtract
  2035. * @param result the vector to store the result in
  2036. * @returns the current Vector4.
  2037. */
  2038. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2039. /**
  2040. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2041. * @returns a new vector with the negated values
  2042. */
  2043. negate(): Vector4;
  2044. /**
  2045. * Multiplies the current Vector4 coordinates by scale (float).
  2046. * @param scale the number to scale with
  2047. * @returns the updated Vector4.
  2048. */
  2049. scaleInPlace(scale: number): Vector4;
  2050. /**
  2051. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2052. * @param scale the number to scale with
  2053. * @returns a new vector with the result
  2054. */
  2055. scale(scale: number): Vector4;
  2056. /**
  2057. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2058. * @param scale the number to scale with
  2059. * @param result a vector to store the result in
  2060. * @returns the current Vector4.
  2061. */
  2062. scaleToRef(scale: number, result: Vector4): Vector4;
  2063. /**
  2064. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2065. * @param scale defines the scale factor
  2066. * @param result defines the Vector4 object where to store the result
  2067. * @returns the unmodified current Vector4
  2068. */
  2069. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2070. /**
  2071. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2072. * @param otherVector the vector to compare against
  2073. * @returns true if they are equal
  2074. */
  2075. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2076. /**
  2077. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2078. * @param otherVector vector to compare against
  2079. * @param epsilon (Default: very small number)
  2080. * @returns true if they are equal
  2081. */
  2082. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2083. /**
  2084. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2085. * @param x x value to compare against
  2086. * @param y y value to compare against
  2087. * @param z z value to compare against
  2088. * @param w w value to compare against
  2089. * @returns true if equal
  2090. */
  2091. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2092. /**
  2093. * Multiplies in place the current Vector4 by the given one.
  2094. * @param otherVector vector to multiple with
  2095. * @returns the updated Vector4.
  2096. */
  2097. multiplyInPlace(otherVector: Vector4): Vector4;
  2098. /**
  2099. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2100. * @param otherVector vector to multiple with
  2101. * @returns resulting new vector
  2102. */
  2103. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2104. /**
  2105. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2106. * @param otherVector vector to multiple with
  2107. * @param result vector to store the result
  2108. * @returns the current Vector4.
  2109. */
  2110. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2111. /**
  2112. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2113. * @param x x value multiply with
  2114. * @param y y value multiply with
  2115. * @param z z value multiply with
  2116. * @param w w value multiply with
  2117. * @returns resulting new vector
  2118. */
  2119. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2120. /**
  2121. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2122. * @param otherVector vector to devide with
  2123. * @returns resulting new vector
  2124. */
  2125. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2126. /**
  2127. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2128. * @param otherVector vector to devide with
  2129. * @param result vector to store the result
  2130. * @returns the current Vector4.
  2131. */
  2132. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2133. /**
  2134. * Divides the current Vector3 coordinates by the given ones.
  2135. * @param otherVector vector to devide with
  2136. * @returns the updated Vector3.
  2137. */
  2138. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2139. /**
  2140. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2141. * @param other defines the second operand
  2142. * @returns the current updated Vector4
  2143. */
  2144. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2145. /**
  2146. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2147. * @param other defines the second operand
  2148. * @returns the current updated Vector4
  2149. */
  2150. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2151. /**
  2152. * Gets a new Vector4 from current Vector4 floored values
  2153. * @returns a new Vector4
  2154. */
  2155. floor(): Vector4;
  2156. /**
  2157. * Gets a new Vector4 from current Vector3 floored values
  2158. * @returns a new Vector4
  2159. */
  2160. fract(): Vector4;
  2161. /**
  2162. * Returns the Vector4 length (float).
  2163. * @returns the length
  2164. */
  2165. length(): number;
  2166. /**
  2167. * Returns the Vector4 squared length (float).
  2168. * @returns the length squared
  2169. */
  2170. lengthSquared(): number;
  2171. /**
  2172. * Normalizes in place the Vector4.
  2173. * @returns the updated Vector4.
  2174. */
  2175. normalize(): Vector4;
  2176. /**
  2177. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2178. * @returns this converted to a new vector3
  2179. */
  2180. toVector3(): Vector3;
  2181. /**
  2182. * Returns a new Vector4 copied from the current one.
  2183. * @returns the new cloned vector
  2184. */
  2185. clone(): Vector4;
  2186. /**
  2187. * Updates the current Vector4 with the given one coordinates.
  2188. * @param source the source vector to copy from
  2189. * @returns the updated Vector4.
  2190. */
  2191. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2192. /**
  2193. * Updates the current Vector4 coordinates with the given floats.
  2194. * @param x float to copy from
  2195. * @param y float to copy from
  2196. * @param z float to copy from
  2197. * @param w float to copy from
  2198. * @returns the updated Vector4.
  2199. */
  2200. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2201. /**
  2202. * Updates the current Vector4 coordinates with the given floats.
  2203. * @param x float to set from
  2204. * @param y float to set from
  2205. * @param z float to set from
  2206. * @param w float to set from
  2207. * @returns the updated Vector4.
  2208. */
  2209. set(x: number, y: number, z: number, w: number): Vector4;
  2210. /**
  2211. * Copies the given float to the current Vector3 coordinates
  2212. * @param v defines the x, y, z and w coordinates of the operand
  2213. * @returns the current updated Vector3
  2214. */
  2215. setAll(v: number): Vector4;
  2216. /**
  2217. * Returns a new Vector4 set from the starting index of the given array.
  2218. * @param array the array to pull values from
  2219. * @param offset the offset into the array to start at
  2220. * @returns the new vector
  2221. */
  2222. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2223. /**
  2224. * Updates the given vector "result" from the starting index of the given array.
  2225. * @param array the array to pull values from
  2226. * @param offset the offset into the array to start at
  2227. * @param result the vector to store the result in
  2228. */
  2229. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2230. /**
  2231. * Updates the given vector "result" from the starting index of the given Float32Array.
  2232. * @param array the array to pull values from
  2233. * @param offset the offset into the array to start at
  2234. * @param result the vector to store the result in
  2235. */
  2236. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2237. /**
  2238. * Updates the given vector "result" coordinates from the given floats.
  2239. * @param x float to set from
  2240. * @param y float to set from
  2241. * @param z float to set from
  2242. * @param w float to set from
  2243. * @param result the vector to the floats in
  2244. */
  2245. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2246. /**
  2247. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2248. * @returns the new vector
  2249. */
  2250. static Zero(): Vector4;
  2251. /**
  2252. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2253. * @returns the new vector
  2254. */
  2255. static One(): Vector4;
  2256. /**
  2257. * Returns a new normalized Vector4 from the given one.
  2258. * @param vector the vector to normalize
  2259. * @returns the vector
  2260. */
  2261. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2262. /**
  2263. * Updates the given vector "result" from the normalization of the given one.
  2264. * @param vector the vector to normalize
  2265. * @param result the vector to store the result in
  2266. */
  2267. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2268. /**
  2269. * Returns a vector with the minimum values from the left and right vectors
  2270. * @param left left vector to minimize
  2271. * @param right right vector to minimize
  2272. * @returns a new vector with the minimum of the left and right vector values
  2273. */
  2274. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2275. /**
  2276. * Returns a vector with the maximum values from the left and right vectors
  2277. * @param left left vector to maximize
  2278. * @param right right vector to maximize
  2279. * @returns a new vector with the maximum of the left and right vector values
  2280. */
  2281. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2282. /**
  2283. * Returns the distance (float) between the vectors "value1" and "value2".
  2284. * @param value1 value to calulate the distance between
  2285. * @param value2 value to calulate the distance between
  2286. * @return the distance between the two vectors
  2287. */
  2288. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2289. /**
  2290. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2291. * @param value1 value to calulate the distance between
  2292. * @param value2 value to calulate the distance between
  2293. * @return the distance between the two vectors squared
  2294. */
  2295. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2296. /**
  2297. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2298. * @param value1 value to calulate the center between
  2299. * @param value2 value to calulate the center between
  2300. * @return the center between the two vectors
  2301. */
  2302. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2303. /**
  2304. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2305. * This methods computes transformed normalized direction vectors only.
  2306. * @param vector the vector to transform
  2307. * @param transformation the transformation matrix to apply
  2308. * @returns the new vector
  2309. */
  2310. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2311. /**
  2312. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2313. * This methods computes transformed normalized direction vectors only.
  2314. * @param vector the vector to transform
  2315. * @param transformation the transformation matrix to apply
  2316. * @param result the vector to store the result in
  2317. */
  2318. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2319. /**
  2320. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2321. * This methods computes transformed normalized direction vectors only.
  2322. * @param x value to transform
  2323. * @param y value to transform
  2324. * @param z value to transform
  2325. * @param w value to transform
  2326. * @param transformation the transformation matrix to apply
  2327. * @param result the vector to store the results in
  2328. */
  2329. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2330. /**
  2331. * Creates a new Vector4 from a Vector3
  2332. * @param source defines the source data
  2333. * @param w defines the 4th component (default is 0)
  2334. * @returns a new Vector4
  2335. */
  2336. static FromVector3(source: Vector3, w?: number): Vector4;
  2337. }
  2338. /**
  2339. * Interface for the size containing width and height
  2340. */
  2341. export interface ISize {
  2342. /**
  2343. * Width
  2344. */
  2345. width: number;
  2346. /**
  2347. * Heighht
  2348. */
  2349. height: number;
  2350. }
  2351. /**
  2352. * Size containing widht and height
  2353. */
  2354. export class Size implements ISize {
  2355. /**
  2356. * Width
  2357. */
  2358. width: number;
  2359. /**
  2360. * Height
  2361. */
  2362. height: number;
  2363. /**
  2364. * Creates a Size object from the given width and height (floats).
  2365. * @param width width of the new size
  2366. * @param height height of the new size
  2367. */
  2368. constructor(width: number, height: number);
  2369. /**
  2370. * Returns a string with the Size width and height
  2371. * @returns a string with the Size width and height
  2372. */
  2373. toString(): string;
  2374. /**
  2375. * "Size"
  2376. * @returns the string "Size"
  2377. */
  2378. getClassName(): string;
  2379. /**
  2380. * Returns the Size hash code.
  2381. * @returns a hash code for a unique width and height
  2382. */
  2383. getHashCode(): number;
  2384. /**
  2385. * Updates the current size from the given one.
  2386. * @param src the given size
  2387. */
  2388. copyFrom(src: Size): void;
  2389. /**
  2390. * Updates in place the current Size from the given floats.
  2391. * @param width width of the new size
  2392. * @param height height of the new size
  2393. * @returns the updated Size.
  2394. */
  2395. copyFromFloats(width: number, height: number): Size;
  2396. /**
  2397. * Updates in place the current Size from the given floats.
  2398. * @param width width to set
  2399. * @param height height to set
  2400. * @returns the updated Size.
  2401. */
  2402. set(width: number, height: number): Size;
  2403. /**
  2404. * Multiplies the width and height by numbers
  2405. * @param w factor to multiple the width by
  2406. * @param h factor to multiple the height by
  2407. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2408. */
  2409. multiplyByFloats(w: number, h: number): Size;
  2410. /**
  2411. * Clones the size
  2412. * @returns a new Size copied from the given one.
  2413. */
  2414. clone(): Size;
  2415. /**
  2416. * True if the current Size and the given one width and height are strictly equal.
  2417. * @param other the other size to compare against
  2418. * @returns True if the current Size and the given one width and height are strictly equal.
  2419. */
  2420. equals(other: Size): boolean;
  2421. /**
  2422. * The surface of the Size : width * height (float).
  2423. */
  2424. readonly surface: number;
  2425. /**
  2426. * Create a new size of zero
  2427. * @returns a new Size set to (0.0, 0.0)
  2428. */
  2429. static Zero(): Size;
  2430. /**
  2431. * Sums the width and height of two sizes
  2432. * @param otherSize size to add to this size
  2433. * @returns a new Size set as the addition result of the current Size and the given one.
  2434. */
  2435. add(otherSize: Size): Size;
  2436. /**
  2437. * Subtracts the width and height of two
  2438. * @param otherSize size to subtract to this size
  2439. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2440. */
  2441. subtract(otherSize: Size): Size;
  2442. /**
  2443. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2444. * @param start starting size to lerp between
  2445. * @param end end size to lerp between
  2446. * @param amount amount to lerp between the start and end values
  2447. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2448. */
  2449. static Lerp(start: Size, end: Size, amount: number): Size;
  2450. }
  2451. /**
  2452. * Class used to store quaternion data
  2453. * @see https://en.wikipedia.org/wiki/Quaternion
  2454. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2455. */
  2456. export class Quaternion {
  2457. /** defines the first component (0 by default) */
  2458. x: number;
  2459. /** defines the second component (0 by default) */
  2460. y: number;
  2461. /** defines the third component (0 by default) */
  2462. z: number;
  2463. /** defines the fourth component (1.0 by default) */
  2464. w: number;
  2465. /**
  2466. * Creates a new Quaternion from the given floats
  2467. * @param x defines the first component (0 by default)
  2468. * @param y defines the second component (0 by default)
  2469. * @param z defines the third component (0 by default)
  2470. * @param w defines the fourth component (1.0 by default)
  2471. */
  2472. constructor(
  2473. /** defines the first component (0 by default) */
  2474. x?: number,
  2475. /** defines the second component (0 by default) */
  2476. y?: number,
  2477. /** defines the third component (0 by default) */
  2478. z?: number,
  2479. /** defines the fourth component (1.0 by default) */
  2480. w?: number);
  2481. /**
  2482. * Gets a string representation for the current quaternion
  2483. * @returns a string with the Quaternion coordinates
  2484. */
  2485. toString(): string;
  2486. /**
  2487. * Gets the class name of the quaternion
  2488. * @returns the string "Quaternion"
  2489. */
  2490. getClassName(): string;
  2491. /**
  2492. * Gets a hash code for this quaternion
  2493. * @returns the quaternion hash code
  2494. */
  2495. getHashCode(): number;
  2496. /**
  2497. * Copy the quaternion to an array
  2498. * @returns a new array populated with 4 elements from the quaternion coordinates
  2499. */
  2500. asArray(): number[];
  2501. /**
  2502. * Check if two quaternions are equals
  2503. * @param otherQuaternion defines the second operand
  2504. * @return true if the current quaternion and the given one coordinates are strictly equals
  2505. */
  2506. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2507. /**
  2508. * Clone the current quaternion
  2509. * @returns a new quaternion copied from the current one
  2510. */
  2511. clone(): Quaternion;
  2512. /**
  2513. * Copy a quaternion to the current one
  2514. * @param other defines the other quaternion
  2515. * @returns the updated current quaternion
  2516. */
  2517. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2518. /**
  2519. * Updates the current quaternion with the given float coordinates
  2520. * @param x defines the x coordinate
  2521. * @param y defines the y coordinate
  2522. * @param z defines the z coordinate
  2523. * @param w defines the w coordinate
  2524. * @returns the updated current quaternion
  2525. */
  2526. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2527. /**
  2528. * Updates the current quaternion from the given float coordinates
  2529. * @param x defines the x coordinate
  2530. * @param y defines the y coordinate
  2531. * @param z defines the z coordinate
  2532. * @param w defines the w coordinate
  2533. * @returns the updated current quaternion
  2534. */
  2535. set(x: number, y: number, z: number, w: number): Quaternion;
  2536. /**
  2537. * Adds two quaternions
  2538. * @param other defines the second operand
  2539. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2540. */
  2541. add(other: DeepImmutable<Quaternion>): Quaternion;
  2542. /**
  2543. * Add a quaternion to the current one
  2544. * @param other defines the quaternion to add
  2545. * @returns the current quaternion
  2546. */
  2547. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2548. /**
  2549. * Subtract two quaternions
  2550. * @param other defines the second operand
  2551. * @returns a new quaternion as the subtraction result of the given one from the current one
  2552. */
  2553. subtract(other: Quaternion): Quaternion;
  2554. /**
  2555. * Multiplies the current quaternion by a scale factor
  2556. * @param value defines the scale factor
  2557. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2558. */
  2559. scale(value: number): Quaternion;
  2560. /**
  2561. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2562. * @param scale defines the scale factor
  2563. * @param result defines the Quaternion object where to store the result
  2564. * @returns the unmodified current quaternion
  2565. */
  2566. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2567. /**
  2568. * Multiplies in place the current quaternion by a scale factor
  2569. * @param value defines the scale factor
  2570. * @returns the current modified quaternion
  2571. */
  2572. scaleInPlace(value: number): Quaternion;
  2573. /**
  2574. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2575. * @param scale defines the scale factor
  2576. * @param result defines the Quaternion object where to store the result
  2577. * @returns the unmodified current quaternion
  2578. */
  2579. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2580. /**
  2581. * Multiplies two quaternions
  2582. * @param q1 defines the second operand
  2583. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2584. */
  2585. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2586. /**
  2587. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2588. * @param q1 defines the second operand
  2589. * @param result defines the target quaternion
  2590. * @returns the current quaternion
  2591. */
  2592. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2593. /**
  2594. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2595. * @param q1 defines the second operand
  2596. * @returns the currentupdated quaternion
  2597. */
  2598. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2599. /**
  2600. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2601. * @param ref defines the target quaternion
  2602. * @returns the current quaternion
  2603. */
  2604. conjugateToRef(ref: Quaternion): Quaternion;
  2605. /**
  2606. * Conjugates in place (1-q) the current quaternion
  2607. * @returns the current updated quaternion
  2608. */
  2609. conjugateInPlace(): Quaternion;
  2610. /**
  2611. * Conjugates in place (1-q) the current quaternion
  2612. * @returns a new quaternion
  2613. */
  2614. conjugate(): Quaternion;
  2615. /**
  2616. * Gets length of current quaternion
  2617. * @returns the quaternion length (float)
  2618. */
  2619. length(): number;
  2620. /**
  2621. * Normalize in place the current quaternion
  2622. * @returns the current updated quaternion
  2623. */
  2624. normalize(): Quaternion;
  2625. /**
  2626. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2627. * @param order is a reserved parameter and is ignore for now
  2628. * @returns a new Vector3 containing the Euler angles
  2629. */
  2630. toEulerAngles(order?: string): Vector3;
  2631. /**
  2632. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2633. * @param result defines the vector which will be filled with the Euler angles
  2634. * @param order is a reserved parameter and is ignore for now
  2635. * @returns the current unchanged quaternion
  2636. */
  2637. toEulerAnglesToRef(result: Vector3): Quaternion;
  2638. /**
  2639. * Updates the given rotation matrix with the current quaternion values
  2640. * @param result defines the target matrix
  2641. * @returns the current unchanged quaternion
  2642. */
  2643. toRotationMatrix(result: Matrix): Quaternion;
  2644. /**
  2645. * Updates the current quaternion from the given rotation matrix values
  2646. * @param matrix defines the source matrix
  2647. * @returns the current updated quaternion
  2648. */
  2649. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2650. /**
  2651. * Creates a new quaternion from a rotation matrix
  2652. * @param matrix defines the source matrix
  2653. * @returns a new quaternion created from the given rotation matrix values
  2654. */
  2655. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2656. /**
  2657. * Updates the given quaternion with the given rotation matrix values
  2658. * @param matrix defines the source matrix
  2659. * @param result defines the target quaternion
  2660. */
  2661. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2662. /**
  2663. * Returns the dot product (float) between the quaternions "left" and "right"
  2664. * @param left defines the left operand
  2665. * @param right defines the right operand
  2666. * @returns the dot product
  2667. */
  2668. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2669. /**
  2670. * Checks if the two quaternions are close to each other
  2671. * @param quat0 defines the first quaternion to check
  2672. * @param quat1 defines the second quaternion to check
  2673. * @returns true if the two quaternions are close to each other
  2674. */
  2675. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2676. /**
  2677. * Creates an empty quaternion
  2678. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2679. */
  2680. static Zero(): Quaternion;
  2681. /**
  2682. * Inverse a given quaternion
  2683. * @param q defines the source quaternion
  2684. * @returns a new quaternion as the inverted current quaternion
  2685. */
  2686. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2687. /**
  2688. * Inverse a given quaternion
  2689. * @param q defines the source quaternion
  2690. * @param result the quaternion the result will be stored in
  2691. * @returns the result quaternion
  2692. */
  2693. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2694. /**
  2695. * Creates an identity quaternion
  2696. * @returns the identity quaternion
  2697. */
  2698. static Identity(): Quaternion;
  2699. /**
  2700. * Gets a boolean indicating if the given quaternion is identity
  2701. * @param quaternion defines the quaternion to check
  2702. * @returns true if the quaternion is identity
  2703. */
  2704. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2705. /**
  2706. * Creates a quaternion from a rotation around an axis
  2707. * @param axis defines the axis to use
  2708. * @param angle defines the angle to use
  2709. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2710. */
  2711. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2712. /**
  2713. * Creates a rotation around an axis and stores it into the given quaternion
  2714. * @param axis defines the axis to use
  2715. * @param angle defines the angle to use
  2716. * @param result defines the target quaternion
  2717. * @returns the target quaternion
  2718. */
  2719. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2720. /**
  2721. * Creates a new quaternion from data stored into an array
  2722. * @param array defines the data source
  2723. * @param offset defines the offset in the source array where the data starts
  2724. * @returns a new quaternion
  2725. */
  2726. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2727. /**
  2728. * Create a quaternion from Euler rotation angles
  2729. * @param x Pitch
  2730. * @param y Yaw
  2731. * @param z Roll
  2732. * @returns the new Quaternion
  2733. */
  2734. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2735. /**
  2736. * Updates a quaternion from Euler rotation angles
  2737. * @param x Pitch
  2738. * @param y Yaw
  2739. * @param z Roll
  2740. * @param result the quaternion to store the result
  2741. * @returns the updated quaternion
  2742. */
  2743. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2744. /**
  2745. * Create a quaternion from Euler rotation vector
  2746. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2747. * @returns the new Quaternion
  2748. */
  2749. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2750. /**
  2751. * Updates a quaternion from Euler rotation vector
  2752. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2753. * @param result the quaternion to store the result
  2754. * @returns the updated quaternion
  2755. */
  2756. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2757. /**
  2758. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2759. * @param yaw defines the rotation around Y axis
  2760. * @param pitch defines the rotation around X axis
  2761. * @param roll defines the rotation around Z axis
  2762. * @returns the new quaternion
  2763. */
  2764. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2765. /**
  2766. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2767. * @param yaw defines the rotation around Y axis
  2768. * @param pitch defines the rotation around X axis
  2769. * @param roll defines the rotation around Z axis
  2770. * @param result defines the target quaternion
  2771. */
  2772. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2773. /**
  2774. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2775. * @param alpha defines the rotation around first axis
  2776. * @param beta defines the rotation around second axis
  2777. * @param gamma defines the rotation around third axis
  2778. * @returns the new quaternion
  2779. */
  2780. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2781. /**
  2782. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2783. * @param alpha defines the rotation around first axis
  2784. * @param beta defines the rotation around second axis
  2785. * @param gamma defines the rotation around third axis
  2786. * @param result defines the target quaternion
  2787. */
  2788. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2789. /**
  2790. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2791. * @param axis1 defines the first axis
  2792. * @param axis2 defines the second axis
  2793. * @param axis3 defines the third axis
  2794. * @returns the new quaternion
  2795. */
  2796. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2797. /**
  2798. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2799. * @param axis1 defines the first axis
  2800. * @param axis2 defines the second axis
  2801. * @param axis3 defines the third axis
  2802. * @param ref defines the target quaternion
  2803. */
  2804. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2805. /**
  2806. * Interpolates between two quaternions
  2807. * @param left defines first quaternion
  2808. * @param right defines second quaternion
  2809. * @param amount defines the gradient to use
  2810. * @returns the new interpolated quaternion
  2811. */
  2812. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2813. /**
  2814. * Interpolates between two quaternions and stores it into a target quaternion
  2815. * @param left defines first quaternion
  2816. * @param right defines second quaternion
  2817. * @param amount defines the gradient to use
  2818. * @param result defines the target quaternion
  2819. */
  2820. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2821. /**
  2822. * Interpolate between two quaternions using Hermite interpolation
  2823. * @param value1 defines first quaternion
  2824. * @param tangent1 defines the incoming tangent
  2825. * @param value2 defines second quaternion
  2826. * @param tangent2 defines the outgoing tangent
  2827. * @param amount defines the target quaternion
  2828. * @returns the new interpolated quaternion
  2829. */
  2830. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2831. }
  2832. /**
  2833. * Class used to store matrix data (4x4)
  2834. */
  2835. export class Matrix {
  2836. private static _updateFlagSeed;
  2837. private static _identityReadOnly;
  2838. private _isIdentity;
  2839. private _isIdentityDirty;
  2840. private _isIdentity3x2;
  2841. private _isIdentity3x2Dirty;
  2842. /**
  2843. * Gets the update flag of the matrix which is an unique number for the matrix.
  2844. * It will be incremented every time the matrix data change.
  2845. * You can use it to speed the comparison between two versions of the same matrix.
  2846. */
  2847. updateFlag: number;
  2848. private readonly _m;
  2849. /**
  2850. * Gets the internal data of the matrix
  2851. */
  2852. readonly m: DeepImmutable<Float32Array>;
  2853. /** @hidden */
  2854. _markAsUpdated(): void;
  2855. /** @hidden */
  2856. private _updateIdentityStatus;
  2857. /**
  2858. * Creates an empty matrix (filled with zeros)
  2859. */
  2860. constructor();
  2861. /**
  2862. * Check if the current matrix is identity
  2863. * @returns true is the matrix is the identity matrix
  2864. */
  2865. isIdentity(): boolean;
  2866. /**
  2867. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2868. * @returns true is the matrix is the identity matrix
  2869. */
  2870. isIdentityAs3x2(): boolean;
  2871. /**
  2872. * Gets the determinant of the matrix
  2873. * @returns the matrix determinant
  2874. */
  2875. determinant(): number;
  2876. /**
  2877. * Returns the matrix as a Float32Array
  2878. * @returns the matrix underlying array
  2879. */
  2880. toArray(): DeepImmutable<Float32Array>;
  2881. /**
  2882. * Returns the matrix as a Float32Array
  2883. * @returns the matrix underlying array.
  2884. */
  2885. asArray(): DeepImmutable<Float32Array>;
  2886. /**
  2887. * Inverts the current matrix in place
  2888. * @returns the current inverted matrix
  2889. */
  2890. invert(): Matrix;
  2891. /**
  2892. * Sets all the matrix elements to zero
  2893. * @returns the current matrix
  2894. */
  2895. reset(): Matrix;
  2896. /**
  2897. * Adds the current matrix with a second one
  2898. * @param other defines the matrix to add
  2899. * @returns a new matrix as the addition of the current matrix and the given one
  2900. */
  2901. add(other: DeepImmutable<Matrix>): Matrix;
  2902. /**
  2903. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2904. * @param other defines the matrix to add
  2905. * @param result defines the target matrix
  2906. * @returns the current matrix
  2907. */
  2908. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2909. /**
  2910. * Adds in place the given matrix to the current matrix
  2911. * @param other defines the second operand
  2912. * @returns the current updated matrix
  2913. */
  2914. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2915. /**
  2916. * Sets the given matrix to the current inverted Matrix
  2917. * @param other defines the target matrix
  2918. * @returns the unmodified current matrix
  2919. */
  2920. invertToRef(other: Matrix): Matrix;
  2921. /**
  2922. * add a value at the specified position in the current Matrix
  2923. * @param index the index of the value within the matrix. between 0 and 15.
  2924. * @param value the value to be added
  2925. * @returns the current updated matrix
  2926. */
  2927. addAtIndex(index: number, value: number): Matrix;
  2928. /**
  2929. * mutiply the specified position in the current Matrix by a value
  2930. * @param index the index of the value within the matrix. between 0 and 15.
  2931. * @param value the value to be added
  2932. * @returns the current updated matrix
  2933. */
  2934. multiplyAtIndex(index: number, value: number): Matrix;
  2935. /**
  2936. * Inserts the translation vector (using 3 floats) in the current matrix
  2937. * @param x defines the 1st component of the translation
  2938. * @param y defines the 2nd component of the translation
  2939. * @param z defines the 3rd component of the translation
  2940. * @returns the current updated matrix
  2941. */
  2942. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2943. /**
  2944. * Adds the translation vector (using 3 floats) in the current matrix
  2945. * @param x defines the 1st component of the translation
  2946. * @param y defines the 2nd component of the translation
  2947. * @param z defines the 3rd component of the translation
  2948. * @returns the current updated matrix
  2949. */
  2950. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2951. /**
  2952. * Inserts the translation vector in the current matrix
  2953. * @param vector3 defines the translation to insert
  2954. * @returns the current updated matrix
  2955. */
  2956. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2957. /**
  2958. * Gets the translation value of the current matrix
  2959. * @returns a new Vector3 as the extracted translation from the matrix
  2960. */
  2961. getTranslation(): Vector3;
  2962. /**
  2963. * Fill a Vector3 with the extracted translation from the matrix
  2964. * @param result defines the Vector3 where to store the translation
  2965. * @returns the current matrix
  2966. */
  2967. getTranslationToRef(result: Vector3): Matrix;
  2968. /**
  2969. * Remove rotation and scaling part from the matrix
  2970. * @returns the updated matrix
  2971. */
  2972. removeRotationAndScaling(): Matrix;
  2973. /**
  2974. * Multiply two matrices
  2975. * @param other defines the second operand
  2976. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2977. */
  2978. multiply(other: DeepImmutable<Matrix>): Matrix;
  2979. /**
  2980. * Copy the current matrix from the given one
  2981. * @param other defines the source matrix
  2982. * @returns the current updated matrix
  2983. */
  2984. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2985. /**
  2986. * Populates the given array from the starting index with the current matrix values
  2987. * @param array defines the target array
  2988. * @param offset defines the offset in the target array where to start storing values
  2989. * @returns the current matrix
  2990. */
  2991. copyToArray(array: Float32Array, offset?: number): Matrix;
  2992. /**
  2993. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2994. * @param other defines the second operand
  2995. * @param result defines the matrix where to store the multiplication
  2996. * @returns the current matrix
  2997. */
  2998. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2999. /**
  3000. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3001. * @param other defines the second operand
  3002. * @param result defines the array where to store the multiplication
  3003. * @param offset defines the offset in the target array where to start storing values
  3004. * @returns the current matrix
  3005. */
  3006. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3007. /**
  3008. * Check equality between this matrix and a second one
  3009. * @param value defines the second matrix to compare
  3010. * @returns true is the current matrix and the given one values are strictly equal
  3011. */
  3012. equals(value: DeepImmutable<Matrix>): boolean;
  3013. /**
  3014. * Clone the current matrix
  3015. * @returns a new matrix from the current matrix
  3016. */
  3017. clone(): Matrix;
  3018. /**
  3019. * Returns the name of the current matrix class
  3020. * @returns the string "Matrix"
  3021. */
  3022. getClassName(): string;
  3023. /**
  3024. * Gets the hash code of the current matrix
  3025. * @returns the hash code
  3026. */
  3027. getHashCode(): number;
  3028. /**
  3029. * Decomposes the current Matrix into a translation, rotation and scaling components
  3030. * @param scale defines the scale vector3 given as a reference to update
  3031. * @param rotation defines the rotation quaternion given as a reference to update
  3032. * @param translation defines the translation vector3 given as a reference to update
  3033. * @returns true if operation was successful
  3034. */
  3035. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3036. /**
  3037. * Gets specific row of the matrix
  3038. * @param index defines the number of the row to get
  3039. * @returns the index-th row of the current matrix as a new Vector4
  3040. */
  3041. getRow(index: number): Nullable<Vector4>;
  3042. /**
  3043. * Sets the index-th row of the current matrix to the vector4 values
  3044. * @param index defines the number of the row to set
  3045. * @param row defines the target vector4
  3046. * @returns the updated current matrix
  3047. */
  3048. setRow(index: number, row: Vector4): Matrix;
  3049. /**
  3050. * Compute the transpose of the matrix
  3051. * @returns the new transposed matrix
  3052. */
  3053. transpose(): Matrix;
  3054. /**
  3055. * Compute the transpose of the matrix and store it in a given matrix
  3056. * @param result defines the target matrix
  3057. * @returns the current matrix
  3058. */
  3059. transposeToRef(result: Matrix): Matrix;
  3060. /**
  3061. * Sets the index-th row of the current matrix with the given 4 x float values
  3062. * @param index defines the row index
  3063. * @param x defines the x component to set
  3064. * @param y defines the y component to set
  3065. * @param z defines the z component to set
  3066. * @param w defines the w component to set
  3067. * @returns the updated current matrix
  3068. */
  3069. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3070. /**
  3071. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3072. * @param scale defines the scale factor
  3073. * @returns a new matrix
  3074. */
  3075. scale(scale: number): Matrix;
  3076. /**
  3077. * Scale the current matrix values by a factor to a given result matrix
  3078. * @param scale defines the scale factor
  3079. * @param result defines the matrix to store the result
  3080. * @returns the current matrix
  3081. */
  3082. scaleToRef(scale: number, result: Matrix): Matrix;
  3083. /**
  3084. * Scale the current matrix values by a factor and add the result to a given matrix
  3085. * @param scale defines the scale factor
  3086. * @param result defines the Matrix to store the result
  3087. * @returns the current matrix
  3088. */
  3089. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3090. /**
  3091. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3092. * @param ref matrix to store the result
  3093. */
  3094. toNormalMatrix(ref: Matrix): void;
  3095. /**
  3096. * Gets only rotation part of the current matrix
  3097. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3098. */
  3099. getRotationMatrix(): Matrix;
  3100. /**
  3101. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3102. * @param result defines the target matrix to store data to
  3103. * @returns the current matrix
  3104. */
  3105. getRotationMatrixToRef(result: Matrix): Matrix;
  3106. /**
  3107. * Toggles model matrix from being right handed to left handed in place and vice versa
  3108. */
  3109. toggleModelMatrixHandInPlace(): void;
  3110. /**
  3111. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3112. */
  3113. toggleProjectionMatrixHandInPlace(): void;
  3114. /**
  3115. * Creates a matrix from an array
  3116. * @param array defines the source array
  3117. * @param offset defines an offset in the source array
  3118. * @returns a new Matrix set from the starting index of the given array
  3119. */
  3120. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3121. /**
  3122. * Copy the content of an array into a given matrix
  3123. * @param array defines the source array
  3124. * @param offset defines an offset in the source array
  3125. * @param result defines the target matrix
  3126. */
  3127. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3128. /**
  3129. * Stores an array into a matrix after having multiplied each component by a given factor
  3130. * @param array defines the source array
  3131. * @param offset defines the offset in the source array
  3132. * @param scale defines the scaling factor
  3133. * @param result defines the target matrix
  3134. */
  3135. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3136. /**
  3137. * Gets an identity matrix that must not be updated
  3138. */
  3139. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3140. /**
  3141. * Stores a list of values (16) inside a given matrix
  3142. * @param initialM11 defines 1st value of 1st row
  3143. * @param initialM12 defines 2nd value of 1st row
  3144. * @param initialM13 defines 3rd value of 1st row
  3145. * @param initialM14 defines 4th value of 1st row
  3146. * @param initialM21 defines 1st value of 2nd row
  3147. * @param initialM22 defines 2nd value of 2nd row
  3148. * @param initialM23 defines 3rd value of 2nd row
  3149. * @param initialM24 defines 4th value of 2nd row
  3150. * @param initialM31 defines 1st value of 3rd row
  3151. * @param initialM32 defines 2nd value of 3rd row
  3152. * @param initialM33 defines 3rd value of 3rd row
  3153. * @param initialM34 defines 4th value of 3rd row
  3154. * @param initialM41 defines 1st value of 4th row
  3155. * @param initialM42 defines 2nd value of 4th row
  3156. * @param initialM43 defines 3rd value of 4th row
  3157. * @param initialM44 defines 4th value of 4th row
  3158. * @param result defines the target matrix
  3159. */
  3160. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3161. /**
  3162. * Creates new matrix from a list of values (16)
  3163. * @param initialM11 defines 1st value of 1st row
  3164. * @param initialM12 defines 2nd value of 1st row
  3165. * @param initialM13 defines 3rd value of 1st row
  3166. * @param initialM14 defines 4th value of 1st row
  3167. * @param initialM21 defines 1st value of 2nd row
  3168. * @param initialM22 defines 2nd value of 2nd row
  3169. * @param initialM23 defines 3rd value of 2nd row
  3170. * @param initialM24 defines 4th value of 2nd row
  3171. * @param initialM31 defines 1st value of 3rd row
  3172. * @param initialM32 defines 2nd value of 3rd row
  3173. * @param initialM33 defines 3rd value of 3rd row
  3174. * @param initialM34 defines 4th value of 3rd row
  3175. * @param initialM41 defines 1st value of 4th row
  3176. * @param initialM42 defines 2nd value of 4th row
  3177. * @param initialM43 defines 3rd value of 4th row
  3178. * @param initialM44 defines 4th value of 4th row
  3179. * @returns the new matrix
  3180. */
  3181. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3182. /**
  3183. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3184. * @param scale defines the scale vector3
  3185. * @param rotation defines the rotation quaternion
  3186. * @param translation defines the translation vector3
  3187. * @returns a new matrix
  3188. */
  3189. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3190. /**
  3191. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3192. * @param scale defines the scale vector3
  3193. * @param rotation defines the rotation quaternion
  3194. * @param translation defines the translation vector3
  3195. * @param result defines the target matrix
  3196. */
  3197. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3198. /**
  3199. * Creates a new identity matrix
  3200. * @returns a new identity matrix
  3201. */
  3202. static Identity(): Matrix;
  3203. /**
  3204. * Creates a new identity matrix and stores the result in a given matrix
  3205. * @param result defines the target matrix
  3206. */
  3207. static IdentityToRef(result: Matrix): void;
  3208. /**
  3209. * Creates a new zero matrix
  3210. * @returns a new zero matrix
  3211. */
  3212. static Zero(): Matrix;
  3213. /**
  3214. * Creates a new rotation matrix for "angle" radians around the X axis
  3215. * @param angle defines the angle (in radians) to use
  3216. * @return the new matrix
  3217. */
  3218. static RotationX(angle: number): Matrix;
  3219. /**
  3220. * Creates a new matrix as the invert of a given matrix
  3221. * @param source defines the source matrix
  3222. * @returns the new matrix
  3223. */
  3224. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3225. /**
  3226. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3227. * @param angle defines the angle (in radians) to use
  3228. * @param result defines the target matrix
  3229. */
  3230. static RotationXToRef(angle: number, result: Matrix): void;
  3231. /**
  3232. * Creates a new rotation matrix for "angle" radians around the Y axis
  3233. * @param angle defines the angle (in radians) to use
  3234. * @return the new matrix
  3235. */
  3236. static RotationY(angle: number): Matrix;
  3237. /**
  3238. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3239. * @param angle defines the angle (in radians) to use
  3240. * @param result defines the target matrix
  3241. */
  3242. static RotationYToRef(angle: number, result: Matrix): void;
  3243. /**
  3244. * Creates a new rotation matrix for "angle" radians around the Z axis
  3245. * @param angle defines the angle (in radians) to use
  3246. * @return the new matrix
  3247. */
  3248. static RotationZ(angle: number): Matrix;
  3249. /**
  3250. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3251. * @param angle defines the angle (in radians) to use
  3252. * @param result defines the target matrix
  3253. */
  3254. static RotationZToRef(angle: number, result: Matrix): void;
  3255. /**
  3256. * Creates a new rotation matrix for "angle" radians around the given axis
  3257. * @param axis defines the axis to use
  3258. * @param angle defines the angle (in radians) to use
  3259. * @return the new matrix
  3260. */
  3261. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3262. /**
  3263. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3264. * @param axis defines the axis to use
  3265. * @param angle defines the angle (in radians) to use
  3266. * @param result defines the target matrix
  3267. */
  3268. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3269. /**
  3270. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3271. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3272. * @param from defines the vector to align
  3273. * @param to defines the vector to align to
  3274. * @param result defines the target matrix
  3275. */
  3276. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3277. /**
  3278. * Creates a rotation matrix
  3279. * @param yaw defines the yaw angle in radians (Y axis)
  3280. * @param pitch defines the pitch angle in radians (X axis)
  3281. * @param roll defines the roll angle in radians (X axis)
  3282. * @returns the new rotation matrix
  3283. */
  3284. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3285. /**
  3286. * Creates a rotation matrix and stores it in a given matrix
  3287. * @param yaw defines the yaw angle in radians (Y axis)
  3288. * @param pitch defines the pitch angle in radians (X axis)
  3289. * @param roll defines the roll angle in radians (X axis)
  3290. * @param result defines the target matrix
  3291. */
  3292. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3293. /**
  3294. * Creates a scaling matrix
  3295. * @param x defines the scale factor on X axis
  3296. * @param y defines the scale factor on Y axis
  3297. * @param z defines the scale factor on Z axis
  3298. * @returns the new matrix
  3299. */
  3300. static Scaling(x: number, y: number, z: number): Matrix;
  3301. /**
  3302. * Creates a scaling matrix and stores it in a given matrix
  3303. * @param x defines the scale factor on X axis
  3304. * @param y defines the scale factor on Y axis
  3305. * @param z defines the scale factor on Z axis
  3306. * @param result defines the target matrix
  3307. */
  3308. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3309. /**
  3310. * Creates a translation matrix
  3311. * @param x defines the translation on X axis
  3312. * @param y defines the translation on Y axis
  3313. * @param z defines the translationon Z axis
  3314. * @returns the new matrix
  3315. */
  3316. static Translation(x: number, y: number, z: number): Matrix;
  3317. /**
  3318. * Creates a translation matrix and stores it in a given matrix
  3319. * @param x defines the translation on X axis
  3320. * @param y defines the translation on Y axis
  3321. * @param z defines the translationon Z axis
  3322. * @param result defines the target matrix
  3323. */
  3324. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3325. /**
  3326. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3327. * @param startValue defines the start value
  3328. * @param endValue defines the end value
  3329. * @param gradient defines the gradient factor
  3330. * @returns the new matrix
  3331. */
  3332. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3333. /**
  3334. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3335. * @param startValue defines the start value
  3336. * @param endValue defines the end value
  3337. * @param gradient defines the gradient factor
  3338. * @param result defines the Matrix object where to store data
  3339. */
  3340. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3341. /**
  3342. * Builds a new matrix whose values are computed by:
  3343. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3344. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3345. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3346. * @param startValue defines the first matrix
  3347. * @param endValue defines the second matrix
  3348. * @param gradient defines the gradient between the two matrices
  3349. * @returns the new matrix
  3350. */
  3351. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3352. /**
  3353. * Update a matrix to values which are computed by:
  3354. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3355. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3356. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3357. * @param startValue defines the first matrix
  3358. * @param endValue defines the second matrix
  3359. * @param gradient defines the gradient between the two matrices
  3360. * @param result defines the target matrix
  3361. */
  3362. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3363. /**
  3364. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3365. * This function works in left handed mode
  3366. * @param eye defines the final position of the entity
  3367. * @param target defines where the entity should look at
  3368. * @param up defines the up vector for the entity
  3369. * @returns the new matrix
  3370. */
  3371. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3372. /**
  3373. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3374. * This function works in left handed mode
  3375. * @param eye defines the final position of the entity
  3376. * @param target defines where the entity should look at
  3377. * @param up defines the up vector for the entity
  3378. * @param result defines the target matrix
  3379. */
  3380. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3381. /**
  3382. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3383. * This function works in right handed mode
  3384. * @param eye defines the final position of the entity
  3385. * @param target defines where the entity should look at
  3386. * @param up defines the up vector for the entity
  3387. * @returns the new matrix
  3388. */
  3389. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3390. /**
  3391. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3392. * This function works in right handed mode
  3393. * @param eye defines the final position of the entity
  3394. * @param target defines where the entity should look at
  3395. * @param up defines the up vector for the entity
  3396. * @param result defines the target matrix
  3397. */
  3398. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3399. /**
  3400. * Create a left-handed orthographic projection matrix
  3401. * @param width defines the viewport width
  3402. * @param height defines the viewport height
  3403. * @param znear defines the near clip plane
  3404. * @param zfar defines the far clip plane
  3405. * @returns a new matrix as a left-handed orthographic projection matrix
  3406. */
  3407. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3408. /**
  3409. * Store a left-handed orthographic projection to a given matrix
  3410. * @param width defines the viewport width
  3411. * @param height defines the viewport height
  3412. * @param znear defines the near clip plane
  3413. * @param zfar defines the far clip plane
  3414. * @param result defines the target matrix
  3415. */
  3416. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3417. /**
  3418. * Create a left-handed orthographic projection matrix
  3419. * @param left defines the viewport left coordinate
  3420. * @param right defines the viewport right coordinate
  3421. * @param bottom defines the viewport bottom coordinate
  3422. * @param top defines the viewport top coordinate
  3423. * @param znear defines the near clip plane
  3424. * @param zfar defines the far clip plane
  3425. * @returns a new matrix as a left-handed orthographic projection matrix
  3426. */
  3427. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3428. /**
  3429. * Stores a left-handed orthographic projection into a given matrix
  3430. * @param left defines the viewport left coordinate
  3431. * @param right defines the viewport right coordinate
  3432. * @param bottom defines the viewport bottom coordinate
  3433. * @param top defines the viewport top coordinate
  3434. * @param znear defines the near clip plane
  3435. * @param zfar defines the far clip plane
  3436. * @param result defines the target matrix
  3437. */
  3438. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3439. /**
  3440. * Creates a right-handed orthographic projection matrix
  3441. * @param left defines the viewport left coordinate
  3442. * @param right defines the viewport right coordinate
  3443. * @param bottom defines the viewport bottom coordinate
  3444. * @param top defines the viewport top coordinate
  3445. * @param znear defines the near clip plane
  3446. * @param zfar defines the far clip plane
  3447. * @returns a new matrix as a right-handed orthographic projection matrix
  3448. */
  3449. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3450. /**
  3451. * Stores a right-handed orthographic projection into a given matrix
  3452. * @param left defines the viewport left coordinate
  3453. * @param right defines the viewport right coordinate
  3454. * @param bottom defines the viewport bottom coordinate
  3455. * @param top defines the viewport top coordinate
  3456. * @param znear defines the near clip plane
  3457. * @param zfar defines the far clip plane
  3458. * @param result defines the target matrix
  3459. */
  3460. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3461. /**
  3462. * Creates a left-handed perspective projection matrix
  3463. * @param width defines the viewport width
  3464. * @param height defines the viewport height
  3465. * @param znear defines the near clip plane
  3466. * @param zfar defines the far clip plane
  3467. * @returns a new matrix as a left-handed perspective projection matrix
  3468. */
  3469. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3470. /**
  3471. * Creates a left-handed perspective projection matrix
  3472. * @param fov defines the horizontal field of view
  3473. * @param aspect defines the aspect ratio
  3474. * @param znear defines the near clip plane
  3475. * @param zfar defines the far clip plane
  3476. * @returns a new matrix as a left-handed perspective projection matrix
  3477. */
  3478. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3479. /**
  3480. * Stores a left-handed perspective projection into a given matrix
  3481. * @param fov defines the horizontal field of view
  3482. * @param aspect defines the aspect ratio
  3483. * @param znear defines the near clip plane
  3484. * @param zfar defines the far clip plane
  3485. * @param result defines the target matrix
  3486. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3487. */
  3488. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3489. /**
  3490. * Creates a right-handed perspective projection matrix
  3491. * @param fov defines the horizontal field of view
  3492. * @param aspect defines the aspect ratio
  3493. * @param znear defines the near clip plane
  3494. * @param zfar defines the far clip plane
  3495. * @returns a new matrix as a right-handed perspective projection matrix
  3496. */
  3497. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3498. /**
  3499. * Stores a right-handed perspective projection into a given matrix
  3500. * @param fov defines the horizontal field of view
  3501. * @param aspect defines the aspect ratio
  3502. * @param znear defines the near clip plane
  3503. * @param zfar defines the far clip plane
  3504. * @param result defines the target matrix
  3505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3506. */
  3507. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3508. /**
  3509. * Stores a perspective projection for WebVR info a given matrix
  3510. * @param fov defines the field of view
  3511. * @param znear defines the near clip plane
  3512. * @param zfar defines the far clip plane
  3513. * @param result defines the target matrix
  3514. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3515. */
  3516. static PerspectiveFovWebVRToRef(fov: {
  3517. upDegrees: number;
  3518. downDegrees: number;
  3519. leftDegrees: number;
  3520. rightDegrees: number;
  3521. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3522. /**
  3523. * Computes a complete transformation matrix
  3524. * @param viewport defines the viewport to use
  3525. * @param world defines the world matrix
  3526. * @param view defines the view matrix
  3527. * @param projection defines the projection matrix
  3528. * @param zmin defines the near clip plane
  3529. * @param zmax defines the far clip plane
  3530. * @returns the transformation matrix
  3531. */
  3532. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3533. /**
  3534. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3535. * @param matrix defines the matrix to use
  3536. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3537. */
  3538. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3539. /**
  3540. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3541. * @param matrix defines the matrix to use
  3542. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3543. */
  3544. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3545. /**
  3546. * Compute the transpose of a given matrix
  3547. * @param matrix defines the matrix to transpose
  3548. * @returns the new matrix
  3549. */
  3550. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3551. /**
  3552. * Compute the transpose of a matrix and store it in a target matrix
  3553. * @param matrix defines the matrix to transpose
  3554. * @param result defines the target matrix
  3555. */
  3556. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3557. /**
  3558. * Computes a reflection matrix from a plane
  3559. * @param plane defines the reflection plane
  3560. * @returns a new matrix
  3561. */
  3562. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3563. /**
  3564. * Computes a reflection matrix from a plane
  3565. * @param plane defines the reflection plane
  3566. * @param result defines the target matrix
  3567. */
  3568. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3569. /**
  3570. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3571. * @param xaxis defines the value of the 1st axis
  3572. * @param yaxis defines the value of the 2nd axis
  3573. * @param zaxis defines the value of the 3rd axis
  3574. * @param result defines the target matrix
  3575. */
  3576. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3577. /**
  3578. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3579. * @param quat defines the quaternion to use
  3580. * @param result defines the target matrix
  3581. */
  3582. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3583. }
  3584. /**
  3585. * Represens a plane by the equation ax + by + cz + d = 0
  3586. */
  3587. export class Plane {
  3588. /**
  3589. * Normal of the plane (a,b,c)
  3590. */
  3591. normal: Vector3;
  3592. /**
  3593. * d component of the plane
  3594. */
  3595. d: number;
  3596. /**
  3597. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3598. * @param a a component of the plane
  3599. * @param b b component of the plane
  3600. * @param c c component of the plane
  3601. * @param d d component of the plane
  3602. */
  3603. constructor(a: number, b: number, c: number, d: number);
  3604. /**
  3605. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3606. */
  3607. asArray(): number[];
  3608. /**
  3609. * @returns a new plane copied from the current Plane.
  3610. */
  3611. clone(): Plane;
  3612. /**
  3613. * @returns the string "Plane".
  3614. */
  3615. getClassName(): string;
  3616. /**
  3617. * @returns the Plane hash code.
  3618. */
  3619. getHashCode(): number;
  3620. /**
  3621. * Normalize the current Plane in place.
  3622. * @returns the updated Plane.
  3623. */
  3624. normalize(): Plane;
  3625. /**
  3626. * Applies a transformation the plane and returns the result
  3627. * @param transformation the transformation matrix to be applied to the plane
  3628. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3629. */
  3630. transform(transformation: DeepImmutable<Matrix>): Plane;
  3631. /**
  3632. * Calcualtte the dot product between the point and the plane normal
  3633. * @param point point to calculate the dot product with
  3634. * @returns the dot product (float) of the point coordinates and the plane normal.
  3635. */
  3636. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3637. /**
  3638. * Updates the current Plane from the plane defined by the three given points.
  3639. * @param point1 one of the points used to contruct the plane
  3640. * @param point2 one of the points used to contruct the plane
  3641. * @param point3 one of the points used to contruct the plane
  3642. * @returns the updated Plane.
  3643. */
  3644. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3645. /**
  3646. * Checks if the plane is facing a given direction
  3647. * @param direction the direction to check if the plane is facing
  3648. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3649. * @returns True is the vector "direction" is the same side than the plane normal.
  3650. */
  3651. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3652. /**
  3653. * Calculates the distance to a point
  3654. * @param point point to calculate distance to
  3655. * @returns the signed distance (float) from the given point to the Plane.
  3656. */
  3657. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3658. /**
  3659. * Creates a plane from an array
  3660. * @param array the array to create a plane from
  3661. * @returns a new Plane from the given array.
  3662. */
  3663. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3664. /**
  3665. * Creates a plane from three points
  3666. * @param point1 point used to create the plane
  3667. * @param point2 point used to create the plane
  3668. * @param point3 point used to create the plane
  3669. * @returns a new Plane defined by the three given points.
  3670. */
  3671. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3672. /**
  3673. * Creates a plane from an origin point and a normal
  3674. * @param origin origin of the plane to be constructed
  3675. * @param normal normal of the plane to be constructed
  3676. * @returns a new Plane the normal vector to this plane at the given origin point.
  3677. * Note : the vector "normal" is updated because normalized.
  3678. */
  3679. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3680. /**
  3681. * Calculates the distance from a plane and a point
  3682. * @param origin origin of the plane to be constructed
  3683. * @param normal normal of the plane to be constructed
  3684. * @param point point to calculate distance to
  3685. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3686. */
  3687. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3688. }
  3689. /**
  3690. * Class used to represent a viewport on screen
  3691. */
  3692. export class Viewport {
  3693. /** viewport left coordinate */
  3694. x: number;
  3695. /** viewport top coordinate */
  3696. y: number;
  3697. /**viewport width */
  3698. width: number;
  3699. /** viewport height */
  3700. height: number;
  3701. /**
  3702. * Creates a Viewport object located at (x, y) and sized (width, height)
  3703. * @param x defines viewport left coordinate
  3704. * @param y defines viewport top coordinate
  3705. * @param width defines the viewport width
  3706. * @param height defines the viewport height
  3707. */
  3708. constructor(
  3709. /** viewport left coordinate */
  3710. x: number,
  3711. /** viewport top coordinate */
  3712. y: number,
  3713. /**viewport width */
  3714. width: number,
  3715. /** viewport height */
  3716. height: number);
  3717. /**
  3718. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3719. * @param renderWidth defines the rendering width
  3720. * @param renderHeight defines the rendering height
  3721. * @returns a new Viewport
  3722. */
  3723. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3724. /**
  3725. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3726. * @param renderWidth defines the rendering width
  3727. * @param renderHeight defines the rendering height
  3728. * @param ref defines the target viewport
  3729. * @returns the current viewport
  3730. */
  3731. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3732. /**
  3733. * Returns a new Viewport copied from the current one
  3734. * @returns a new Viewport
  3735. */
  3736. clone(): Viewport;
  3737. }
  3738. /**
  3739. * Reprasents a camera frustum
  3740. */
  3741. export class Frustum {
  3742. /**
  3743. * Gets the planes representing the frustum
  3744. * @param transform matrix to be applied to the returned planes
  3745. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3746. */
  3747. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3748. /**
  3749. * Gets the near frustum plane transformed by the transform matrix
  3750. * @param transform transformation matrix to be applied to the resulting frustum plane
  3751. * @param frustumPlane the resuling frustum plane
  3752. */
  3753. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3754. /**
  3755. * Gets the far frustum plane transformed by the transform matrix
  3756. * @param transform transformation matrix to be applied to the resulting frustum plane
  3757. * @param frustumPlane the resuling frustum plane
  3758. */
  3759. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3760. /**
  3761. * Gets the left frustum plane transformed by the transform matrix
  3762. * @param transform transformation matrix to be applied to the resulting frustum plane
  3763. * @param frustumPlane the resuling frustum plane
  3764. */
  3765. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3766. /**
  3767. * Gets the right frustum plane transformed by the transform matrix
  3768. * @param transform transformation matrix to be applied to the resulting frustum plane
  3769. * @param frustumPlane the resuling frustum plane
  3770. */
  3771. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3772. /**
  3773. * Gets the top frustum plane transformed by the transform matrix
  3774. * @param transform transformation matrix to be applied to the resulting frustum plane
  3775. * @param frustumPlane the resuling frustum plane
  3776. */
  3777. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3778. /**
  3779. * Gets the bottom frustum plane transformed by the transform matrix
  3780. * @param transform transformation matrix to be applied to the resulting frustum plane
  3781. * @param frustumPlane the resuling frustum plane
  3782. */
  3783. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3784. /**
  3785. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3786. * @param transform transformation matrix to be applied to the resulting frustum planes
  3787. * @param frustumPlanes the resuling frustum planes
  3788. */
  3789. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3790. }
  3791. /** Defines supported spaces */
  3792. export enum Space {
  3793. /** Local (object) space */
  3794. LOCAL = 0,
  3795. /** World space */
  3796. WORLD = 1,
  3797. /** Bone space */
  3798. BONE = 2
  3799. }
  3800. /** Defines the 3 main axes */
  3801. export class Axis {
  3802. /** X axis */
  3803. static X: Vector3;
  3804. /** Y axis */
  3805. static Y: Vector3;
  3806. /** Z axis */
  3807. static Z: Vector3;
  3808. }
  3809. /** Class used to represent a Bezier curve */
  3810. export class BezierCurve {
  3811. /**
  3812. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3813. * @param t defines the time
  3814. * @param x1 defines the left coordinate on X axis
  3815. * @param y1 defines the left coordinate on Y axis
  3816. * @param x2 defines the right coordinate on X axis
  3817. * @param y2 defines the right coordinate on Y axis
  3818. * @returns the interpolated value
  3819. */
  3820. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3821. }
  3822. /**
  3823. * Defines potential orientation for back face culling
  3824. */
  3825. export enum Orientation {
  3826. /**
  3827. * Clockwise
  3828. */
  3829. CW = 0,
  3830. /** Counter clockwise */
  3831. CCW = 1
  3832. }
  3833. /**
  3834. * Defines angle representation
  3835. */
  3836. export class Angle {
  3837. private _radians;
  3838. /**
  3839. * Creates an Angle object of "radians" radians (float).
  3840. * @param radians the angle in radians
  3841. */
  3842. constructor(radians: number);
  3843. /**
  3844. * Get value in degrees
  3845. * @returns the Angle value in degrees (float)
  3846. */
  3847. degrees(): number;
  3848. /**
  3849. * Get value in radians
  3850. * @returns the Angle value in radians (float)
  3851. */
  3852. radians(): number;
  3853. /**
  3854. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3855. * @param a defines first vector
  3856. * @param b defines second vector
  3857. * @returns a new Angle
  3858. */
  3859. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3860. /**
  3861. * Gets a new Angle object from the given float in radians
  3862. * @param radians defines the angle value in radians
  3863. * @returns a new Angle
  3864. */
  3865. static FromRadians(radians: number): Angle;
  3866. /**
  3867. * Gets a new Angle object from the given float in degrees
  3868. * @param degrees defines the angle value in degrees
  3869. * @returns a new Angle
  3870. */
  3871. static FromDegrees(degrees: number): Angle;
  3872. }
  3873. /**
  3874. * This represents an arc in a 2d space.
  3875. */
  3876. export class Arc2 {
  3877. /** Defines the start point of the arc */
  3878. startPoint: Vector2;
  3879. /** Defines the mid point of the arc */
  3880. midPoint: Vector2;
  3881. /** Defines the end point of the arc */
  3882. endPoint: Vector2;
  3883. /**
  3884. * Defines the center point of the arc.
  3885. */
  3886. centerPoint: Vector2;
  3887. /**
  3888. * Defines the radius of the arc.
  3889. */
  3890. radius: number;
  3891. /**
  3892. * Defines the angle of the arc (from mid point to end point).
  3893. */
  3894. angle: Angle;
  3895. /**
  3896. * Defines the start angle of the arc (from start point to middle point).
  3897. */
  3898. startAngle: Angle;
  3899. /**
  3900. * Defines the orientation of the arc (clock wise/counter clock wise).
  3901. */
  3902. orientation: Orientation;
  3903. /**
  3904. * Creates an Arc object from the three given points : start, middle and end.
  3905. * @param startPoint Defines the start point of the arc
  3906. * @param midPoint Defines the midlle point of the arc
  3907. * @param endPoint Defines the end point of the arc
  3908. */
  3909. constructor(
  3910. /** Defines the start point of the arc */
  3911. startPoint: Vector2,
  3912. /** Defines the mid point of the arc */
  3913. midPoint: Vector2,
  3914. /** Defines the end point of the arc */
  3915. endPoint: Vector2);
  3916. }
  3917. /**
  3918. * Represents a 2D path made up of multiple 2D points
  3919. */
  3920. export class Path2 {
  3921. private _points;
  3922. private _length;
  3923. /**
  3924. * If the path start and end point are the same
  3925. */
  3926. closed: boolean;
  3927. /**
  3928. * Creates a Path2 object from the starting 2D coordinates x and y.
  3929. * @param x the starting points x value
  3930. * @param y the starting points y value
  3931. */
  3932. constructor(x: number, y: number);
  3933. /**
  3934. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3935. * @param x the added points x value
  3936. * @param y the added points y value
  3937. * @returns the updated Path2.
  3938. */
  3939. addLineTo(x: number, y: number): Path2;
  3940. /**
  3941. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3942. * @param midX middle point x value
  3943. * @param midY middle point y value
  3944. * @param endX end point x value
  3945. * @param endY end point y value
  3946. * @param numberOfSegments (default: 36)
  3947. * @returns the updated Path2.
  3948. */
  3949. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3950. /**
  3951. * Closes the Path2.
  3952. * @returns the Path2.
  3953. */
  3954. close(): Path2;
  3955. /**
  3956. * Gets the sum of the distance between each sequential point in the path
  3957. * @returns the Path2 total length (float).
  3958. */
  3959. length(): number;
  3960. /**
  3961. * Gets the points which construct the path
  3962. * @returns the Path2 internal array of points.
  3963. */
  3964. getPoints(): Vector2[];
  3965. /**
  3966. * Retreives the point at the distance aways from the starting point
  3967. * @param normalizedLengthPosition the length along the path to retreive the point from
  3968. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3969. */
  3970. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3971. /**
  3972. * Creates a new path starting from an x and y position
  3973. * @param x starting x value
  3974. * @param y starting y value
  3975. * @returns a new Path2 starting at the coordinates (x, y).
  3976. */
  3977. static StartingAt(x: number, y: number): Path2;
  3978. }
  3979. /**
  3980. * Represents a 3D path made up of multiple 3D points
  3981. */
  3982. export class Path3D {
  3983. /**
  3984. * an array of Vector3, the curve axis of the Path3D
  3985. */
  3986. path: Vector3[];
  3987. private _curve;
  3988. private _distances;
  3989. private _tangents;
  3990. private _normals;
  3991. private _binormals;
  3992. private _raw;
  3993. /**
  3994. * new Path3D(path, normal, raw)
  3995. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3996. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3997. * @param path an array of Vector3, the curve axis of the Path3D
  3998. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3999. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4000. */
  4001. constructor(
  4002. /**
  4003. * an array of Vector3, the curve axis of the Path3D
  4004. */
  4005. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4006. /**
  4007. * Returns the Path3D array of successive Vector3 designing its curve.
  4008. * @returns the Path3D array of successive Vector3 designing its curve.
  4009. */
  4010. getCurve(): Vector3[];
  4011. /**
  4012. * Returns an array populated with tangent vectors on each Path3D curve point.
  4013. * @returns an array populated with tangent vectors on each Path3D curve point.
  4014. */
  4015. getTangents(): Vector3[];
  4016. /**
  4017. * Returns an array populated with normal vectors on each Path3D curve point.
  4018. * @returns an array populated with normal vectors on each Path3D curve point.
  4019. */
  4020. getNormals(): Vector3[];
  4021. /**
  4022. * Returns an array populated with binormal vectors on each Path3D curve point.
  4023. * @returns an array populated with binormal vectors on each Path3D curve point.
  4024. */
  4025. getBinormals(): Vector3[];
  4026. /**
  4027. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4028. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4029. */
  4030. getDistances(): number[];
  4031. /**
  4032. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4033. * @param path path which all values are copied into the curves points
  4034. * @param firstNormal which should be projected onto the curve
  4035. * @returns the same object updated.
  4036. */
  4037. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4038. private _compute;
  4039. private _getFirstNonNullVector;
  4040. private _getLastNonNullVector;
  4041. private _normalVector;
  4042. }
  4043. /**
  4044. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4045. * A Curve3 is designed from a series of successive Vector3.
  4046. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4047. */
  4048. export class Curve3 {
  4049. private _points;
  4050. private _length;
  4051. /**
  4052. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4053. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4054. * @param v1 (Vector3) the control point
  4055. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4056. * @param nbPoints (integer) the wanted number of points in the curve
  4057. * @returns the created Curve3
  4058. */
  4059. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4060. /**
  4061. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4062. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4063. * @param v1 (Vector3) the first control point
  4064. * @param v2 (Vector3) the second control point
  4065. * @param v3 (Vector3) the end point of the Cubic Bezier
  4066. * @param nbPoints (integer) the wanted number of points in the curve
  4067. * @returns the created Curve3
  4068. */
  4069. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4070. /**
  4071. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4072. * @param p1 (Vector3) the origin point of the Hermite Spline
  4073. * @param t1 (Vector3) the tangent vector at the origin point
  4074. * @param p2 (Vector3) the end point of the Hermite Spline
  4075. * @param t2 (Vector3) the tangent vector at the end point
  4076. * @param nbPoints (integer) the wanted number of points in the curve
  4077. * @returns the created Curve3
  4078. */
  4079. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4080. /**
  4081. * Returns a Curve3 object along a CatmullRom Spline curve :
  4082. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4083. * @param nbPoints (integer) the wanted number of points between each curve control points
  4084. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4085. * @returns the created Curve3
  4086. */
  4087. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4088. /**
  4089. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4090. * A Curve3 is designed from a series of successive Vector3.
  4091. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4092. * @param points points which make up the curve
  4093. */
  4094. constructor(points: Vector3[]);
  4095. /**
  4096. * @returns the Curve3 stored array of successive Vector3
  4097. */
  4098. getPoints(): Vector3[];
  4099. /**
  4100. * @returns the computed length (float) of the curve.
  4101. */
  4102. length(): number;
  4103. /**
  4104. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4105. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4106. * curveA and curveB keep unchanged.
  4107. * @param curve the curve to continue from this curve
  4108. * @returns the newly constructed curve
  4109. */
  4110. continue(curve: DeepImmutable<Curve3>): Curve3;
  4111. private _computeLength;
  4112. }
  4113. /**
  4114. * Contains position and normal vectors for a vertex
  4115. */
  4116. export class PositionNormalVertex {
  4117. /** the position of the vertex (defaut: 0,0,0) */
  4118. position: Vector3;
  4119. /** the normal of the vertex (defaut: 0,1,0) */
  4120. normal: Vector3;
  4121. /**
  4122. * Creates a PositionNormalVertex
  4123. * @param position the position of the vertex (defaut: 0,0,0)
  4124. * @param normal the normal of the vertex (defaut: 0,1,0)
  4125. */
  4126. constructor(
  4127. /** the position of the vertex (defaut: 0,0,0) */
  4128. position?: Vector3,
  4129. /** the normal of the vertex (defaut: 0,1,0) */
  4130. normal?: Vector3);
  4131. /**
  4132. * Clones the PositionNormalVertex
  4133. * @returns the cloned PositionNormalVertex
  4134. */
  4135. clone(): PositionNormalVertex;
  4136. }
  4137. /**
  4138. * Contains position, normal and uv vectors for a vertex
  4139. */
  4140. export class PositionNormalTextureVertex {
  4141. /** the position of the vertex (defaut: 0,0,0) */
  4142. position: Vector3;
  4143. /** the normal of the vertex (defaut: 0,1,0) */
  4144. normal: Vector3;
  4145. /** the uv of the vertex (default: 0,0) */
  4146. uv: Vector2;
  4147. /**
  4148. * Creates a PositionNormalTextureVertex
  4149. * @param position the position of the vertex (defaut: 0,0,0)
  4150. * @param normal the normal of the vertex (defaut: 0,1,0)
  4151. * @param uv the uv of the vertex (default: 0,0)
  4152. */
  4153. constructor(
  4154. /** the position of the vertex (defaut: 0,0,0) */
  4155. position?: Vector3,
  4156. /** the normal of the vertex (defaut: 0,1,0) */
  4157. normal?: Vector3,
  4158. /** the uv of the vertex (default: 0,0) */
  4159. uv?: Vector2);
  4160. /**
  4161. * Clones the PositionNormalTextureVertex
  4162. * @returns the cloned PositionNormalTextureVertex
  4163. */
  4164. clone(): PositionNormalTextureVertex;
  4165. }
  4166. /**
  4167. * @hidden
  4168. */
  4169. export class Tmp {
  4170. static Color3: Color3[];
  4171. static Color4: Color4[];
  4172. static Vector2: Vector2[];
  4173. static Vector3: Vector3[];
  4174. static Vector4: Vector4[];
  4175. static Quaternion: Quaternion[];
  4176. static Matrix: Matrix[];
  4177. }
  4178. }
  4179. declare module "babylonjs/Offline/IOfflineProvider" {
  4180. /**
  4181. * Class used to enable access to offline support
  4182. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4183. */
  4184. export interface IOfflineProvider {
  4185. /**
  4186. * Gets a boolean indicating if scene must be saved in the database
  4187. */
  4188. enableSceneOffline: boolean;
  4189. /**
  4190. * Gets a boolean indicating if textures must be saved in the database
  4191. */
  4192. enableTexturesOffline: boolean;
  4193. /**
  4194. * Open the offline support and make it available
  4195. * @param successCallback defines the callback to call on success
  4196. * @param errorCallback defines the callback to call on error
  4197. */
  4198. open(successCallback: () => void, errorCallback: () => void): void;
  4199. /**
  4200. * Loads an image from the offline support
  4201. * @param url defines the url to load from
  4202. * @param image defines the target DOM image
  4203. */
  4204. loadImage(url: string, image: HTMLImageElement): void;
  4205. /**
  4206. * Loads a file from offline support
  4207. * @param url defines the URL to load from
  4208. * @param sceneLoaded defines a callback to call on success
  4209. * @param progressCallBack defines a callback to call when progress changed
  4210. * @param errorCallback defines a callback to call on error
  4211. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4212. */
  4213. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4214. }
  4215. }
  4216. declare module "babylonjs/Misc/observable" {
  4217. import { Nullable } from "babylonjs/types";
  4218. /**
  4219. * A class serves as a medium between the observable and its observers
  4220. */
  4221. export class EventState {
  4222. /**
  4223. * Create a new EventState
  4224. * @param mask defines the mask associated with this state
  4225. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4226. * @param target defines the original target of the state
  4227. * @param currentTarget defines the current target of the state
  4228. */
  4229. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4230. /**
  4231. * Initialize the current event state
  4232. * @param mask defines the mask associated with this state
  4233. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4234. * @param target defines the original target of the state
  4235. * @param currentTarget defines the current target of the state
  4236. * @returns the current event state
  4237. */
  4238. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4239. /**
  4240. * An Observer can set this property to true to prevent subsequent observers of being notified
  4241. */
  4242. skipNextObservers: boolean;
  4243. /**
  4244. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4245. */
  4246. mask: number;
  4247. /**
  4248. * The object that originally notified the event
  4249. */
  4250. target?: any;
  4251. /**
  4252. * The current object in the bubbling phase
  4253. */
  4254. currentTarget?: any;
  4255. /**
  4256. * This will be populated with the return value of the last function that was executed.
  4257. * If it is the first function in the callback chain it will be the event data.
  4258. */
  4259. lastReturnValue?: any;
  4260. }
  4261. /**
  4262. * Represent an Observer registered to a given Observable object.
  4263. */
  4264. export class Observer<T> {
  4265. /**
  4266. * Defines the callback to call when the observer is notified
  4267. */
  4268. callback: (eventData: T, eventState: EventState) => void;
  4269. /**
  4270. * Defines the mask of the observer (used to filter notifications)
  4271. */
  4272. mask: number;
  4273. /**
  4274. * Defines the current scope used to restore the JS context
  4275. */
  4276. scope: any;
  4277. /** @hidden */
  4278. _willBeUnregistered: boolean;
  4279. /**
  4280. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4281. */
  4282. unregisterOnNextCall: boolean;
  4283. /**
  4284. * Creates a new observer
  4285. * @param callback defines the callback to call when the observer is notified
  4286. * @param mask defines the mask of the observer (used to filter notifications)
  4287. * @param scope defines the current scope used to restore the JS context
  4288. */
  4289. constructor(
  4290. /**
  4291. * Defines the callback to call when the observer is notified
  4292. */
  4293. callback: (eventData: T, eventState: EventState) => void,
  4294. /**
  4295. * Defines the mask of the observer (used to filter notifications)
  4296. */
  4297. mask: number,
  4298. /**
  4299. * Defines the current scope used to restore the JS context
  4300. */
  4301. scope?: any);
  4302. }
  4303. /**
  4304. * Represent a list of observers registered to multiple Observables object.
  4305. */
  4306. export class MultiObserver<T> {
  4307. private _observers;
  4308. private _observables;
  4309. /**
  4310. * Release associated resources
  4311. */
  4312. dispose(): void;
  4313. /**
  4314. * Raise a callback when one of the observable will notify
  4315. * @param observables defines a list of observables to watch
  4316. * @param callback defines the callback to call on notification
  4317. * @param mask defines the mask used to filter notifications
  4318. * @param scope defines the current scope used to restore the JS context
  4319. * @returns the new MultiObserver
  4320. */
  4321. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4322. }
  4323. /**
  4324. * The Observable class is a simple implementation of the Observable pattern.
  4325. *
  4326. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4327. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4328. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4329. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4330. */
  4331. export class Observable<T> {
  4332. private _observers;
  4333. private _eventState;
  4334. private _onObserverAdded;
  4335. /**
  4336. * Creates a new observable
  4337. * @param onObserverAdded defines a callback to call when a new observer is added
  4338. */
  4339. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4340. /**
  4341. * Create a new Observer with the specified callback
  4342. * @param callback the callback that will be executed for that Observer
  4343. * @param mask the mask used to filter observers
  4344. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4345. * @param scope optional scope for the callback to be called from
  4346. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4347. * @returns the new observer created for the callback
  4348. */
  4349. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4350. /**
  4351. * Create a new Observer with the specified callback and unregisters after the next notification
  4352. * @param callback the callback that will be executed for that Observer
  4353. * @returns the new observer created for the callback
  4354. */
  4355. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4356. /**
  4357. * Remove an Observer from the Observable object
  4358. * @param observer the instance of the Observer to remove
  4359. * @returns false if it doesn't belong to this Observable
  4360. */
  4361. remove(observer: Nullable<Observer<T>>): boolean;
  4362. /**
  4363. * Remove a callback from the Observable object
  4364. * @param callback the callback to remove
  4365. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4366. * @returns false if it doesn't belong to this Observable
  4367. */
  4368. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4369. private _deferUnregister;
  4370. private _remove;
  4371. /**
  4372. * Moves the observable to the top of the observer list making it get called first when notified
  4373. * @param observer the observer to move
  4374. */
  4375. makeObserverTopPriority(observer: Observer<T>): void;
  4376. /**
  4377. * Moves the observable to the bottom of the observer list making it get called last when notified
  4378. * @param observer the observer to move
  4379. */
  4380. makeObserverBottomPriority(observer: Observer<T>): void;
  4381. /**
  4382. * Notify all Observers by calling their respective callback with the given data
  4383. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4384. * @param eventData defines the data to send to all observers
  4385. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4386. * @param target defines the original target of the state
  4387. * @param currentTarget defines the current target of the state
  4388. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4389. */
  4390. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4391. /**
  4392. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4393. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4394. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4395. * and it is crucial that all callbacks will be executed.
  4396. * The order of the callbacks is kept, callbacks are not executed parallel.
  4397. *
  4398. * @param eventData The data to be sent to each callback
  4399. * @param mask is used to filter observers defaults to -1
  4400. * @param target defines the callback target (see EventState)
  4401. * @param currentTarget defines he current object in the bubbling phase
  4402. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4403. */
  4404. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4405. /**
  4406. * Notify a specific observer
  4407. * @param observer defines the observer to notify
  4408. * @param eventData defines the data to be sent to each callback
  4409. * @param mask is used to filter observers defaults to -1
  4410. */
  4411. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4412. /**
  4413. * Gets a boolean indicating if the observable has at least one observer
  4414. * @returns true is the Observable has at least one Observer registered
  4415. */
  4416. hasObservers(): boolean;
  4417. /**
  4418. * Clear the list of observers
  4419. */
  4420. clear(): void;
  4421. /**
  4422. * Clone the current observable
  4423. * @returns a new observable
  4424. */
  4425. clone(): Observable<T>;
  4426. /**
  4427. * Does this observable handles observer registered with a given mask
  4428. * @param mask defines the mask to be tested
  4429. * @return whether or not one observer registered with the given mask is handeled
  4430. **/
  4431. hasSpecificMask(mask?: number): boolean;
  4432. }
  4433. }
  4434. declare module "babylonjs/Misc/filesInputStore" {
  4435. /**
  4436. * Class used to help managing file picking and drag'n'drop
  4437. * File Storage
  4438. */
  4439. export class FilesInputStore {
  4440. /**
  4441. * List of files ready to be loaded
  4442. */
  4443. static FilesToLoad: {
  4444. [key: string]: File;
  4445. };
  4446. }
  4447. }
  4448. declare module "babylonjs/Engines/constants" {
  4449. /** Defines the cross module used constants to avoid circular dependncies */
  4450. export class Constants {
  4451. /** Defines that alpha blending is disabled */
  4452. static readonly ALPHA_DISABLE: number;
  4453. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4454. static readonly ALPHA_ADD: number;
  4455. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4456. static readonly ALPHA_COMBINE: number;
  4457. /** Defines that alpha blending to DEST - SRC * DEST */
  4458. static readonly ALPHA_SUBTRACT: number;
  4459. /** Defines that alpha blending to SRC * DEST */
  4460. static readonly ALPHA_MULTIPLY: number;
  4461. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4462. static readonly ALPHA_MAXIMIZED: number;
  4463. /** Defines that alpha blending to SRC + DEST */
  4464. static readonly ALPHA_ONEONE: number;
  4465. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4466. static readonly ALPHA_PREMULTIPLIED: number;
  4467. /**
  4468. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4469. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4470. */
  4471. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4472. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4473. static readonly ALPHA_INTERPOLATE: number;
  4474. /**
  4475. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4476. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4477. */
  4478. static readonly ALPHA_SCREENMODE: number;
  4479. /** Defines that the ressource is not delayed*/
  4480. static readonly DELAYLOADSTATE_NONE: number;
  4481. /** Defines that the ressource was successfully delay loaded */
  4482. static readonly DELAYLOADSTATE_LOADED: number;
  4483. /** Defines that the ressource is currently delay loading */
  4484. static readonly DELAYLOADSTATE_LOADING: number;
  4485. /** Defines that the ressource is delayed and has not started loading */
  4486. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4487. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4488. static readonly NEVER: number;
  4489. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4490. static readonly ALWAYS: number;
  4491. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4492. static readonly LESS: number;
  4493. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4494. static readonly EQUAL: number;
  4495. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4496. static readonly LEQUAL: number;
  4497. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4498. static readonly GREATER: number;
  4499. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4500. static readonly GEQUAL: number;
  4501. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4502. static readonly NOTEQUAL: number;
  4503. /** Passed to stencilOperation to specify that stencil value must be kept */
  4504. static readonly KEEP: number;
  4505. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4506. static readonly REPLACE: number;
  4507. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4508. static readonly INCR: number;
  4509. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4510. static readonly DECR: number;
  4511. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4512. static readonly INVERT: number;
  4513. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4514. static readonly INCR_WRAP: number;
  4515. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4516. static readonly DECR_WRAP: number;
  4517. /** Texture is not repeating outside of 0..1 UVs */
  4518. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4519. /** Texture is repeating outside of 0..1 UVs */
  4520. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4521. /** Texture is repeating and mirrored */
  4522. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4523. /** ALPHA */
  4524. static readonly TEXTUREFORMAT_ALPHA: number;
  4525. /** LUMINANCE */
  4526. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4527. /** LUMINANCE_ALPHA */
  4528. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4529. /** RGB */
  4530. static readonly TEXTUREFORMAT_RGB: number;
  4531. /** RGBA */
  4532. static readonly TEXTUREFORMAT_RGBA: number;
  4533. /** RED */
  4534. static readonly TEXTUREFORMAT_RED: number;
  4535. /** RED (2nd reference) */
  4536. static readonly TEXTUREFORMAT_R: number;
  4537. /** RG */
  4538. static readonly TEXTUREFORMAT_RG: number;
  4539. /** RED_INTEGER */
  4540. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4541. /** RED_INTEGER (2nd reference) */
  4542. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4543. /** RG_INTEGER */
  4544. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4545. /** RGB_INTEGER */
  4546. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4547. /** RGBA_INTEGER */
  4548. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4549. /** UNSIGNED_BYTE */
  4550. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4551. /** UNSIGNED_BYTE (2nd reference) */
  4552. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4553. /** FLOAT */
  4554. static readonly TEXTURETYPE_FLOAT: number;
  4555. /** HALF_FLOAT */
  4556. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4557. /** BYTE */
  4558. static readonly TEXTURETYPE_BYTE: number;
  4559. /** SHORT */
  4560. static readonly TEXTURETYPE_SHORT: number;
  4561. /** UNSIGNED_SHORT */
  4562. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4563. /** INT */
  4564. static readonly TEXTURETYPE_INT: number;
  4565. /** UNSIGNED_INT */
  4566. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4567. /** UNSIGNED_SHORT_4_4_4_4 */
  4568. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4569. /** UNSIGNED_SHORT_5_5_5_1 */
  4570. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4571. /** UNSIGNED_SHORT_5_6_5 */
  4572. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4573. /** UNSIGNED_INT_2_10_10_10_REV */
  4574. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4575. /** UNSIGNED_INT_24_8 */
  4576. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4577. /** UNSIGNED_INT_10F_11F_11F_REV */
  4578. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4579. /** UNSIGNED_INT_5_9_9_9_REV */
  4580. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4581. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4582. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4583. /** nearest is mag = nearest and min = nearest and mip = linear */
  4584. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4585. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4586. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4587. /** Trilinear is mag = linear and min = linear and mip = linear */
  4588. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4589. /** nearest is mag = nearest and min = nearest and mip = linear */
  4590. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4591. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4592. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4593. /** Trilinear is mag = linear and min = linear and mip = linear */
  4594. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4595. /** mag = nearest and min = nearest and mip = nearest */
  4596. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4597. /** mag = nearest and min = linear and mip = nearest */
  4598. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4599. /** mag = nearest and min = linear and mip = linear */
  4600. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4601. /** mag = nearest and min = linear and mip = none */
  4602. static readonly TEXTURE_NEAREST_LINEAR: number;
  4603. /** mag = nearest and min = nearest and mip = none */
  4604. static readonly TEXTURE_NEAREST_NEAREST: number;
  4605. /** mag = linear and min = nearest and mip = nearest */
  4606. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4607. /** mag = linear and min = nearest and mip = linear */
  4608. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4609. /** mag = linear and min = linear and mip = none */
  4610. static readonly TEXTURE_LINEAR_LINEAR: number;
  4611. /** mag = linear and min = nearest and mip = none */
  4612. static readonly TEXTURE_LINEAR_NEAREST: number;
  4613. /** Explicit coordinates mode */
  4614. static readonly TEXTURE_EXPLICIT_MODE: number;
  4615. /** Spherical coordinates mode */
  4616. static readonly TEXTURE_SPHERICAL_MODE: number;
  4617. /** Planar coordinates mode */
  4618. static readonly TEXTURE_PLANAR_MODE: number;
  4619. /** Cubic coordinates mode */
  4620. static readonly TEXTURE_CUBIC_MODE: number;
  4621. /** Projection coordinates mode */
  4622. static readonly TEXTURE_PROJECTION_MODE: number;
  4623. /** Skybox coordinates mode */
  4624. static readonly TEXTURE_SKYBOX_MODE: number;
  4625. /** Inverse Cubic coordinates mode */
  4626. static readonly TEXTURE_INVCUBIC_MODE: number;
  4627. /** Equirectangular coordinates mode */
  4628. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4629. /** Equirectangular Fixed coordinates mode */
  4630. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4631. /** Equirectangular Fixed Mirrored coordinates mode */
  4632. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4633. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4634. static readonly SCALEMODE_FLOOR: number;
  4635. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4636. static readonly SCALEMODE_NEAREST: number;
  4637. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4638. static readonly SCALEMODE_CEILING: number;
  4639. /**
  4640. * The dirty texture flag value
  4641. */
  4642. static readonly MATERIAL_TextureDirtyFlag: number;
  4643. /**
  4644. * The dirty light flag value
  4645. */
  4646. static readonly MATERIAL_LightDirtyFlag: number;
  4647. /**
  4648. * The dirty fresnel flag value
  4649. */
  4650. static readonly MATERIAL_FresnelDirtyFlag: number;
  4651. /**
  4652. * The dirty attribute flag value
  4653. */
  4654. static readonly MATERIAL_AttributesDirtyFlag: number;
  4655. /**
  4656. * The dirty misc flag value
  4657. */
  4658. static readonly MATERIAL_MiscDirtyFlag: number;
  4659. /**
  4660. * The all dirty flag value
  4661. */
  4662. static readonly MATERIAL_AllDirtyFlag: number;
  4663. /**
  4664. * Returns the triangle fill mode
  4665. */
  4666. static readonly MATERIAL_TriangleFillMode: number;
  4667. /**
  4668. * Returns the wireframe mode
  4669. */
  4670. static readonly MATERIAL_WireFrameFillMode: number;
  4671. /**
  4672. * Returns the point fill mode
  4673. */
  4674. static readonly MATERIAL_PointFillMode: number;
  4675. /**
  4676. * Returns the point list draw mode
  4677. */
  4678. static readonly MATERIAL_PointListDrawMode: number;
  4679. /**
  4680. * Returns the line list draw mode
  4681. */
  4682. static readonly MATERIAL_LineListDrawMode: number;
  4683. /**
  4684. * Returns the line loop draw mode
  4685. */
  4686. static readonly MATERIAL_LineLoopDrawMode: number;
  4687. /**
  4688. * Returns the line strip draw mode
  4689. */
  4690. static readonly MATERIAL_LineStripDrawMode: number;
  4691. /**
  4692. * Returns the triangle strip draw mode
  4693. */
  4694. static readonly MATERIAL_TriangleStripDrawMode: number;
  4695. /**
  4696. * Returns the triangle fan draw mode
  4697. */
  4698. static readonly MATERIAL_TriangleFanDrawMode: number;
  4699. /**
  4700. * Stores the clock-wise side orientation
  4701. */
  4702. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4703. /**
  4704. * Stores the counter clock-wise side orientation
  4705. */
  4706. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4707. /**
  4708. * Nothing
  4709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4710. */
  4711. static readonly ACTION_NothingTrigger: number;
  4712. /**
  4713. * On pick
  4714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4715. */
  4716. static readonly ACTION_OnPickTrigger: number;
  4717. /**
  4718. * On left pick
  4719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4720. */
  4721. static readonly ACTION_OnLeftPickTrigger: number;
  4722. /**
  4723. * On right pick
  4724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4725. */
  4726. static readonly ACTION_OnRightPickTrigger: number;
  4727. /**
  4728. * On center pick
  4729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4730. */
  4731. static readonly ACTION_OnCenterPickTrigger: number;
  4732. /**
  4733. * On pick down
  4734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4735. */
  4736. static readonly ACTION_OnPickDownTrigger: number;
  4737. /**
  4738. * On double pick
  4739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4740. */
  4741. static readonly ACTION_OnDoublePickTrigger: number;
  4742. /**
  4743. * On pick up
  4744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4745. */
  4746. static readonly ACTION_OnPickUpTrigger: number;
  4747. /**
  4748. * On pick out.
  4749. * This trigger will only be raised if you also declared a OnPickDown
  4750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4751. */
  4752. static readonly ACTION_OnPickOutTrigger: number;
  4753. /**
  4754. * On long press
  4755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4756. */
  4757. static readonly ACTION_OnLongPressTrigger: number;
  4758. /**
  4759. * On pointer over
  4760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4761. */
  4762. static readonly ACTION_OnPointerOverTrigger: number;
  4763. /**
  4764. * On pointer out
  4765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4766. */
  4767. static readonly ACTION_OnPointerOutTrigger: number;
  4768. /**
  4769. * On every frame
  4770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4771. */
  4772. static readonly ACTION_OnEveryFrameTrigger: number;
  4773. /**
  4774. * On intersection enter
  4775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4776. */
  4777. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4778. /**
  4779. * On intersection exit
  4780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4781. */
  4782. static readonly ACTION_OnIntersectionExitTrigger: number;
  4783. /**
  4784. * On key down
  4785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4786. */
  4787. static readonly ACTION_OnKeyDownTrigger: number;
  4788. /**
  4789. * On key up
  4790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4791. */
  4792. static readonly ACTION_OnKeyUpTrigger: number;
  4793. /**
  4794. * Billboard mode will only apply to Y axis
  4795. */
  4796. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4797. /**
  4798. * Billboard mode will apply to all axes
  4799. */
  4800. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4801. /**
  4802. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4803. */
  4804. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4805. /**
  4806. * Gets or sets base Assets URL
  4807. */
  4808. static readonly PARTICLES_BaseAssetsUrl: string;
  4809. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4810. * Test order :
  4811. * Is the bounding sphere outside the frustum ?
  4812. * If not, are the bounding box vertices outside the frustum ?
  4813. * It not, then the cullable object is in the frustum.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4816. /** Culling strategy : Bounding Sphere Only.
  4817. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4818. * It's also less accurate than the standard because some not visible objects can still be selected.
  4819. * Test : is the bounding sphere outside the frustum ?
  4820. * If not, then the cullable object is in the frustum.
  4821. */
  4822. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4823. /** Culling strategy : Optimistic Inclusion.
  4824. * This in an inclusion test first, then the standard exclusion test.
  4825. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4826. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4827. * Anyway, it's as accurate as the standard strategy.
  4828. * Test :
  4829. * Is the cullable object bounding sphere center in the frustum ?
  4830. * If not, apply the default culling strategy.
  4831. */
  4832. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4833. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4834. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4835. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4836. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4837. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4838. * Test :
  4839. * Is the cullable object bounding sphere center in the frustum ?
  4840. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4841. */
  4842. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4843. /**
  4844. * No logging while loading
  4845. */
  4846. static readonly SCENELOADER_NO_LOGGING: number;
  4847. /**
  4848. * Minimal logging while loading
  4849. */
  4850. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4851. /**
  4852. * Summary logging while loading
  4853. */
  4854. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4855. /**
  4856. * Detailled logging while loading
  4857. */
  4858. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4859. }
  4860. }
  4861. declare module "babylonjs/Misc/domManagement" {
  4862. /**
  4863. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4864. * Babylon.js
  4865. */
  4866. export class DomManagement {
  4867. /**
  4868. * Checks if the window object exists
  4869. * @returns true if the window object exists
  4870. */
  4871. static IsWindowObjectExist(): boolean;
  4872. /**
  4873. * Extracts text content from a DOM element hierarchy
  4874. * @param element defines the root element
  4875. * @returns a string
  4876. */
  4877. static GetDOMTextContent(element: HTMLElement): string;
  4878. }
  4879. }
  4880. declare module "babylonjs/Misc/logger" {
  4881. /**
  4882. * Logger used througouht the application to allow configuration of
  4883. * the log level required for the messages.
  4884. */
  4885. export class Logger {
  4886. /**
  4887. * No log
  4888. */
  4889. static readonly NoneLogLevel: number;
  4890. /**
  4891. * Only message logs
  4892. */
  4893. static readonly MessageLogLevel: number;
  4894. /**
  4895. * Only warning logs
  4896. */
  4897. static readonly WarningLogLevel: number;
  4898. /**
  4899. * Only error logs
  4900. */
  4901. static readonly ErrorLogLevel: number;
  4902. /**
  4903. * All logs
  4904. */
  4905. static readonly AllLogLevel: number;
  4906. private static _LogCache;
  4907. /**
  4908. * Gets a value indicating the number of loading errors
  4909. * @ignorenaming
  4910. */
  4911. static errorsCount: number;
  4912. /**
  4913. * Callback called when a new log is added
  4914. */
  4915. static OnNewCacheEntry: (entry: string) => void;
  4916. private static _AddLogEntry;
  4917. private static _FormatMessage;
  4918. private static _LogDisabled;
  4919. private static _LogEnabled;
  4920. private static _WarnDisabled;
  4921. private static _WarnEnabled;
  4922. private static _ErrorDisabled;
  4923. private static _ErrorEnabled;
  4924. /**
  4925. * Log a message to the console
  4926. */
  4927. static Log: (message: string) => void;
  4928. /**
  4929. * Write a warning message to the console
  4930. */
  4931. static Warn: (message: string) => void;
  4932. /**
  4933. * Write an error message to the console
  4934. */
  4935. static Error: (message: string) => void;
  4936. /**
  4937. * Gets current log cache (list of logs)
  4938. */
  4939. static readonly LogCache: string;
  4940. /**
  4941. * Clears the log cache
  4942. */
  4943. static ClearLogCache(): void;
  4944. /**
  4945. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4946. */
  4947. static LogLevels: number;
  4948. }
  4949. }
  4950. declare module "babylonjs/Misc/typeStore" {
  4951. /** @hidden */
  4952. export class _TypeStore {
  4953. /** @hidden */
  4954. static RegisteredTypes: {
  4955. [key: string]: Object;
  4956. };
  4957. /** @hidden */
  4958. static GetClass(fqdn: string): any;
  4959. }
  4960. }
  4961. declare module "babylonjs/Misc/deepCopier" {
  4962. /**
  4963. * Class containing a set of static utilities functions for deep copy.
  4964. */
  4965. export class DeepCopier {
  4966. /**
  4967. * Tries to copy an object by duplicating every property
  4968. * @param source defines the source object
  4969. * @param destination defines the target object
  4970. * @param doNotCopyList defines a list of properties to avoid
  4971. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4972. */
  4973. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4974. }
  4975. }
  4976. declare module "babylonjs/Misc/precisionDate" {
  4977. /**
  4978. * Class containing a set of static utilities functions for precision date
  4979. */
  4980. export class PrecisionDate {
  4981. /**
  4982. * Gets either window.performance.now() if supported or Date.now() else
  4983. */
  4984. static readonly Now: number;
  4985. }
  4986. }
  4987. declare module "babylonjs/Misc/devTools" {
  4988. /** @hidden */
  4989. export class _DevTools {
  4990. static WarnImport(name: string): string;
  4991. }
  4992. }
  4993. declare module "babylonjs/Misc/webRequest" {
  4994. /**
  4995. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4996. */
  4997. export class WebRequest {
  4998. private _xhr;
  4999. /**
  5000. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5001. * i.e. when loading files, where the server/service expects an Authorization header
  5002. */
  5003. static CustomRequestHeaders: {
  5004. [key: string]: string;
  5005. };
  5006. /**
  5007. * Add callback functions in this array to update all the requests before they get sent to the network
  5008. */
  5009. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5010. private _injectCustomRequestHeaders;
  5011. /**
  5012. * Gets or sets a function to be called when loading progress changes
  5013. */
  5014. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5015. /**
  5016. * Returns client's state
  5017. */
  5018. readonly readyState: number;
  5019. /**
  5020. * Returns client's status
  5021. */
  5022. readonly status: number;
  5023. /**
  5024. * Returns client's status as a text
  5025. */
  5026. readonly statusText: string;
  5027. /**
  5028. * Returns client's response
  5029. */
  5030. readonly response: any;
  5031. /**
  5032. * Returns client's response url
  5033. */
  5034. readonly responseURL: string;
  5035. /**
  5036. * Returns client's response as text
  5037. */
  5038. readonly responseText: string;
  5039. /**
  5040. * Gets or sets the expected response type
  5041. */
  5042. responseType: XMLHttpRequestResponseType;
  5043. /** @hidden */
  5044. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5045. /** @hidden */
  5046. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5047. /**
  5048. * Cancels any network activity
  5049. */
  5050. abort(): void;
  5051. /**
  5052. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5053. * @param body defines an optional request body
  5054. */
  5055. send(body?: Document | BodyInit | null): void;
  5056. /**
  5057. * Sets the request method, request URL
  5058. * @param method defines the method to use (GET, POST, etc..)
  5059. * @param url defines the url to connect with
  5060. */
  5061. open(method: string, url: string): void;
  5062. }
  5063. }
  5064. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5065. /**
  5066. * Class used to evalaute queries containing `and` and `or` operators
  5067. */
  5068. export class AndOrNotEvaluator {
  5069. /**
  5070. * Evaluate a query
  5071. * @param query defines the query to evaluate
  5072. * @param evaluateCallback defines the callback used to filter result
  5073. * @returns true if the query matches
  5074. */
  5075. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5076. private static _HandleParenthesisContent;
  5077. private static _SimplifyNegation;
  5078. }
  5079. }
  5080. declare module "babylonjs/Misc/tags" {
  5081. /**
  5082. * Class used to store custom tags
  5083. */
  5084. export class Tags {
  5085. /**
  5086. * Adds support for tags on the given object
  5087. * @param obj defines the object to use
  5088. */
  5089. static EnableFor(obj: any): void;
  5090. /**
  5091. * Removes tags support
  5092. * @param obj defines the object to use
  5093. */
  5094. static DisableFor(obj: any): void;
  5095. /**
  5096. * Gets a boolean indicating if the given object has tags
  5097. * @param obj defines the object to use
  5098. * @returns a boolean
  5099. */
  5100. static HasTags(obj: any): boolean;
  5101. /**
  5102. * Gets the tags available on a given object
  5103. * @param obj defines the object to use
  5104. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5105. * @returns the tags
  5106. */
  5107. static GetTags(obj: any, asString?: boolean): any;
  5108. /**
  5109. * Adds tags to an object
  5110. * @param obj defines the object to use
  5111. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5112. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5113. */
  5114. static AddTagsTo(obj: any, tagsString: string): void;
  5115. /**
  5116. * @hidden
  5117. */
  5118. static _AddTagTo(obj: any, tag: string): void;
  5119. /**
  5120. * Removes specific tags from a specific object
  5121. * @param obj defines the object to use
  5122. * @param tagsString defines the tags to remove
  5123. */
  5124. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5125. /**
  5126. * @hidden
  5127. */
  5128. static _RemoveTagFrom(obj: any, tag: string): void;
  5129. /**
  5130. * Defines if tags hosted on an object match a given query
  5131. * @param obj defines the object to use
  5132. * @param tagsQuery defines the tag query
  5133. * @returns a boolean
  5134. */
  5135. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5136. }
  5137. }
  5138. declare module "babylonjs/Materials/materialDefines" {
  5139. /**
  5140. * Manages the defines for the Material
  5141. */
  5142. export class MaterialDefines {
  5143. private _keys;
  5144. private _isDirty;
  5145. /** @hidden */
  5146. _renderId: number;
  5147. /** @hidden */
  5148. _areLightsDirty: boolean;
  5149. /** @hidden */
  5150. _areAttributesDirty: boolean;
  5151. /** @hidden */
  5152. _areTexturesDirty: boolean;
  5153. /** @hidden */
  5154. _areFresnelDirty: boolean;
  5155. /** @hidden */
  5156. _areMiscDirty: boolean;
  5157. /** @hidden */
  5158. _areImageProcessingDirty: boolean;
  5159. /** @hidden */
  5160. _normals: boolean;
  5161. /** @hidden */
  5162. _uvs: boolean;
  5163. /** @hidden */
  5164. _needNormals: boolean;
  5165. /** @hidden */
  5166. _needUVs: boolean;
  5167. /**
  5168. * Specifies if the material needs to be re-calculated
  5169. */
  5170. readonly isDirty: boolean;
  5171. /**
  5172. * Marks the material to indicate that it has been re-calculated
  5173. */
  5174. markAsProcessed(): void;
  5175. /**
  5176. * Marks the material to indicate that it needs to be re-calculated
  5177. */
  5178. markAsUnprocessed(): void;
  5179. /**
  5180. * Marks the material to indicate all of its defines need to be re-calculated
  5181. */
  5182. markAllAsDirty(): void;
  5183. /**
  5184. * Marks the material to indicate that image processing needs to be re-calculated
  5185. */
  5186. markAsImageProcessingDirty(): void;
  5187. /**
  5188. * Marks the material to indicate the lights need to be re-calculated
  5189. */
  5190. markAsLightDirty(): void;
  5191. /**
  5192. * Marks the attribute state as changed
  5193. */
  5194. markAsAttributesDirty(): void;
  5195. /**
  5196. * Marks the texture state as changed
  5197. */
  5198. markAsTexturesDirty(): void;
  5199. /**
  5200. * Marks the fresnel state as changed
  5201. */
  5202. markAsFresnelDirty(): void;
  5203. /**
  5204. * Marks the misc state as changed
  5205. */
  5206. markAsMiscDirty(): void;
  5207. /**
  5208. * Rebuilds the material defines
  5209. */
  5210. rebuild(): void;
  5211. /**
  5212. * Specifies if two material defines are equal
  5213. * @param other - A material define instance to compare to
  5214. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5215. */
  5216. isEqual(other: MaterialDefines): boolean;
  5217. /**
  5218. * Clones this instance's defines to another instance
  5219. * @param other - material defines to clone values to
  5220. */
  5221. cloneTo(other: MaterialDefines): void;
  5222. /**
  5223. * Resets the material define values
  5224. */
  5225. reset(): void;
  5226. /**
  5227. * Converts the material define values to a string
  5228. * @returns - String of material define information
  5229. */
  5230. toString(): string;
  5231. }
  5232. }
  5233. declare module "babylonjs/Misc/performanceMonitor" {
  5234. /**
  5235. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5236. */
  5237. export class PerformanceMonitor {
  5238. private _enabled;
  5239. private _rollingFrameTime;
  5240. private _lastFrameTimeMs;
  5241. /**
  5242. * constructor
  5243. * @param frameSampleSize The number of samples required to saturate the sliding window
  5244. */
  5245. constructor(frameSampleSize?: number);
  5246. /**
  5247. * Samples current frame
  5248. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5249. */
  5250. sampleFrame(timeMs?: number): void;
  5251. /**
  5252. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5253. */
  5254. readonly averageFrameTime: number;
  5255. /**
  5256. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5257. */
  5258. readonly averageFrameTimeVariance: number;
  5259. /**
  5260. * Returns the frame time of the most recent frame
  5261. */
  5262. readonly instantaneousFrameTime: number;
  5263. /**
  5264. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5265. */
  5266. readonly averageFPS: number;
  5267. /**
  5268. * Returns the average framerate in frames per second using the most recent frame time
  5269. */
  5270. readonly instantaneousFPS: number;
  5271. /**
  5272. * Returns true if enough samples have been taken to completely fill the sliding window
  5273. */
  5274. readonly isSaturated: boolean;
  5275. /**
  5276. * Enables contributions to the sliding window sample set
  5277. */
  5278. enable(): void;
  5279. /**
  5280. * Disables contributions to the sliding window sample set
  5281. * Samples will not be interpolated over the disabled period
  5282. */
  5283. disable(): void;
  5284. /**
  5285. * Returns true if sampling is enabled
  5286. */
  5287. readonly isEnabled: boolean;
  5288. /**
  5289. * Resets performance monitor
  5290. */
  5291. reset(): void;
  5292. }
  5293. /**
  5294. * RollingAverage
  5295. *
  5296. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5297. */
  5298. export class RollingAverage {
  5299. /**
  5300. * Current average
  5301. */
  5302. average: number;
  5303. /**
  5304. * Current variance
  5305. */
  5306. variance: number;
  5307. protected _samples: Array<number>;
  5308. protected _sampleCount: number;
  5309. protected _pos: number;
  5310. protected _m2: number;
  5311. /**
  5312. * constructor
  5313. * @param length The number of samples required to saturate the sliding window
  5314. */
  5315. constructor(length: number);
  5316. /**
  5317. * Adds a sample to the sample set
  5318. * @param v The sample value
  5319. */
  5320. add(v: number): void;
  5321. /**
  5322. * Returns previously added values or null if outside of history or outside the sliding window domain
  5323. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5324. * @return Value previously recorded with add() or null if outside of range
  5325. */
  5326. history(i: number): number;
  5327. /**
  5328. * Returns true if enough samples have been taken to completely fill the sliding window
  5329. * @return true if sample-set saturated
  5330. */
  5331. isSaturated(): boolean;
  5332. /**
  5333. * Resets the rolling average (equivalent to 0 samples taken so far)
  5334. */
  5335. reset(): void;
  5336. /**
  5337. * Wraps a value around the sample range boundaries
  5338. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5339. * @return Wrapped position in sample range
  5340. */
  5341. protected _wrapPosition(i: number): number;
  5342. }
  5343. }
  5344. declare module "babylonjs/Misc/stringDictionary" {
  5345. import { Nullable } from "babylonjs/types";
  5346. /**
  5347. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5348. * The underlying implementation relies on an associative array to ensure the best performances.
  5349. * The value can be anything including 'null' but except 'undefined'
  5350. */
  5351. export class StringDictionary<T> {
  5352. /**
  5353. * This will clear this dictionary and copy the content from the 'source' one.
  5354. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5355. * @param source the dictionary to take the content from and copy to this dictionary
  5356. */
  5357. copyFrom(source: StringDictionary<T>): void;
  5358. /**
  5359. * Get a value based from its key
  5360. * @param key the given key to get the matching value from
  5361. * @return the value if found, otherwise undefined is returned
  5362. */
  5363. get(key: string): T | undefined;
  5364. /**
  5365. * Get a value from its key or add it if it doesn't exist.
  5366. * This method will ensure you that a given key/data will be present in the dictionary.
  5367. * @param key the given key to get the matching value from
  5368. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5369. * The factory will only be invoked if there's no data for the given key.
  5370. * @return the value corresponding to the key.
  5371. */
  5372. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5373. /**
  5374. * Get a value from its key if present in the dictionary otherwise add it
  5375. * @param key the key to get the value from
  5376. * @param val if there's no such key/value pair in the dictionary add it with this value
  5377. * @return the value corresponding to the key
  5378. */
  5379. getOrAdd(key: string, val: T): T;
  5380. /**
  5381. * Check if there's a given key in the dictionary
  5382. * @param key the key to check for
  5383. * @return true if the key is present, false otherwise
  5384. */
  5385. contains(key: string): boolean;
  5386. /**
  5387. * Add a new key and its corresponding value
  5388. * @param key the key to add
  5389. * @param value the value corresponding to the key
  5390. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  5391. */
  5392. add(key: string, value: T): boolean;
  5393. /**
  5394. * Update a specific value associated to a key
  5395. * @param key defines the key to use
  5396. * @param value defines the value to store
  5397. * @returns true if the value was updated (or false if the key was not found)
  5398. */
  5399. set(key: string, value: T): boolean;
  5400. /**
  5401. * Get the element of the given key and remove it from the dictionary
  5402. * @param key defines the key to search
  5403. * @returns the value associated with the key or null if not found
  5404. */
  5405. getAndRemove(key: string): Nullable<T>;
  5406. /**
  5407. * Remove a key/value from the dictionary.
  5408. * @param key the key to remove
  5409. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5410. */
  5411. remove(key: string): boolean;
  5412. /**
  5413. * Clear the whole content of the dictionary
  5414. */
  5415. clear(): void;
  5416. /**
  5417. * Gets the current count
  5418. */
  5419. readonly count: number;
  5420. /**
  5421. * Execute a callback on each key/val of the dictionary.
  5422. * Note that you can remove any element in this dictionary in the callback implementation
  5423. * @param callback the callback to execute on a given key/value pair
  5424. */
  5425. forEach(callback: (key: string, val: T) => void): void;
  5426. /**
  5427. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5428. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5429. * Note that you can remove any element in this dictionary in the callback implementation
  5430. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5431. * @returns the first item
  5432. */
  5433. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5434. private _count;
  5435. private _data;
  5436. }
  5437. }
  5438. declare module "babylonjs/Misc/promise" {
  5439. /**
  5440. * Helper class that provides a small promise polyfill
  5441. */
  5442. export class PromisePolyfill {
  5443. /**
  5444. * Static function used to check if the polyfill is required
  5445. * If this is the case then the function will inject the polyfill to window.Promise
  5446. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5447. */
  5448. static Apply(force?: boolean): void;
  5449. }
  5450. }
  5451. declare module "babylonjs/Meshes/buffer" {
  5452. import { Nullable, DataArray } from "babylonjs/types";
  5453. /**
  5454. * Class used to store data that will be store in GPU memory
  5455. */
  5456. export class Buffer {
  5457. private _engine;
  5458. private _buffer;
  5459. /** @hidden */
  5460. _data: Nullable<DataArray>;
  5461. private _updatable;
  5462. private _instanced;
  5463. /**
  5464. * Gets the byte stride.
  5465. */
  5466. readonly byteStride: number;
  5467. /**
  5468. * Constructor
  5469. * @param engine the engine
  5470. * @param data the data to use for this buffer
  5471. * @param updatable whether the data is updatable
  5472. * @param stride the stride (optional)
  5473. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5474. * @param instanced whether the buffer is instanced (optional)
  5475. * @param useBytes set to true if the stride in in bytes (optional)
  5476. */
  5477. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5478. /**
  5479. * Create a new VertexBuffer based on the current buffer
  5480. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5481. * @param offset defines offset in the buffer (0 by default)
  5482. * @param size defines the size in floats of attributes (position is 3 for instance)
  5483. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5484. * @param instanced defines if the vertex buffer contains indexed data
  5485. * @param useBytes defines if the offset and stride are in bytes
  5486. * @returns the new vertex buffer
  5487. */
  5488. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5489. /**
  5490. * Gets a boolean indicating if the Buffer is updatable?
  5491. * @returns true if the buffer is updatable
  5492. */
  5493. isUpdatable(): boolean;
  5494. /**
  5495. * Gets current buffer's data
  5496. * @returns a DataArray or null
  5497. */
  5498. getData(): Nullable<DataArray>;
  5499. /**
  5500. * Gets underlying native buffer
  5501. * @returns underlying native buffer
  5502. */
  5503. getBuffer(): Nullable<WebGLBuffer>;
  5504. /**
  5505. * Gets the stride in float32 units (i.e. byte stride / 4).
  5506. * May not be an integer if the byte stride is not divisible by 4.
  5507. * DEPRECATED. Use byteStride instead.
  5508. * @returns the stride in float32 units
  5509. */
  5510. getStrideSize(): number;
  5511. /**
  5512. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5513. * @param data defines the data to store
  5514. */
  5515. create(data?: Nullable<DataArray>): void;
  5516. /** @hidden */
  5517. _rebuild(): void;
  5518. /**
  5519. * Update current buffer data
  5520. * @param data defines the data to store
  5521. */
  5522. update(data: DataArray): void;
  5523. /**
  5524. * Updates the data directly.
  5525. * @param data the new data
  5526. * @param offset the new offset
  5527. * @param vertexCount the vertex count (optional)
  5528. * @param useBytes set to true if the offset is in bytes
  5529. */
  5530. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5531. /**
  5532. * Release all resources
  5533. */
  5534. dispose(): void;
  5535. }
  5536. /**
  5537. * Specialized buffer used to store vertex data
  5538. */
  5539. export class VertexBuffer {
  5540. /** @hidden */
  5541. _buffer: Buffer;
  5542. private _kind;
  5543. private _size;
  5544. private _ownsBuffer;
  5545. private _instanced;
  5546. private _instanceDivisor;
  5547. /**
  5548. * The byte type.
  5549. */
  5550. static readonly BYTE: number;
  5551. /**
  5552. * The unsigned byte type.
  5553. */
  5554. static readonly UNSIGNED_BYTE: number;
  5555. /**
  5556. * The short type.
  5557. */
  5558. static readonly SHORT: number;
  5559. /**
  5560. * The unsigned short type.
  5561. */
  5562. static readonly UNSIGNED_SHORT: number;
  5563. /**
  5564. * The integer type.
  5565. */
  5566. static readonly INT: number;
  5567. /**
  5568. * The unsigned integer type.
  5569. */
  5570. static readonly UNSIGNED_INT: number;
  5571. /**
  5572. * The float type.
  5573. */
  5574. static readonly FLOAT: number;
  5575. /**
  5576. * Gets or sets the instance divisor when in instanced mode
  5577. */
  5578. instanceDivisor: number;
  5579. /**
  5580. * Gets the byte stride.
  5581. */
  5582. readonly byteStride: number;
  5583. /**
  5584. * Gets the byte offset.
  5585. */
  5586. readonly byteOffset: number;
  5587. /**
  5588. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5589. */
  5590. readonly normalized: boolean;
  5591. /**
  5592. * Gets the data type of each component in the array.
  5593. */
  5594. readonly type: number;
  5595. /**
  5596. * Constructor
  5597. * @param engine the engine
  5598. * @param data the data to use for this vertex buffer
  5599. * @param kind the vertex buffer kind
  5600. * @param updatable whether the data is updatable
  5601. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5602. * @param stride the stride (optional)
  5603. * @param instanced whether the buffer is instanced (optional)
  5604. * @param offset the offset of the data (optional)
  5605. * @param size the number of components (optional)
  5606. * @param type the type of the component (optional)
  5607. * @param normalized whether the data contains normalized data (optional)
  5608. * @param useBytes set to true if stride and offset are in bytes (optional)
  5609. */
  5610. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  5611. /** @hidden */
  5612. _rebuild(): void;
  5613. /**
  5614. * Returns the kind of the VertexBuffer (string)
  5615. * @returns a string
  5616. */
  5617. getKind(): string;
  5618. /**
  5619. * Gets a boolean indicating if the VertexBuffer is updatable?
  5620. * @returns true if the buffer is updatable
  5621. */
  5622. isUpdatable(): boolean;
  5623. /**
  5624. * Gets current buffer's data
  5625. * @returns a DataArray or null
  5626. */
  5627. getData(): Nullable<DataArray>;
  5628. /**
  5629. * Gets underlying native buffer
  5630. * @returns underlying native buffer
  5631. */
  5632. getBuffer(): Nullable<WebGLBuffer>;
  5633. /**
  5634. * Gets the stride in float32 units (i.e. byte stride / 4).
  5635. * May not be an integer if the byte stride is not divisible by 4.
  5636. * DEPRECATED. Use byteStride instead.
  5637. * @returns the stride in float32 units
  5638. */
  5639. getStrideSize(): number;
  5640. /**
  5641. * Returns the offset as a multiple of the type byte length.
  5642. * DEPRECATED. Use byteOffset instead.
  5643. * @returns the offset in bytes
  5644. */
  5645. getOffset(): number;
  5646. /**
  5647. * Returns the number of components per vertex attribute (integer)
  5648. * @returns the size in float
  5649. */
  5650. getSize(): number;
  5651. /**
  5652. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5653. * @returns true if this buffer is instanced
  5654. */
  5655. getIsInstanced(): boolean;
  5656. /**
  5657. * Returns the instancing divisor, zero for non-instanced (integer).
  5658. * @returns a number
  5659. */
  5660. getInstanceDivisor(): number;
  5661. /**
  5662. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5663. * @param data defines the data to store
  5664. */
  5665. create(data?: DataArray): void;
  5666. /**
  5667. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5668. * This function will create a new buffer if the current one is not updatable
  5669. * @param data defines the data to store
  5670. */
  5671. update(data: DataArray): void;
  5672. /**
  5673. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5674. * Returns the directly updated WebGLBuffer.
  5675. * @param data the new data
  5676. * @param offset the new offset
  5677. * @param useBytes set to true if the offset is in bytes
  5678. */
  5679. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5680. /**
  5681. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5682. */
  5683. dispose(): void;
  5684. /**
  5685. * Enumerates each value of this vertex buffer as numbers.
  5686. * @param count the number of values to enumerate
  5687. * @param callback the callback function called for each value
  5688. */
  5689. forEach(count: number, callback: (value: number, index: number) => void): void;
  5690. /**
  5691. * Positions
  5692. */
  5693. static readonly PositionKind: string;
  5694. /**
  5695. * Normals
  5696. */
  5697. static readonly NormalKind: string;
  5698. /**
  5699. * Tangents
  5700. */
  5701. static readonly TangentKind: string;
  5702. /**
  5703. * Texture coordinates
  5704. */
  5705. static readonly UVKind: string;
  5706. /**
  5707. * Texture coordinates 2
  5708. */
  5709. static readonly UV2Kind: string;
  5710. /**
  5711. * Texture coordinates 3
  5712. */
  5713. static readonly UV3Kind: string;
  5714. /**
  5715. * Texture coordinates 4
  5716. */
  5717. static readonly UV4Kind: string;
  5718. /**
  5719. * Texture coordinates 5
  5720. */
  5721. static readonly UV5Kind: string;
  5722. /**
  5723. * Texture coordinates 6
  5724. */
  5725. static readonly UV6Kind: string;
  5726. /**
  5727. * Colors
  5728. */
  5729. static readonly ColorKind: string;
  5730. /**
  5731. * Matrix indices (for bones)
  5732. */
  5733. static readonly MatricesIndicesKind: string;
  5734. /**
  5735. * Matrix weights (for bones)
  5736. */
  5737. static readonly MatricesWeightsKind: string;
  5738. /**
  5739. * Additional matrix indices (for bones)
  5740. */
  5741. static readonly MatricesIndicesExtraKind: string;
  5742. /**
  5743. * Additional matrix weights (for bones)
  5744. */
  5745. static readonly MatricesWeightsExtraKind: string;
  5746. /**
  5747. * Deduces the stride given a kind.
  5748. * @param kind The kind string to deduce
  5749. * @returns The deduced stride
  5750. */
  5751. static DeduceStride(kind: string): number;
  5752. /**
  5753. * Gets the byte length of the given type.
  5754. * @param type the type
  5755. * @returns the number of bytes
  5756. */
  5757. static GetTypeByteLength(type: number): number;
  5758. /**
  5759. * Enumerates each value of the given parameters as numbers.
  5760. * @param data the data to enumerate
  5761. * @param byteOffset the byte offset of the data
  5762. * @param byteStride the byte stride of the data
  5763. * @param componentCount the number of components per element
  5764. * @param componentType the type of the component
  5765. * @param count the total number of components
  5766. * @param normalized whether the data is normalized
  5767. * @param callback the callback function called for each value
  5768. */
  5769. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5770. private static _GetFloatValue;
  5771. }
  5772. }
  5773. declare module "babylonjs/Maths/sphericalPolynomial" {
  5774. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5775. /**
  5776. * Class representing spherical polynomial coefficients to the 3rd degree
  5777. */
  5778. export class SphericalPolynomial {
  5779. /**
  5780. * The x coefficients of the spherical polynomial
  5781. */
  5782. x: Vector3;
  5783. /**
  5784. * The y coefficients of the spherical polynomial
  5785. */
  5786. y: Vector3;
  5787. /**
  5788. * The z coefficients of the spherical polynomial
  5789. */
  5790. z: Vector3;
  5791. /**
  5792. * The xx coefficients of the spherical polynomial
  5793. */
  5794. xx: Vector3;
  5795. /**
  5796. * The yy coefficients of the spherical polynomial
  5797. */
  5798. yy: Vector3;
  5799. /**
  5800. * The zz coefficients of the spherical polynomial
  5801. */
  5802. zz: Vector3;
  5803. /**
  5804. * The xy coefficients of the spherical polynomial
  5805. */
  5806. xy: Vector3;
  5807. /**
  5808. * The yz coefficients of the spherical polynomial
  5809. */
  5810. yz: Vector3;
  5811. /**
  5812. * The zx coefficients of the spherical polynomial
  5813. */
  5814. zx: Vector3;
  5815. /**
  5816. * Adds an ambient color to the spherical polynomial
  5817. * @param color the color to add
  5818. */
  5819. addAmbient(color: Color3): void;
  5820. /**
  5821. * Scales the spherical polynomial by the given amount
  5822. * @param scale the amount to scale
  5823. */
  5824. scale(scale: number): void;
  5825. /**
  5826. * Gets the spherical polynomial from harmonics
  5827. * @param harmonics the spherical harmonics
  5828. * @returns the spherical polynomial
  5829. */
  5830. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5831. /**
  5832. * Constructs a spherical polynomial from an array.
  5833. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5834. * @returns the spherical polynomial
  5835. */
  5836. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5837. }
  5838. /**
  5839. * Class representing spherical harmonics coefficients to the 3rd degree
  5840. */
  5841. export class SphericalHarmonics {
  5842. /**
  5843. * The l0,0 coefficients of the spherical harmonics
  5844. */
  5845. l00: Vector3;
  5846. /**
  5847. * The l1,-1 coefficients of the spherical harmonics
  5848. */
  5849. l1_1: Vector3;
  5850. /**
  5851. * The l1,0 coefficients of the spherical harmonics
  5852. */
  5853. l10: Vector3;
  5854. /**
  5855. * The l1,1 coefficients of the spherical harmonics
  5856. */
  5857. l11: Vector3;
  5858. /**
  5859. * The l2,-2 coefficients of the spherical harmonics
  5860. */
  5861. l2_2: Vector3;
  5862. /**
  5863. * The l2,-1 coefficients of the spherical harmonics
  5864. */
  5865. l2_1: Vector3;
  5866. /**
  5867. * The l2,0 coefficients of the spherical harmonics
  5868. */
  5869. l20: Vector3;
  5870. /**
  5871. * The l2,1 coefficients of the spherical harmonics
  5872. */
  5873. l21: Vector3;
  5874. /**
  5875. * The l2,2 coefficients of the spherical harmonics
  5876. */
  5877. lL22: Vector3;
  5878. /**
  5879. * Adds a light to the spherical harmonics
  5880. * @param direction the direction of the light
  5881. * @param color the color of the light
  5882. * @param deltaSolidAngle the delta solid angle of the light
  5883. */
  5884. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5885. /**
  5886. * Scales the spherical harmonics by the given amount
  5887. * @param scale the amount to scale
  5888. */
  5889. scale(scale: number): void;
  5890. /**
  5891. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5892. *
  5893. * ```
  5894. * E_lm = A_l * L_lm
  5895. * ```
  5896. *
  5897. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5898. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5899. * the scaling factors are given in equation 9.
  5900. */
  5901. convertIncidentRadianceToIrradiance(): void;
  5902. /**
  5903. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5904. *
  5905. * ```
  5906. * L = (1/pi) * E * rho
  5907. * ```
  5908. *
  5909. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5910. */
  5911. convertIrradianceToLambertianRadiance(): void;
  5912. /**
  5913. * Gets the spherical harmonics from polynomial
  5914. * @param polynomial the spherical polynomial
  5915. * @returns the spherical harmonics
  5916. */
  5917. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5918. /**
  5919. * Constructs a spherical harmonics from an array.
  5920. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5921. * @returns the spherical harmonics
  5922. */
  5923. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5924. }
  5925. }
  5926. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5927. import { Nullable } from "babylonjs/types";
  5928. /**
  5929. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5930. */
  5931. export interface CubeMapInfo {
  5932. /**
  5933. * The pixel array for the front face.
  5934. * This is stored in format, left to right, up to down format.
  5935. */
  5936. front: Nullable<ArrayBufferView>;
  5937. /**
  5938. * The pixel array for the back face.
  5939. * This is stored in format, left to right, up to down format.
  5940. */
  5941. back: Nullable<ArrayBufferView>;
  5942. /**
  5943. * The pixel array for the left face.
  5944. * This is stored in format, left to right, up to down format.
  5945. */
  5946. left: Nullable<ArrayBufferView>;
  5947. /**
  5948. * The pixel array for the right face.
  5949. * This is stored in format, left to right, up to down format.
  5950. */
  5951. right: Nullable<ArrayBufferView>;
  5952. /**
  5953. * The pixel array for the up face.
  5954. * This is stored in format, left to right, up to down format.
  5955. */
  5956. up: Nullable<ArrayBufferView>;
  5957. /**
  5958. * The pixel array for the down face.
  5959. * This is stored in format, left to right, up to down format.
  5960. */
  5961. down: Nullable<ArrayBufferView>;
  5962. /**
  5963. * The size of the cubemap stored.
  5964. *
  5965. * Each faces will be size * size pixels.
  5966. */
  5967. size: number;
  5968. /**
  5969. * The format of the texture.
  5970. *
  5971. * RGBA, RGB.
  5972. */
  5973. format: number;
  5974. /**
  5975. * The type of the texture data.
  5976. *
  5977. * UNSIGNED_INT, FLOAT.
  5978. */
  5979. type: number;
  5980. /**
  5981. * Specifies whether the texture is in gamma space.
  5982. */
  5983. gammaSpace: boolean;
  5984. }
  5985. /**
  5986. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5987. */
  5988. export class PanoramaToCubeMapTools {
  5989. private static FACE_FRONT;
  5990. private static FACE_BACK;
  5991. private static FACE_RIGHT;
  5992. private static FACE_LEFT;
  5993. private static FACE_DOWN;
  5994. private static FACE_UP;
  5995. /**
  5996. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5997. *
  5998. * @param float32Array The source data.
  5999. * @param inputWidth The width of the input panorama.
  6000. * @param inputHeight The height of the input panorama.
  6001. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6002. * @return The cubemap data
  6003. */
  6004. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6005. private static CreateCubemapTexture;
  6006. private static CalcProjectionSpherical;
  6007. }
  6008. }
  6009. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6010. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6011. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6012. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6013. /**
  6014. * Helper class dealing with the extraction of spherical polynomial dataArray
  6015. * from a cube map.
  6016. */
  6017. export class CubeMapToSphericalPolynomialTools {
  6018. private static FileFaces;
  6019. /**
  6020. * Converts a texture to the according Spherical Polynomial data.
  6021. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6022. *
  6023. * @param texture The texture to extract the information from.
  6024. * @return The Spherical Polynomial data.
  6025. */
  6026. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6027. /**
  6028. * Converts a cubemap to the according Spherical Polynomial data.
  6029. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6030. *
  6031. * @param cubeInfo The Cube map to extract the information from.
  6032. * @return The Spherical Polynomial data.
  6033. */
  6034. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6035. }
  6036. }
  6037. declare module "babylonjs/Engines/engineStore" {
  6038. import { Nullable } from "babylonjs/types";
  6039. import { Engine } from "babylonjs/Engines/engine";
  6040. import { Scene } from "babylonjs/scene";
  6041. /**
  6042. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6043. * during the life time of the application.
  6044. */
  6045. export class EngineStore {
  6046. /** Gets the list of created engines */
  6047. static Instances: import("babylonjs/Engines/engine").Engine[];
  6048. /**
  6049. * Gets the latest created engine
  6050. */
  6051. static readonly LastCreatedEngine: Nullable<Engine>;
  6052. /**
  6053. * Gets the latest created scene
  6054. */
  6055. static readonly LastCreatedScene: Nullable<Scene>;
  6056. }
  6057. }
  6058. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6059. /**
  6060. * Define options used to create a render target texture
  6061. */
  6062. export class RenderTargetCreationOptions {
  6063. /**
  6064. * Specifies is mipmaps must be generated
  6065. */
  6066. generateMipMaps?: boolean;
  6067. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6068. generateDepthBuffer?: boolean;
  6069. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6070. generateStencilBuffer?: boolean;
  6071. /** Defines texture type (int by default) */
  6072. type?: number;
  6073. /** Defines sampling mode (trilinear by default) */
  6074. samplingMode?: number;
  6075. /** Defines format (RGBA by default) */
  6076. format?: number;
  6077. }
  6078. }
  6079. declare module "babylonjs/States/alphaCullingState" {
  6080. /**
  6081. * @hidden
  6082. **/
  6083. export class _AlphaState {
  6084. private _isAlphaBlendDirty;
  6085. private _isBlendFunctionParametersDirty;
  6086. private _isBlendEquationParametersDirty;
  6087. private _isBlendConstantsDirty;
  6088. private _alphaBlend;
  6089. private _blendFunctionParameters;
  6090. private _blendEquationParameters;
  6091. private _blendConstants;
  6092. /**
  6093. * Initializes the state.
  6094. */
  6095. constructor();
  6096. readonly isDirty: boolean;
  6097. alphaBlend: boolean;
  6098. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6099. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6100. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6101. reset(): void;
  6102. apply(gl: WebGLRenderingContext): void;
  6103. }
  6104. }
  6105. declare module "babylonjs/States/depthCullingState" {
  6106. import { Nullable } from "babylonjs/types";
  6107. /**
  6108. * @hidden
  6109. **/
  6110. export class _DepthCullingState {
  6111. private _isDepthTestDirty;
  6112. private _isDepthMaskDirty;
  6113. private _isDepthFuncDirty;
  6114. private _isCullFaceDirty;
  6115. private _isCullDirty;
  6116. private _isZOffsetDirty;
  6117. private _isFrontFaceDirty;
  6118. private _depthTest;
  6119. private _depthMask;
  6120. private _depthFunc;
  6121. private _cull;
  6122. private _cullFace;
  6123. private _zOffset;
  6124. private _frontFace;
  6125. /**
  6126. * Initializes the state.
  6127. */
  6128. constructor();
  6129. readonly isDirty: boolean;
  6130. zOffset: number;
  6131. cullFace: Nullable<number>;
  6132. cull: Nullable<boolean>;
  6133. depthFunc: Nullable<number>;
  6134. depthMask: boolean;
  6135. depthTest: boolean;
  6136. frontFace: Nullable<number>;
  6137. reset(): void;
  6138. apply(gl: WebGLRenderingContext): void;
  6139. }
  6140. }
  6141. declare module "babylonjs/States/stencilState" {
  6142. /**
  6143. * @hidden
  6144. **/
  6145. export class _StencilState {
  6146. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  6147. static readonly ALWAYS: number;
  6148. /** Passed to stencilOperation to specify that stencil value must be kept */
  6149. static readonly KEEP: number;
  6150. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6151. static readonly REPLACE: number;
  6152. private _isStencilTestDirty;
  6153. private _isStencilMaskDirty;
  6154. private _isStencilFuncDirty;
  6155. private _isStencilOpDirty;
  6156. private _stencilTest;
  6157. private _stencilMask;
  6158. private _stencilFunc;
  6159. private _stencilFuncRef;
  6160. private _stencilFuncMask;
  6161. private _stencilOpStencilFail;
  6162. private _stencilOpDepthFail;
  6163. private _stencilOpStencilDepthPass;
  6164. readonly isDirty: boolean;
  6165. stencilFunc: number;
  6166. stencilFuncRef: number;
  6167. stencilFuncMask: number;
  6168. stencilOpStencilFail: number;
  6169. stencilOpDepthFail: number;
  6170. stencilOpStencilDepthPass: number;
  6171. stencilMask: number;
  6172. stencilTest: boolean;
  6173. constructor();
  6174. reset(): void;
  6175. apply(gl: WebGLRenderingContext): void;
  6176. }
  6177. }
  6178. declare module "babylonjs/States/index" {
  6179. export * from "babylonjs/States/alphaCullingState";
  6180. export * from "babylonjs/States/depthCullingState";
  6181. export * from "babylonjs/States/stencilState";
  6182. }
  6183. declare module "babylonjs/Instrumentation/timeToken" {
  6184. import { Nullable } from "babylonjs/types";
  6185. /**
  6186. * @hidden
  6187. **/
  6188. export class _TimeToken {
  6189. _startTimeQuery: Nullable<WebGLQuery>;
  6190. _endTimeQuery: Nullable<WebGLQuery>;
  6191. _timeElapsedQuery: Nullable<WebGLQuery>;
  6192. _timeElapsedQueryEnded: boolean;
  6193. }
  6194. }
  6195. declare module "babylonjs/Materials/Textures/internalTexture" {
  6196. import { Observable } from "babylonjs/Misc/observable";
  6197. import { Nullable, int } from "babylonjs/types";
  6198. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6199. import { Engine } from "babylonjs/Engines/engine";
  6200. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6201. /**
  6202. * Class used to store data associated with WebGL texture data for the engine
  6203. * This class should not be used directly
  6204. */
  6205. export class InternalTexture {
  6206. /** hidden */
  6207. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6208. /**
  6209. * The source of the texture data is unknown
  6210. */
  6211. static DATASOURCE_UNKNOWN: number;
  6212. /**
  6213. * Texture data comes from an URL
  6214. */
  6215. static DATASOURCE_URL: number;
  6216. /**
  6217. * Texture data is only used for temporary storage
  6218. */
  6219. static DATASOURCE_TEMP: number;
  6220. /**
  6221. * Texture data comes from raw data (ArrayBuffer)
  6222. */
  6223. static DATASOURCE_RAW: number;
  6224. /**
  6225. * Texture content is dynamic (video or dynamic texture)
  6226. */
  6227. static DATASOURCE_DYNAMIC: number;
  6228. /**
  6229. * Texture content is generated by rendering to it
  6230. */
  6231. static DATASOURCE_RENDERTARGET: number;
  6232. /**
  6233. * Texture content is part of a multi render target process
  6234. */
  6235. static DATASOURCE_MULTIRENDERTARGET: number;
  6236. /**
  6237. * Texture data comes from a cube data file
  6238. */
  6239. static DATASOURCE_CUBE: number;
  6240. /**
  6241. * Texture data comes from a raw cube data
  6242. */
  6243. static DATASOURCE_CUBERAW: number;
  6244. /**
  6245. * Texture data come from a prefiltered cube data file
  6246. */
  6247. static DATASOURCE_CUBEPREFILTERED: number;
  6248. /**
  6249. * Texture content is raw 3D data
  6250. */
  6251. static DATASOURCE_RAW3D: number;
  6252. /**
  6253. * Texture content is a depth texture
  6254. */
  6255. static DATASOURCE_DEPTHTEXTURE: number;
  6256. /**
  6257. * Texture data comes from a raw cube data encoded with RGBD
  6258. */
  6259. static DATASOURCE_CUBERAW_RGBD: number;
  6260. /**
  6261. * Defines if the texture is ready
  6262. */
  6263. isReady: boolean;
  6264. /**
  6265. * Defines if the texture is a cube texture
  6266. */
  6267. isCube: boolean;
  6268. /**
  6269. * Defines if the texture contains 3D data
  6270. */
  6271. is3D: boolean;
  6272. /**
  6273. * Defines if the texture contains multiview data
  6274. */
  6275. isMultiview: boolean;
  6276. /**
  6277. * Gets the URL used to load this texture
  6278. */
  6279. url: string;
  6280. /**
  6281. * Gets the sampling mode of the texture
  6282. */
  6283. samplingMode: number;
  6284. /**
  6285. * Gets a boolean indicating if the texture needs mipmaps generation
  6286. */
  6287. generateMipMaps: boolean;
  6288. /**
  6289. * Gets the number of samples used by the texture (WebGL2+ only)
  6290. */
  6291. samples: number;
  6292. /**
  6293. * Gets the type of the texture (int, float...)
  6294. */
  6295. type: number;
  6296. /**
  6297. * Gets the format of the texture (RGB, RGBA...)
  6298. */
  6299. format: number;
  6300. /**
  6301. * Observable called when the texture is loaded
  6302. */
  6303. onLoadedObservable: Observable<InternalTexture>;
  6304. /**
  6305. * Gets the width of the texture
  6306. */
  6307. width: number;
  6308. /**
  6309. * Gets the height of the texture
  6310. */
  6311. height: number;
  6312. /**
  6313. * Gets the depth of the texture
  6314. */
  6315. depth: number;
  6316. /**
  6317. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6318. */
  6319. baseWidth: number;
  6320. /**
  6321. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6322. */
  6323. baseHeight: number;
  6324. /**
  6325. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6326. */
  6327. baseDepth: number;
  6328. /**
  6329. * Gets a boolean indicating if the texture is inverted on Y axis
  6330. */
  6331. invertY: boolean;
  6332. /** @hidden */
  6333. _invertVScale: boolean;
  6334. /** @hidden */
  6335. _associatedChannel: number;
  6336. /** @hidden */
  6337. _dataSource: number;
  6338. /** @hidden */
  6339. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6340. /** @hidden */
  6341. _bufferView: Nullable<ArrayBufferView>;
  6342. /** @hidden */
  6343. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6344. /** @hidden */
  6345. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6346. /** @hidden */
  6347. _size: number;
  6348. /** @hidden */
  6349. _extension: string;
  6350. /** @hidden */
  6351. _files: Nullable<string[]>;
  6352. /** @hidden */
  6353. _workingCanvas: HTMLCanvasElement;
  6354. /** @hidden */
  6355. _workingContext: CanvasRenderingContext2D;
  6356. /** @hidden */
  6357. _framebuffer: Nullable<WebGLFramebuffer>;
  6358. /** @hidden */
  6359. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6360. /** @hidden */
  6361. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6362. /** @hidden */
  6363. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6364. /** @hidden */
  6365. _attachments: Nullable<number[]>;
  6366. /** @hidden */
  6367. _cachedCoordinatesMode: Nullable<number>;
  6368. /** @hidden */
  6369. _cachedWrapU: Nullable<number>;
  6370. /** @hidden */
  6371. _cachedWrapV: Nullable<number>;
  6372. /** @hidden */
  6373. _cachedWrapR: Nullable<number>;
  6374. /** @hidden */
  6375. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6376. /** @hidden */
  6377. _isDisabled: boolean;
  6378. /** @hidden */
  6379. _compression: Nullable<string>;
  6380. /** @hidden */
  6381. _generateStencilBuffer: boolean;
  6382. /** @hidden */
  6383. _generateDepthBuffer: boolean;
  6384. /** @hidden */
  6385. _comparisonFunction: number;
  6386. /** @hidden */
  6387. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6388. /** @hidden */
  6389. _lodGenerationScale: number;
  6390. /** @hidden */
  6391. _lodGenerationOffset: number;
  6392. /** @hidden */
  6393. _colorTextureArray: Nullable<WebGLTexture>;
  6394. /** @hidden */
  6395. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6396. /** @hidden */
  6397. _lodTextureHigh: BaseTexture;
  6398. /** @hidden */
  6399. _lodTextureMid: BaseTexture;
  6400. /** @hidden */
  6401. _lodTextureLow: BaseTexture;
  6402. /** @hidden */
  6403. _isRGBD: boolean;
  6404. /** @hidden */
  6405. _webGLTexture: Nullable<WebGLTexture>;
  6406. /** @hidden */
  6407. _references: number;
  6408. private _engine;
  6409. /**
  6410. * Gets the Engine the texture belongs to.
  6411. * @returns The babylon engine
  6412. */
  6413. getEngine(): Engine;
  6414. /**
  6415. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6416. */
  6417. readonly dataSource: number;
  6418. /**
  6419. * Creates a new InternalTexture
  6420. * @param engine defines the engine to use
  6421. * @param dataSource defines the type of data that will be used
  6422. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6423. */
  6424. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6425. /**
  6426. * Increments the number of references (ie. the number of Texture that point to it)
  6427. */
  6428. incrementReferences(): void;
  6429. /**
  6430. * Change the size of the texture (not the size of the content)
  6431. * @param width defines the new width
  6432. * @param height defines the new height
  6433. * @param depth defines the new depth (1 by default)
  6434. */
  6435. updateSize(width: int, height: int, depth?: int): void;
  6436. /** @hidden */
  6437. _rebuild(): void;
  6438. /** @hidden */
  6439. _swapAndDie(target: InternalTexture): void;
  6440. /**
  6441. * Dispose the current allocated resources
  6442. */
  6443. dispose(): void;
  6444. }
  6445. }
  6446. declare module "babylonjs/Animations/easing" {
  6447. /**
  6448. * This represents the main contract an easing function should follow.
  6449. * Easing functions are used throughout the animation system.
  6450. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6451. */
  6452. export interface IEasingFunction {
  6453. /**
  6454. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6455. * of the easing function.
  6456. * The link below provides some of the most common examples of easing functions.
  6457. * @see https://easings.net/
  6458. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6459. * @returns the corresponding value on the curve defined by the easing function
  6460. */
  6461. ease(gradient: number): number;
  6462. }
  6463. /**
  6464. * Base class used for every default easing function.
  6465. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6466. */
  6467. export class EasingFunction implements IEasingFunction {
  6468. /**
  6469. * Interpolation follows the mathematical formula associated with the easing function.
  6470. */
  6471. static readonly EASINGMODE_EASEIN: number;
  6472. /**
  6473. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6474. */
  6475. static readonly EASINGMODE_EASEOUT: number;
  6476. /**
  6477. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6478. */
  6479. static readonly EASINGMODE_EASEINOUT: number;
  6480. private _easingMode;
  6481. /**
  6482. * Sets the easing mode of the current function.
  6483. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6484. */
  6485. setEasingMode(easingMode: number): void;
  6486. /**
  6487. * Gets the current easing mode.
  6488. * @returns the easing mode
  6489. */
  6490. getEasingMode(): number;
  6491. /**
  6492. * @hidden
  6493. */
  6494. easeInCore(gradient: number): number;
  6495. /**
  6496. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6497. * of the easing function.
  6498. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6499. * @returns the corresponding value on the curve defined by the easing function
  6500. */
  6501. ease(gradient: number): number;
  6502. }
  6503. /**
  6504. * Easing function with a circle shape (see link below).
  6505. * @see https://easings.net/#easeInCirc
  6506. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6507. */
  6508. export class CircleEase extends EasingFunction implements IEasingFunction {
  6509. /** @hidden */
  6510. easeInCore(gradient: number): number;
  6511. }
  6512. /**
  6513. * Easing function with a ease back shape (see link below).
  6514. * @see https://easings.net/#easeInBack
  6515. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6516. */
  6517. export class BackEase extends EasingFunction implements IEasingFunction {
  6518. /** Defines the amplitude of the function */
  6519. amplitude: number;
  6520. /**
  6521. * Instantiates a back ease easing
  6522. * @see https://easings.net/#easeInBack
  6523. * @param amplitude Defines the amplitude of the function
  6524. */
  6525. constructor(
  6526. /** Defines the amplitude of the function */
  6527. amplitude?: number);
  6528. /** @hidden */
  6529. easeInCore(gradient: number): number;
  6530. }
  6531. /**
  6532. * Easing function with a bouncing shape (see link below).
  6533. * @see https://easings.net/#easeInBounce
  6534. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6535. */
  6536. export class BounceEase extends EasingFunction implements IEasingFunction {
  6537. /** Defines the number of bounces */
  6538. bounces: number;
  6539. /** Defines the amplitude of the bounce */
  6540. bounciness: number;
  6541. /**
  6542. * Instantiates a bounce easing
  6543. * @see https://easings.net/#easeInBounce
  6544. * @param bounces Defines the number of bounces
  6545. * @param bounciness Defines the amplitude of the bounce
  6546. */
  6547. constructor(
  6548. /** Defines the number of bounces */
  6549. bounces?: number,
  6550. /** Defines the amplitude of the bounce */
  6551. bounciness?: number);
  6552. /** @hidden */
  6553. easeInCore(gradient: number): number;
  6554. }
  6555. /**
  6556. * Easing function with a power of 3 shape (see link below).
  6557. * @see https://easings.net/#easeInCubic
  6558. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6559. */
  6560. export class CubicEase extends EasingFunction implements IEasingFunction {
  6561. /** @hidden */
  6562. easeInCore(gradient: number): number;
  6563. }
  6564. /**
  6565. * Easing function with an elastic shape (see link below).
  6566. * @see https://easings.net/#easeInElastic
  6567. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6568. */
  6569. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6570. /** Defines the number of oscillations*/
  6571. oscillations: number;
  6572. /** Defines the amplitude of the oscillations*/
  6573. springiness: number;
  6574. /**
  6575. * Instantiates an elastic easing function
  6576. * @see https://easings.net/#easeInElastic
  6577. * @param oscillations Defines the number of oscillations
  6578. * @param springiness Defines the amplitude of the oscillations
  6579. */
  6580. constructor(
  6581. /** Defines the number of oscillations*/
  6582. oscillations?: number,
  6583. /** Defines the amplitude of the oscillations*/
  6584. springiness?: number);
  6585. /** @hidden */
  6586. easeInCore(gradient: number): number;
  6587. }
  6588. /**
  6589. * Easing function with an exponential shape (see link below).
  6590. * @see https://easings.net/#easeInExpo
  6591. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6592. */
  6593. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6594. /** Defines the exponent of the function */
  6595. exponent: number;
  6596. /**
  6597. * Instantiates an exponential easing function
  6598. * @see https://easings.net/#easeInExpo
  6599. * @param exponent Defines the exponent of the function
  6600. */
  6601. constructor(
  6602. /** Defines the exponent of the function */
  6603. exponent?: number);
  6604. /** @hidden */
  6605. easeInCore(gradient: number): number;
  6606. }
  6607. /**
  6608. * Easing function with a power shape (see link below).
  6609. * @see https://easings.net/#easeInQuad
  6610. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6611. */
  6612. export class PowerEase extends EasingFunction implements IEasingFunction {
  6613. /** Defines the power of the function */
  6614. power: number;
  6615. /**
  6616. * Instantiates an power base easing function
  6617. * @see https://easings.net/#easeInQuad
  6618. * @param power Defines the power of the function
  6619. */
  6620. constructor(
  6621. /** Defines the power of the function */
  6622. power?: number);
  6623. /** @hidden */
  6624. easeInCore(gradient: number): number;
  6625. }
  6626. /**
  6627. * Easing function with a power of 2 shape (see link below).
  6628. * @see https://easings.net/#easeInQuad
  6629. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6630. */
  6631. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6632. /** @hidden */
  6633. easeInCore(gradient: number): number;
  6634. }
  6635. /**
  6636. * Easing function with a power of 4 shape (see link below).
  6637. * @see https://easings.net/#easeInQuart
  6638. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6639. */
  6640. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6641. /** @hidden */
  6642. easeInCore(gradient: number): number;
  6643. }
  6644. /**
  6645. * Easing function with a power of 5 shape (see link below).
  6646. * @see https://easings.net/#easeInQuint
  6647. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6648. */
  6649. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6650. /** @hidden */
  6651. easeInCore(gradient: number): number;
  6652. }
  6653. /**
  6654. * Easing function with a sin shape (see link below).
  6655. * @see https://easings.net/#easeInSine
  6656. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6657. */
  6658. export class SineEase extends EasingFunction implements IEasingFunction {
  6659. /** @hidden */
  6660. easeInCore(gradient: number): number;
  6661. }
  6662. /**
  6663. * Easing function with a bezier shape (see link below).
  6664. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6665. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6666. */
  6667. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6668. /** Defines the x component of the start tangent in the bezier curve */
  6669. x1: number;
  6670. /** Defines the y component of the start tangent in the bezier curve */
  6671. y1: number;
  6672. /** Defines the x component of the end tangent in the bezier curve */
  6673. x2: number;
  6674. /** Defines the y component of the end tangent in the bezier curve */
  6675. y2: number;
  6676. /**
  6677. * Instantiates a bezier function
  6678. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6679. * @param x1 Defines the x component of the start tangent in the bezier curve
  6680. * @param y1 Defines the y component of the start tangent in the bezier curve
  6681. * @param x2 Defines the x component of the end tangent in the bezier curve
  6682. * @param y2 Defines the y component of the end tangent in the bezier curve
  6683. */
  6684. constructor(
  6685. /** Defines the x component of the start tangent in the bezier curve */
  6686. x1?: number,
  6687. /** Defines the y component of the start tangent in the bezier curve */
  6688. y1?: number,
  6689. /** Defines the x component of the end tangent in the bezier curve */
  6690. x2?: number,
  6691. /** Defines the y component of the end tangent in the bezier curve */
  6692. y2?: number);
  6693. /** @hidden */
  6694. easeInCore(gradient: number): number;
  6695. }
  6696. }
  6697. declare module "babylonjs/Animations/animationKey" {
  6698. /**
  6699. * Defines an interface which represents an animation key frame
  6700. */
  6701. export interface IAnimationKey {
  6702. /**
  6703. * Frame of the key frame
  6704. */
  6705. frame: number;
  6706. /**
  6707. * Value at the specifies key frame
  6708. */
  6709. value: any;
  6710. /**
  6711. * The input tangent for the cubic hermite spline
  6712. */
  6713. inTangent?: any;
  6714. /**
  6715. * The output tangent for the cubic hermite spline
  6716. */
  6717. outTangent?: any;
  6718. /**
  6719. * The animation interpolation type
  6720. */
  6721. interpolation?: AnimationKeyInterpolation;
  6722. }
  6723. /**
  6724. * Enum for the animation key frame interpolation type
  6725. */
  6726. export enum AnimationKeyInterpolation {
  6727. /**
  6728. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6729. */
  6730. STEP = 1
  6731. }
  6732. }
  6733. declare module "babylonjs/Animations/animationRange" {
  6734. /**
  6735. * Represents the range of an animation
  6736. */
  6737. export class AnimationRange {
  6738. /**The name of the animation range**/
  6739. name: string;
  6740. /**The starting frame of the animation */
  6741. from: number;
  6742. /**The ending frame of the animation*/
  6743. to: number;
  6744. /**
  6745. * Initializes the range of an animation
  6746. * @param name The name of the animation range
  6747. * @param from The starting frame of the animation
  6748. * @param to The ending frame of the animation
  6749. */
  6750. constructor(
  6751. /**The name of the animation range**/
  6752. name: string,
  6753. /**The starting frame of the animation */
  6754. from: number,
  6755. /**The ending frame of the animation*/
  6756. to: number);
  6757. /**
  6758. * Makes a copy of the animation range
  6759. * @returns A copy of the animation range
  6760. */
  6761. clone(): AnimationRange;
  6762. }
  6763. }
  6764. declare module "babylonjs/Animations/animationEvent" {
  6765. /**
  6766. * Composed of a frame, and an action function
  6767. */
  6768. export class AnimationEvent {
  6769. /** The frame for which the event is triggered **/
  6770. frame: number;
  6771. /** The event to perform when triggered **/
  6772. action: (currentFrame: number) => void;
  6773. /** Specifies if the event should be triggered only once**/
  6774. onlyOnce?: boolean | undefined;
  6775. /**
  6776. * Specifies if the animation event is done
  6777. */
  6778. isDone: boolean;
  6779. /**
  6780. * Initializes the animation event
  6781. * @param frame The frame for which the event is triggered
  6782. * @param action The event to perform when triggered
  6783. * @param onlyOnce Specifies if the event should be triggered only once
  6784. */
  6785. constructor(
  6786. /** The frame for which the event is triggered **/
  6787. frame: number,
  6788. /** The event to perform when triggered **/
  6789. action: (currentFrame: number) => void,
  6790. /** Specifies if the event should be triggered only once**/
  6791. onlyOnce?: boolean | undefined);
  6792. /** @hidden */
  6793. _clone(): AnimationEvent;
  6794. }
  6795. }
  6796. declare module "babylonjs/Behaviors/behavior" {
  6797. import { Nullable } from "babylonjs/types";
  6798. /**
  6799. * Interface used to define a behavior
  6800. */
  6801. export interface Behavior<T> {
  6802. /** gets or sets behavior's name */
  6803. name: string;
  6804. /**
  6805. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6806. */
  6807. init(): void;
  6808. /**
  6809. * Called when the behavior is attached to a target
  6810. * @param target defines the target where the behavior is attached to
  6811. */
  6812. attach(target: T): void;
  6813. /**
  6814. * Called when the behavior is detached from its target
  6815. */
  6816. detach(): void;
  6817. }
  6818. /**
  6819. * Interface implemented by classes supporting behaviors
  6820. */
  6821. export interface IBehaviorAware<T> {
  6822. /**
  6823. * Attach a behavior
  6824. * @param behavior defines the behavior to attach
  6825. * @returns the current host
  6826. */
  6827. addBehavior(behavior: Behavior<T>): T;
  6828. /**
  6829. * Remove a behavior from the current object
  6830. * @param behavior defines the behavior to detach
  6831. * @returns the current host
  6832. */
  6833. removeBehavior(behavior: Behavior<T>): T;
  6834. /**
  6835. * Gets a behavior using its name to search
  6836. * @param name defines the name to search
  6837. * @returns the behavior or null if not found
  6838. */
  6839. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6840. }
  6841. }
  6842. declare module "babylonjs/Collisions/intersectionInfo" {
  6843. import { Nullable } from "babylonjs/types";
  6844. /**
  6845. * @hidden
  6846. */
  6847. export class IntersectionInfo {
  6848. bu: Nullable<number>;
  6849. bv: Nullable<number>;
  6850. distance: number;
  6851. faceId: number;
  6852. subMeshId: number;
  6853. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6854. }
  6855. }
  6856. declare module "babylonjs/Culling/boundingSphere" {
  6857. import { DeepImmutable } from "babylonjs/types";
  6858. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6859. /**
  6860. * Class used to store bounding sphere information
  6861. */
  6862. export class BoundingSphere {
  6863. /**
  6864. * Gets the center of the bounding sphere in local space
  6865. */
  6866. readonly center: Vector3;
  6867. /**
  6868. * Radius of the bounding sphere in local space
  6869. */
  6870. radius: number;
  6871. /**
  6872. * Gets the center of the bounding sphere in world space
  6873. */
  6874. readonly centerWorld: Vector3;
  6875. /**
  6876. * Radius of the bounding sphere in world space
  6877. */
  6878. radiusWorld: number;
  6879. /**
  6880. * Gets the minimum vector in local space
  6881. */
  6882. readonly minimum: Vector3;
  6883. /**
  6884. * Gets the maximum vector in local space
  6885. */
  6886. readonly maximum: Vector3;
  6887. private _worldMatrix;
  6888. private static readonly TmpVector3;
  6889. /**
  6890. * Creates a new bounding sphere
  6891. * @param min defines the minimum vector (in local space)
  6892. * @param max defines the maximum vector (in local space)
  6893. * @param worldMatrix defines the new world matrix
  6894. */
  6895. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6896. /**
  6897. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6898. * @param min defines the new minimum vector (in local space)
  6899. * @param max defines the new maximum vector (in local space)
  6900. * @param worldMatrix defines the new world matrix
  6901. */
  6902. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6903. /**
  6904. * Scale the current bounding sphere by applying a scale factor
  6905. * @param factor defines the scale factor to apply
  6906. * @returns the current bounding box
  6907. */
  6908. scale(factor: number): BoundingSphere;
  6909. /**
  6910. * Gets the world matrix of the bounding box
  6911. * @returns a matrix
  6912. */
  6913. getWorldMatrix(): DeepImmutable<Matrix>;
  6914. /** @hidden */
  6915. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6916. /**
  6917. * Tests if the bounding sphere is intersecting the frustum planes
  6918. * @param frustumPlanes defines the frustum planes to test
  6919. * @returns true if there is an intersection
  6920. */
  6921. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6922. /**
  6923. * Tests if the bounding sphere center is in between the frustum planes.
  6924. * Used for optimistic fast inclusion.
  6925. * @param frustumPlanes defines the frustum planes to test
  6926. * @returns true if the sphere center is in between the frustum planes
  6927. */
  6928. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6929. /**
  6930. * Tests if a point is inside the bounding sphere
  6931. * @param point defines the point to test
  6932. * @returns true if the point is inside the bounding sphere
  6933. */
  6934. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6935. /**
  6936. * Checks if two sphere intersct
  6937. * @param sphere0 sphere 0
  6938. * @param sphere1 sphere 1
  6939. * @returns true if the speres intersect
  6940. */
  6941. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6942. }
  6943. }
  6944. declare module "babylonjs/Culling/boundingBox" {
  6945. import { DeepImmutable } from "babylonjs/types";
  6946. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6947. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6948. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6949. /**
  6950. * Class used to store bounding box information
  6951. */
  6952. export class BoundingBox implements ICullable {
  6953. /**
  6954. * Gets the 8 vectors representing the bounding box in local space
  6955. */
  6956. readonly vectors: Vector3[];
  6957. /**
  6958. * Gets the center of the bounding box in local space
  6959. */
  6960. readonly center: Vector3;
  6961. /**
  6962. * Gets the center of the bounding box in world space
  6963. */
  6964. readonly centerWorld: Vector3;
  6965. /**
  6966. * Gets the extend size in local space
  6967. */
  6968. readonly extendSize: Vector3;
  6969. /**
  6970. * Gets the extend size in world space
  6971. */
  6972. readonly extendSizeWorld: Vector3;
  6973. /**
  6974. * Gets the OBB (object bounding box) directions
  6975. */
  6976. readonly directions: Vector3[];
  6977. /**
  6978. * Gets the 8 vectors representing the bounding box in world space
  6979. */
  6980. readonly vectorsWorld: Vector3[];
  6981. /**
  6982. * Gets the minimum vector in world space
  6983. */
  6984. readonly minimumWorld: Vector3;
  6985. /**
  6986. * Gets the maximum vector in world space
  6987. */
  6988. readonly maximumWorld: Vector3;
  6989. /**
  6990. * Gets the minimum vector in local space
  6991. */
  6992. readonly minimum: Vector3;
  6993. /**
  6994. * Gets the maximum vector in local space
  6995. */
  6996. readonly maximum: Vector3;
  6997. private _worldMatrix;
  6998. private static readonly TmpVector3;
  6999. /**
  7000. * @hidden
  7001. */
  7002. _tag: number;
  7003. /**
  7004. * Creates a new bounding box
  7005. * @param min defines the minimum vector (in local space)
  7006. * @param max defines the maximum vector (in local space)
  7007. * @param worldMatrix defines the new world matrix
  7008. */
  7009. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7010. /**
  7011. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7012. * @param min defines the new minimum vector (in local space)
  7013. * @param max defines the new maximum vector (in local space)
  7014. * @param worldMatrix defines the new world matrix
  7015. */
  7016. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7017. /**
  7018. * Scale the current bounding box by applying a scale factor
  7019. * @param factor defines the scale factor to apply
  7020. * @returns the current bounding box
  7021. */
  7022. scale(factor: number): BoundingBox;
  7023. /**
  7024. * Gets the world matrix of the bounding box
  7025. * @returns a matrix
  7026. */
  7027. getWorldMatrix(): DeepImmutable<Matrix>;
  7028. /** @hidden */
  7029. _update(world: DeepImmutable<Matrix>): void;
  7030. /**
  7031. * Tests if the bounding box is intersecting the frustum planes
  7032. * @param frustumPlanes defines the frustum planes to test
  7033. * @returns true if there is an intersection
  7034. */
  7035. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7036. /**
  7037. * Tests if the bounding box is entirely inside the frustum planes
  7038. * @param frustumPlanes defines the frustum planes to test
  7039. * @returns true if there is an inclusion
  7040. */
  7041. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7042. /**
  7043. * Tests if a point is inside the bounding box
  7044. * @param point defines the point to test
  7045. * @returns true if the point is inside the bounding box
  7046. */
  7047. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7048. /**
  7049. * Tests if the bounding box intersects with a bounding sphere
  7050. * @param sphere defines the sphere to test
  7051. * @returns true if there is an intersection
  7052. */
  7053. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7054. /**
  7055. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7056. * @param min defines the min vector to use
  7057. * @param max defines the max vector to use
  7058. * @returns true if there is an intersection
  7059. */
  7060. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7061. /**
  7062. * Tests if two bounding boxes are intersections
  7063. * @param box0 defines the first box to test
  7064. * @param box1 defines the second box to test
  7065. * @returns true if there is an intersection
  7066. */
  7067. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7068. /**
  7069. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7070. * @param minPoint defines the minimum vector of the bounding box
  7071. * @param maxPoint defines the maximum vector of the bounding box
  7072. * @param sphereCenter defines the sphere center
  7073. * @param sphereRadius defines the sphere radius
  7074. * @returns true if there is an intersection
  7075. */
  7076. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7077. /**
  7078. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7079. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7080. * @param frustumPlanes defines the frustum planes to test
  7081. * @return true if there is an inclusion
  7082. */
  7083. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7084. /**
  7085. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7086. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7087. * @param frustumPlanes defines the frustum planes to test
  7088. * @return true if there is an intersection
  7089. */
  7090. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7091. }
  7092. }
  7093. declare module "babylonjs/Collisions/collider" {
  7094. import { Nullable, IndicesArray } from "babylonjs/types";
  7095. import { Vector3, Plane } from "babylonjs/Maths/math";
  7096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7097. /** @hidden */
  7098. export class Collider {
  7099. /** Define if a collision was found */
  7100. collisionFound: boolean;
  7101. /**
  7102. * Define last intersection point in local space
  7103. */
  7104. intersectionPoint: Vector3;
  7105. /**
  7106. * Define last collided mesh
  7107. */
  7108. collidedMesh: Nullable<AbstractMesh>;
  7109. private _collisionPoint;
  7110. private _planeIntersectionPoint;
  7111. private _tempVector;
  7112. private _tempVector2;
  7113. private _tempVector3;
  7114. private _tempVector4;
  7115. private _edge;
  7116. private _baseToVertex;
  7117. private _destinationPoint;
  7118. private _slidePlaneNormal;
  7119. private _displacementVector;
  7120. /** @hidden */
  7121. _radius: Vector3;
  7122. /** @hidden */
  7123. _retry: number;
  7124. private _velocity;
  7125. private _basePoint;
  7126. private _epsilon;
  7127. /** @hidden */
  7128. _velocityWorldLength: number;
  7129. /** @hidden */
  7130. _basePointWorld: Vector3;
  7131. private _velocityWorld;
  7132. private _normalizedVelocity;
  7133. /** @hidden */
  7134. _initialVelocity: Vector3;
  7135. /** @hidden */
  7136. _initialPosition: Vector3;
  7137. private _nearestDistance;
  7138. private _collisionMask;
  7139. collisionMask: number;
  7140. /**
  7141. * Gets the plane normal used to compute the sliding response (in local space)
  7142. */
  7143. readonly slidePlaneNormal: Vector3;
  7144. /** @hidden */
  7145. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7146. /** @hidden */
  7147. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7148. /** @hidden */
  7149. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7150. /** @hidden */
  7151. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7152. /** @hidden */
  7153. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7154. /** @hidden */
  7155. _getResponse(pos: Vector3, vel: Vector3): void;
  7156. }
  7157. }
  7158. declare module "babylonjs/Culling/boundingInfo" {
  7159. import { DeepImmutable } from "babylonjs/types";
  7160. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7161. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7162. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7163. import { Collider } from "babylonjs/Collisions/collider";
  7164. /**
  7165. * Interface for cullable objects
  7166. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7167. */
  7168. export interface ICullable {
  7169. /**
  7170. * Checks if the object or part of the object is in the frustum
  7171. * @param frustumPlanes Camera near/planes
  7172. * @returns true if the object is in frustum otherwise false
  7173. */
  7174. isInFrustum(frustumPlanes: Plane[]): boolean;
  7175. /**
  7176. * Checks if a cullable object (mesh...) is in the camera frustum
  7177. * Unlike isInFrustum this cheks the full bounding box
  7178. * @param frustumPlanes Camera near/planes
  7179. * @returns true if the object is in frustum otherwise false
  7180. */
  7181. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7182. }
  7183. /**
  7184. * Info for a bounding data of a mesh
  7185. */
  7186. export class BoundingInfo implements ICullable {
  7187. /**
  7188. * Bounding box for the mesh
  7189. */
  7190. readonly boundingBox: BoundingBox;
  7191. /**
  7192. * Bounding sphere for the mesh
  7193. */
  7194. readonly boundingSphere: BoundingSphere;
  7195. private _isLocked;
  7196. private static readonly TmpVector3;
  7197. /**
  7198. * Constructs bounding info
  7199. * @param minimum min vector of the bounding box/sphere
  7200. * @param maximum max vector of the bounding box/sphere
  7201. * @param worldMatrix defines the new world matrix
  7202. */
  7203. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7204. /**
  7205. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7206. * @param min defines the new minimum vector (in local space)
  7207. * @param max defines the new maximum vector (in local space)
  7208. * @param worldMatrix defines the new world matrix
  7209. */
  7210. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7211. /**
  7212. * min vector of the bounding box/sphere
  7213. */
  7214. readonly minimum: Vector3;
  7215. /**
  7216. * max vector of the bounding box/sphere
  7217. */
  7218. readonly maximum: Vector3;
  7219. /**
  7220. * If the info is locked and won't be updated to avoid perf overhead
  7221. */
  7222. isLocked: boolean;
  7223. /**
  7224. * Updates the bounding sphere and box
  7225. * @param world world matrix to be used to update
  7226. */
  7227. update(world: DeepImmutable<Matrix>): void;
  7228. /**
  7229. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7230. * @param center New center of the bounding info
  7231. * @param extend New extend of the bounding info
  7232. * @returns the current bounding info
  7233. */
  7234. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7235. /**
  7236. * Scale the current bounding info by applying a scale factor
  7237. * @param factor defines the scale factor to apply
  7238. * @returns the current bounding info
  7239. */
  7240. scale(factor: number): BoundingInfo;
  7241. /**
  7242. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7243. * @param frustumPlanes defines the frustum to test
  7244. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7245. * @returns true if the bounding info is in the frustum planes
  7246. */
  7247. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7248. /**
  7249. * Gets the world distance between the min and max points of the bounding box
  7250. */
  7251. readonly diagonalLength: number;
  7252. /**
  7253. * Checks if a cullable object (mesh...) is in the camera frustum
  7254. * Unlike isInFrustum this cheks the full bounding box
  7255. * @param frustumPlanes Camera near/planes
  7256. * @returns true if the object is in frustum otherwise false
  7257. */
  7258. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7259. /** @hidden */
  7260. _checkCollision(collider: Collider): boolean;
  7261. /**
  7262. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7263. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7264. * @param point the point to check intersection with
  7265. * @returns if the point intersects
  7266. */
  7267. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7268. /**
  7269. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7270. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7271. * @param boundingInfo the bounding info to check intersection with
  7272. * @param precise if the intersection should be done using OBB
  7273. * @returns if the bounding info intersects
  7274. */
  7275. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7276. }
  7277. }
  7278. declare module "babylonjs/Misc/smartArray" {
  7279. /**
  7280. * Defines an array and its length.
  7281. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7282. */
  7283. export interface ISmartArrayLike<T> {
  7284. /**
  7285. * The data of the array.
  7286. */
  7287. data: Array<T>;
  7288. /**
  7289. * The active length of the array.
  7290. */
  7291. length: number;
  7292. }
  7293. /**
  7294. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7295. */
  7296. export class SmartArray<T> implements ISmartArrayLike<T> {
  7297. /**
  7298. * The full set of data from the array.
  7299. */
  7300. data: Array<T>;
  7301. /**
  7302. * The active length of the array.
  7303. */
  7304. length: number;
  7305. protected _id: number;
  7306. /**
  7307. * Instantiates a Smart Array.
  7308. * @param capacity defines the default capacity of the array.
  7309. */
  7310. constructor(capacity: number);
  7311. /**
  7312. * Pushes a value at the end of the active data.
  7313. * @param value defines the object to push in the array.
  7314. */
  7315. push(value: T): void;
  7316. /**
  7317. * Iterates over the active data and apply the lambda to them.
  7318. * @param func defines the action to apply on each value.
  7319. */
  7320. forEach(func: (content: T) => void): void;
  7321. /**
  7322. * Sorts the full sets of data.
  7323. * @param compareFn defines the comparison function to apply.
  7324. */
  7325. sort(compareFn: (a: T, b: T) => number): void;
  7326. /**
  7327. * Resets the active data to an empty array.
  7328. */
  7329. reset(): void;
  7330. /**
  7331. * Releases all the data from the array as well as the array.
  7332. */
  7333. dispose(): void;
  7334. /**
  7335. * Concats the active data with a given array.
  7336. * @param array defines the data to concatenate with.
  7337. */
  7338. concat(array: any): void;
  7339. /**
  7340. * Returns the position of a value in the active data.
  7341. * @param value defines the value to find the index for
  7342. * @returns the index if found in the active data otherwise -1
  7343. */
  7344. indexOf(value: T): number;
  7345. /**
  7346. * Returns whether an element is part of the active data.
  7347. * @param value defines the value to look for
  7348. * @returns true if found in the active data otherwise false
  7349. */
  7350. contains(value: T): boolean;
  7351. private static _GlobalId;
  7352. }
  7353. /**
  7354. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7355. * The data in this array can only be present once
  7356. */
  7357. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7358. private _duplicateId;
  7359. /**
  7360. * Pushes a value at the end of the active data.
  7361. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7362. * @param value defines the object to push in the array.
  7363. */
  7364. push(value: T): void;
  7365. /**
  7366. * Pushes a value at the end of the active data.
  7367. * If the data is already present, it won t be added again
  7368. * @param value defines the object to push in the array.
  7369. * @returns true if added false if it was already present
  7370. */
  7371. pushNoDuplicate(value: T): boolean;
  7372. /**
  7373. * Resets the active data to an empty array.
  7374. */
  7375. reset(): void;
  7376. /**
  7377. * Concats the active data with a given array.
  7378. * This ensures no dupplicate will be present in the result.
  7379. * @param array defines the data to concatenate with.
  7380. */
  7381. concatWithNoDuplicate(array: any): void;
  7382. }
  7383. }
  7384. declare module "babylonjs/Materials/multiMaterial" {
  7385. import { Nullable } from "babylonjs/types";
  7386. import { Scene } from "babylonjs/scene";
  7387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7388. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7390. import { Material } from "babylonjs/Materials/material";
  7391. /**
  7392. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7393. * separate meshes. This can be use to improve performances.
  7394. * @see http://doc.babylonjs.com/how_to/multi_materials
  7395. */
  7396. export class MultiMaterial extends Material {
  7397. private _subMaterials;
  7398. /**
  7399. * Gets or Sets the list of Materials used within the multi material.
  7400. * They need to be ordered according to the submeshes order in the associated mesh
  7401. */
  7402. subMaterials: Nullable<Material>[];
  7403. /**
  7404. * Function used to align with Node.getChildren()
  7405. * @returns the list of Materials used within the multi material
  7406. */
  7407. getChildren(): Nullable<Material>[];
  7408. /**
  7409. * Instantiates a new Multi Material
  7410. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7411. * separate meshes. This can be use to improve performances.
  7412. * @see http://doc.babylonjs.com/how_to/multi_materials
  7413. * @param name Define the name in the scene
  7414. * @param scene Define the scene the material belongs to
  7415. */
  7416. constructor(name: string, scene: Scene);
  7417. private _hookArray;
  7418. /**
  7419. * Get one of the submaterial by its index in the submaterials array
  7420. * @param index The index to look the sub material at
  7421. * @returns The Material if the index has been defined
  7422. */
  7423. getSubMaterial(index: number): Nullable<Material>;
  7424. /**
  7425. * Get the list of active textures for the whole sub materials list.
  7426. * @returns All the textures that will be used during the rendering
  7427. */
  7428. getActiveTextures(): BaseTexture[];
  7429. /**
  7430. * Gets the current class name of the material e.g. "MultiMaterial"
  7431. * Mainly use in serialization.
  7432. * @returns the class name
  7433. */
  7434. getClassName(): string;
  7435. /**
  7436. * Checks if the material is ready to render the requested sub mesh
  7437. * @param mesh Define the mesh the submesh belongs to
  7438. * @param subMesh Define the sub mesh to look readyness for
  7439. * @param useInstances Define whether or not the material is used with instances
  7440. * @returns true if ready, otherwise false
  7441. */
  7442. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7443. /**
  7444. * Clones the current material and its related sub materials
  7445. * @param name Define the name of the newly cloned material
  7446. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7447. * @returns the cloned material
  7448. */
  7449. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7450. /**
  7451. * Serializes the materials into a JSON representation.
  7452. * @returns the JSON representation
  7453. */
  7454. serialize(): any;
  7455. /**
  7456. * Dispose the material and release its associated resources
  7457. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  7458. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  7459. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  7460. */
  7461. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7462. /**
  7463. * Creates a MultiMaterial from parsed MultiMaterial data.
  7464. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7465. * @param scene defines the hosting scene
  7466. * @returns a new MultiMaterial
  7467. */
  7468. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7469. }
  7470. }
  7471. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7472. /**
  7473. * Class used to represent data loading progression
  7474. */
  7475. export class SceneLoaderFlags {
  7476. private static _ForceFullSceneLoadingForIncremental;
  7477. private static _ShowLoadingScreen;
  7478. private static _CleanBoneMatrixWeights;
  7479. private static _loggingLevel;
  7480. /**
  7481. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7482. */
  7483. static ForceFullSceneLoadingForIncremental: boolean;
  7484. /**
  7485. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7486. */
  7487. static ShowLoadingScreen: boolean;
  7488. /**
  7489. * Defines the current logging level (while loading the scene)
  7490. * @ignorenaming
  7491. */
  7492. static loggingLevel: number;
  7493. /**
  7494. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7495. */
  7496. static CleanBoneMatrixWeights: boolean;
  7497. }
  7498. }
  7499. declare module "babylonjs/Meshes/transformNode" {
  7500. import { DeepImmutable } from "babylonjs/types";
  7501. import { Observable } from "babylonjs/Misc/observable";
  7502. import { Nullable } from "babylonjs/types";
  7503. import { Camera } from "babylonjs/Cameras/camera";
  7504. import { Scene } from "babylonjs/scene";
  7505. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7506. import { Node } from "babylonjs/node";
  7507. import { Bone } from "babylonjs/Bones/bone";
  7508. /**
  7509. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  7510. * @see https://doc.babylonjs.com/how_to/transformnode
  7511. */
  7512. export class TransformNode extends Node {
  7513. /**
  7514. * Object will not rotate to face the camera
  7515. */
  7516. static BILLBOARDMODE_NONE: number;
  7517. /**
  7518. * Object will rotate to face the camera but only on the x axis
  7519. */
  7520. static BILLBOARDMODE_X: number;
  7521. /**
  7522. * Object will rotate to face the camera but only on the y axis
  7523. */
  7524. static BILLBOARDMODE_Y: number;
  7525. /**
  7526. * Object will rotate to face the camera but only on the z axis
  7527. */
  7528. static BILLBOARDMODE_Z: number;
  7529. /**
  7530. * Object will rotate to face the camera
  7531. */
  7532. static BILLBOARDMODE_ALL: number;
  7533. private _forward;
  7534. private _forwardInverted;
  7535. private _up;
  7536. private _right;
  7537. private _rightInverted;
  7538. private _position;
  7539. private _rotation;
  7540. private _rotationQuaternion;
  7541. protected _scaling: Vector3;
  7542. protected _isDirty: boolean;
  7543. private _transformToBoneReferal;
  7544. private _billboardMode;
  7545. /**
  7546. * Gets or sets the billboard mode. Default is 0.
  7547. *
  7548. * | Value | Type | Description |
  7549. * | --- | --- | --- |
  7550. * | 0 | BILLBOARDMODE_NONE | |
  7551. * | 1 | BILLBOARDMODE_X | |
  7552. * | 2 | BILLBOARDMODE_Y | |
  7553. * | 4 | BILLBOARDMODE_Z | |
  7554. * | 7 | BILLBOARDMODE_ALL | |
  7555. *
  7556. */
  7557. billboardMode: number;
  7558. private _preserveParentRotationForBillboard;
  7559. /**
  7560. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7561. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7562. */
  7563. preserveParentRotationForBillboard: boolean;
  7564. /**
  7565. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  7566. */
  7567. scalingDeterminant: number;
  7568. /**
  7569. * Sets the distance of the object to max, often used by skybox
  7570. */
  7571. infiniteDistance: boolean;
  7572. /**
  7573. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7574. * By default the system will update normals to compensate
  7575. */
  7576. ignoreNonUniformScaling: boolean;
  7577. /**
  7578. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  7579. */
  7580. reIntegrateRotationIntoRotationQuaternion: boolean;
  7581. /** @hidden */
  7582. _poseMatrix: Matrix;
  7583. /** @hidden */
  7584. _localMatrix: Matrix;
  7585. private _absolutePosition;
  7586. private _pivotMatrix;
  7587. private _pivotMatrixInverse;
  7588. protected _postMultiplyPivotMatrix: boolean;
  7589. protected _isWorldMatrixFrozen: boolean;
  7590. /** @hidden */
  7591. _indexInSceneTransformNodesArray: number;
  7592. private _connectBillboardProcessors;
  7593. /**
  7594. * An event triggered after the world matrix is updated
  7595. */
  7596. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7597. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7598. /**
  7599. * Gets a string identifying the name of the class
  7600. * @returns "TransformNode" string
  7601. */
  7602. getClassName(): string;
  7603. /**
  7604. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7605. */
  7606. position: Vector3;
  7607. /**
  7608. * 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)).
  7609. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7610. */
  7611. rotation: Vector3;
  7612. /**
  7613. * 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)).
  7614. */
  7615. scaling: Vector3;
  7616. /**
  7617. * 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).
  7618. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7619. */
  7620. rotationQuaternion: Nullable<Quaternion>;
  7621. /**
  7622. * The forward direction of that transform in world space.
  7623. */
  7624. readonly forward: Vector3;
  7625. /**
  7626. * The up direction of that transform in world space.
  7627. */
  7628. readonly up: Vector3;
  7629. /**
  7630. * The right direction of that transform in world space.
  7631. */
  7632. readonly right: Vector3;
  7633. /**
  7634. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7635. * @param matrix the matrix to copy the pose from
  7636. * @returns this TransformNode.
  7637. */
  7638. updatePoseMatrix(matrix: Matrix): TransformNode;
  7639. /**
  7640. * Returns the mesh Pose matrix.
  7641. * @returns the pose matrix
  7642. */
  7643. getPoseMatrix(): Matrix;
  7644. /** @hidden */
  7645. _isSynchronized(): boolean;
  7646. /** @hidden */
  7647. _initCache(): void;
  7648. /**
  7649. * Flag the transform node as dirty (Forcing it to update everything)
  7650. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7651. * @returns this transform node
  7652. */
  7653. markAsDirty(property: string): TransformNode;
  7654. /**
  7655. * Returns the current mesh absolute position.
  7656. * Returns a Vector3.
  7657. */
  7658. readonly absolutePosition: Vector3;
  7659. /**
  7660. * Sets a new matrix to apply before all other transformation
  7661. * @param matrix defines the transform matrix
  7662. * @returns the current TransformNode
  7663. */
  7664. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7665. /**
  7666. * Sets a new pivot matrix to the current node
  7667. * @param matrix defines the new pivot matrix to use
  7668. * @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
  7669. * @returns the current TransformNode
  7670. */
  7671. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7672. /**
  7673. * Returns the mesh pivot matrix.
  7674. * Default : Identity.
  7675. * @returns the matrix
  7676. */
  7677. getPivotMatrix(): Matrix;
  7678. /**
  7679. * Prevents the World matrix to be computed any longer.
  7680. * @returns the TransformNode.
  7681. */
  7682. freezeWorldMatrix(): TransformNode;
  7683. /**
  7684. * Allows back the World matrix computation.
  7685. * @returns the TransformNode.
  7686. */
  7687. unfreezeWorldMatrix(): this;
  7688. /**
  7689. * True if the World matrix has been frozen.
  7690. */
  7691. readonly isWorldMatrixFrozen: boolean;
  7692. /**
  7693. * Retuns the mesh absolute position in the World.
  7694. * @returns a Vector3.
  7695. */
  7696. getAbsolutePosition(): Vector3;
  7697. /**
  7698. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7699. * @param absolutePosition the absolute position to set
  7700. * @returns the TransformNode.
  7701. */
  7702. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7703. /**
  7704. * Sets the mesh position in its local space.
  7705. * @param vector3 the position to set in localspace
  7706. * @returns the TransformNode.
  7707. */
  7708. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7709. /**
  7710. * Returns the mesh position in the local space from the current World matrix values.
  7711. * @returns a new Vector3.
  7712. */
  7713. getPositionExpressedInLocalSpace(): Vector3;
  7714. /**
  7715. * Translates the mesh along the passed Vector3 in its local space.
  7716. * @param vector3 the distance to translate in localspace
  7717. * @returns the TransformNode.
  7718. */
  7719. locallyTranslate(vector3: Vector3): TransformNode;
  7720. private static _lookAtVectorCache;
  7721. /**
  7722. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7723. * @param targetPoint the position (must be in same space as current mesh) to look at
  7724. * @param yawCor optional yaw (y-axis) correction in radians
  7725. * @param pitchCor optional pitch (x-axis) correction in radians
  7726. * @param rollCor optional roll (z-axis) correction in radians
  7727. * @param space the choosen space of the target
  7728. * @returns the TransformNode.
  7729. */
  7730. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7731. /**
  7732. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7733. * This Vector3 is expressed in the World space.
  7734. * @param localAxis axis to rotate
  7735. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7736. */
  7737. getDirection(localAxis: Vector3): Vector3;
  7738. /**
  7739. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7740. * localAxis is expressed in the mesh local space.
  7741. * result is computed in the Wordl space from the mesh World matrix.
  7742. * @param localAxis axis to rotate
  7743. * @param result the resulting transformnode
  7744. * @returns this TransformNode.
  7745. */
  7746. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7747. /**
  7748. * Sets this transform node rotation to the given local axis.
  7749. * @param localAxis the axis in local space
  7750. * @param yawCor optional yaw (y-axis) correction in radians
  7751. * @param pitchCor optional pitch (x-axis) correction in radians
  7752. * @param rollCor optional roll (z-axis) correction in radians
  7753. * @returns this TransformNode
  7754. */
  7755. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7756. /**
  7757. * Sets a new pivot point to the current node
  7758. * @param point defines the new pivot point to use
  7759. * @param space defines if the point is in world or local space (local by default)
  7760. * @returns the current TransformNode
  7761. */
  7762. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7763. /**
  7764. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7765. * @returns the pivot point
  7766. */
  7767. getPivotPoint(): Vector3;
  7768. /**
  7769. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7770. * @param result the vector3 to store the result
  7771. * @returns this TransformNode.
  7772. */
  7773. getPivotPointToRef(result: Vector3): TransformNode;
  7774. /**
  7775. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7776. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7777. */
  7778. getAbsolutePivotPoint(): Vector3;
  7779. /**
  7780. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7781. * @param result vector3 to store the result
  7782. * @returns this TransformNode.
  7783. */
  7784. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7785. /**
  7786. * Defines the passed node as the parent of the current node.
  7787. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7788. * @see https://doc.babylonjs.com/how_to/parenting
  7789. * @param node the node ot set as the parent
  7790. * @returns this TransformNode.
  7791. */
  7792. setParent(node: Nullable<Node>): TransformNode;
  7793. private _nonUniformScaling;
  7794. /**
  7795. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7796. */
  7797. readonly nonUniformScaling: boolean;
  7798. /** @hidden */
  7799. _updateNonUniformScalingState(value: boolean): boolean;
  7800. /**
  7801. * Attach the current TransformNode to another TransformNode associated with a bone
  7802. * @param bone Bone affecting the TransformNode
  7803. * @param affectedTransformNode TransformNode associated with the bone
  7804. * @returns this object
  7805. */
  7806. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7807. /**
  7808. * Detach the transform node if its associated with a bone
  7809. * @returns this object
  7810. */
  7811. detachFromBone(): TransformNode;
  7812. private static _rotationAxisCache;
  7813. /**
  7814. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7815. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7816. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7817. * The passed axis is also normalized.
  7818. * @param axis the axis to rotate around
  7819. * @param amount the amount to rotate in radians
  7820. * @param space Space to rotate in (Default: local)
  7821. * @returns the TransformNode.
  7822. */
  7823. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7824. /**
  7825. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7826. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7827. * The passed axis is also normalized. .
  7828. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7829. * @param point the point to rotate around
  7830. * @param axis the axis to rotate around
  7831. * @param amount the amount to rotate in radians
  7832. * @returns the TransformNode
  7833. */
  7834. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7835. /**
  7836. * Translates the mesh along the axis vector for the passed distance in the given space.
  7837. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7838. * @param axis the axis to translate in
  7839. * @param distance the distance to translate
  7840. * @param space Space to rotate in (Default: local)
  7841. * @returns the TransformNode.
  7842. */
  7843. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7844. /**
  7845. * Adds a rotation step to the mesh current rotation.
  7846. * x, y, z are Euler angles expressed in radians.
  7847. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7848. * This means this rotation is made in the mesh local space only.
  7849. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7850. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7851. * ```javascript
  7852. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7853. * ```
  7854. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7855. * 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.
  7856. * @param x Rotation to add
  7857. * @param y Rotation to add
  7858. * @param z Rotation to add
  7859. * @returns the TransformNode.
  7860. */
  7861. addRotation(x: number, y: number, z: number): TransformNode;
  7862. /**
  7863. * @hidden
  7864. */
  7865. protected _getEffectiveParent(): Nullable<Node>;
  7866. private _activeCompositionProcess;
  7867. private _defaultCompositionProcessor;
  7868. private _pivotCompositionProcessor;
  7869. private _activeParentProcessor;
  7870. private _activeBillboardPostProcessor;
  7871. private _defaultParentProcessor;
  7872. private _billboardParentProcessor;
  7873. private _billboardPostProcessor;
  7874. /**
  7875. * Computes the world matrix of the node
  7876. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7877. * @returns the world matrix
  7878. */
  7879. computeWorldMatrix(force?: boolean): Matrix;
  7880. protected _afterComputeWorldMatrix(): void;
  7881. /**
  7882. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7883. * @param func callback function to add
  7884. *
  7885. * @returns the TransformNode.
  7886. */
  7887. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7888. /**
  7889. * Removes a registered callback function.
  7890. * @param func callback function to remove
  7891. * @returns the TransformNode.
  7892. */
  7893. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7894. /**
  7895. * Gets the position of the current mesh in camera space
  7896. * @param camera defines the camera to use
  7897. * @returns a position
  7898. */
  7899. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7900. /**
  7901. * Returns the distance from the mesh to the active camera
  7902. * @param camera defines the camera to use
  7903. * @returns the distance
  7904. */
  7905. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7906. /**
  7907. * Clone the current transform node
  7908. * @param name Name of the new clone
  7909. * @param newParent New parent for the clone
  7910. * @param doNotCloneChildren Do not clone children hierarchy
  7911. * @returns the new transform node
  7912. */
  7913. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7914. /**
  7915. * Serializes the objects information.
  7916. * @param currentSerializationObject defines the object to serialize in
  7917. * @returns the serialized object
  7918. */
  7919. serialize(currentSerializationObject?: any): any;
  7920. /**
  7921. * Returns a new TransformNode object parsed from the source provided.
  7922. * @param parsedTransformNode is the source.
  7923. * @param scene the scne the object belongs to
  7924. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7925. * @returns a new TransformNode object parsed from the source provided.
  7926. */
  7927. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7928. /**
  7929. * Get all child-transformNodes of this node
  7930. * @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
  7931. * @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
  7932. * @returns an array of TransformNode
  7933. */
  7934. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7935. /**
  7936. * Releases resources associated with this transform node.
  7937. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7938. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7939. */
  7940. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7941. }
  7942. }
  7943. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7944. /**
  7945. * Class used to override all child animations of a given target
  7946. */
  7947. export class AnimationPropertiesOverride {
  7948. /**
  7949. * Gets or sets a value indicating if animation blending must be used
  7950. */
  7951. enableBlending: boolean;
  7952. /**
  7953. * Gets or sets the blending speed to use when enableBlending is true
  7954. */
  7955. blendingSpeed: number;
  7956. /**
  7957. * Gets or sets the default loop mode to use
  7958. */
  7959. loopMode: number;
  7960. }
  7961. }
  7962. declare module "babylonjs/Bones/bone" {
  7963. import { Skeleton } from "babylonjs/Bones/skeleton";
  7964. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7965. import { Nullable } from "babylonjs/types";
  7966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7967. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7968. import { Node } from "babylonjs/node";
  7969. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7970. /**
  7971. * Class used to store bone information
  7972. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7973. */
  7974. export class Bone extends Node {
  7975. /**
  7976. * defines the bone name
  7977. */
  7978. name: string;
  7979. private static _tmpVecs;
  7980. private static _tmpQuat;
  7981. private static _tmpMats;
  7982. /**
  7983. * Gets the list of child bones
  7984. */
  7985. children: Bone[];
  7986. /** Gets the animations associated with this bone */
  7987. animations: import("babylonjs/Animations/animation").Animation[];
  7988. /**
  7989. * Gets or sets bone length
  7990. */
  7991. length: number;
  7992. /**
  7993. * @hidden Internal only
  7994. * Set this value to map this bone to a different index in the transform matrices
  7995. * Set this value to -1 to exclude the bone from the transform matrices
  7996. */
  7997. _index: Nullable<number>;
  7998. private _skeleton;
  7999. private _localMatrix;
  8000. private _restPose;
  8001. private _baseMatrix;
  8002. private _absoluteTransform;
  8003. private _invertedAbsoluteTransform;
  8004. private _parent;
  8005. private _scalingDeterminant;
  8006. private _worldTransform;
  8007. private _localScaling;
  8008. private _localRotation;
  8009. private _localPosition;
  8010. private _needToDecompose;
  8011. private _needToCompose;
  8012. /** @hidden */
  8013. _linkedTransformNode: Nullable<TransformNode>;
  8014. /** @hidden */
  8015. /** @hidden */
  8016. _matrix: Matrix;
  8017. /**
  8018. * Create a new bone
  8019. * @param name defines the bone name
  8020. * @param skeleton defines the parent skeleton
  8021. * @param parentBone defines the parent (can be null if the bone is the root)
  8022. * @param localMatrix defines the local matrix
  8023. * @param restPose defines the rest pose matrix
  8024. * @param baseMatrix defines the base matrix
  8025. * @param index defines index of the bone in the hiearchy
  8026. */
  8027. constructor(
  8028. /**
  8029. * defines the bone name
  8030. */
  8031. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8032. /**
  8033. * Gets the current object class name.
  8034. * @return the class name
  8035. */
  8036. getClassName(): string;
  8037. /**
  8038. * Gets the parent skeleton
  8039. * @returns a skeleton
  8040. */
  8041. getSkeleton(): Skeleton;
  8042. /**
  8043. * Gets parent bone
  8044. * @returns a bone or null if the bone is the root of the bone hierarchy
  8045. */
  8046. getParent(): Nullable<Bone>;
  8047. /**
  8048. * Returns an array containing the root bones
  8049. * @returns an array containing the root bones
  8050. */
  8051. getChildren(): Array<Bone>;
  8052. /**
  8053. * Sets the parent bone
  8054. * @param parent defines the parent (can be null if the bone is the root)
  8055. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8056. */
  8057. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8058. /**
  8059. * Gets the local matrix
  8060. * @returns a matrix
  8061. */
  8062. getLocalMatrix(): Matrix;
  8063. /**
  8064. * Gets the base matrix (initial matrix which remains unchanged)
  8065. * @returns a matrix
  8066. */
  8067. getBaseMatrix(): Matrix;
  8068. /**
  8069. * Gets the rest pose matrix
  8070. * @returns a matrix
  8071. */
  8072. getRestPose(): Matrix;
  8073. /**
  8074. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8075. */
  8076. getWorldMatrix(): Matrix;
  8077. /**
  8078. * Sets the local matrix to rest pose matrix
  8079. */
  8080. returnToRest(): void;
  8081. /**
  8082. * Gets the inverse of the absolute transform matrix.
  8083. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8084. * @returns a matrix
  8085. */
  8086. getInvertedAbsoluteTransform(): Matrix;
  8087. /**
  8088. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8089. * @returns a matrix
  8090. */
  8091. getAbsoluteTransform(): Matrix;
  8092. /**
  8093. * Links with the given transform node.
  8094. * The local matrix of this bone is copied from the transform node every frame.
  8095. * @param transformNode defines the transform node to link to
  8096. */
  8097. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8098. /** Gets or sets current position (in local space) */
  8099. position: Vector3;
  8100. /** Gets or sets current rotation (in local space) */
  8101. rotation: Vector3;
  8102. /** Gets or sets current rotation quaternion (in local space) */
  8103. rotationQuaternion: Quaternion;
  8104. /** Gets or sets current scaling (in local space) */
  8105. scaling: Vector3;
  8106. /**
  8107. * Gets the animation properties override
  8108. */
  8109. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8110. private _decompose;
  8111. private _compose;
  8112. /**
  8113. * Update the base and local matrices
  8114. * @param matrix defines the new base or local matrix
  8115. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8116. * @param updateLocalMatrix defines if the local matrix should be updated
  8117. */
  8118. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8119. /** @hidden */
  8120. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8121. /**
  8122. * Flag the bone as dirty (Forcing it to update everything)
  8123. */
  8124. markAsDirty(): void;
  8125. private _markAsDirtyAndCompose;
  8126. private _markAsDirtyAndDecompose;
  8127. /**
  8128. * Translate the bone in local or world space
  8129. * @param vec The amount to translate the bone
  8130. * @param space The space that the translation is in
  8131. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8132. */
  8133. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8134. /**
  8135. * Set the postion of the bone in local or world space
  8136. * @param position The position to set the bone
  8137. * @param space The space that the position is in
  8138. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8139. */
  8140. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8141. /**
  8142. * Set the absolute position of the bone (world space)
  8143. * @param position The position to set the bone
  8144. * @param mesh The mesh that this bone is attached to
  8145. */
  8146. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8147. /**
  8148. * Scale the bone on the x, y and z axes (in local space)
  8149. * @param x The amount to scale the bone on the x axis
  8150. * @param y The amount to scale the bone on the y axis
  8151. * @param z The amount to scale the bone on the z axis
  8152. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8153. */
  8154. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8155. /**
  8156. * Set the bone scaling in local space
  8157. * @param scale defines the scaling vector
  8158. */
  8159. setScale(scale: Vector3): void;
  8160. /**
  8161. * Gets the current scaling in local space
  8162. * @returns the current scaling vector
  8163. */
  8164. getScale(): Vector3;
  8165. /**
  8166. * Gets the current scaling in local space and stores it in a target vector
  8167. * @param result defines the target vector
  8168. */
  8169. getScaleToRef(result: Vector3): void;
  8170. /**
  8171. * Set the yaw, pitch, and roll of the bone in local or world space
  8172. * @param yaw The rotation of the bone on the y axis
  8173. * @param pitch The rotation of the bone on the x axis
  8174. * @param roll The rotation of the bone on the z axis
  8175. * @param space The space that the axes of rotation are in
  8176. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8177. */
  8178. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8179. /**
  8180. * Add a rotation to the bone on an axis in local or world space
  8181. * @param axis The axis to rotate the bone on
  8182. * @param amount The amount to rotate the bone
  8183. * @param space The space that the axis is in
  8184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8185. */
  8186. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8187. /**
  8188. * Set the rotation of the bone to a particular axis angle in local or world space
  8189. * @param axis The axis to rotate the bone on
  8190. * @param angle The angle that the bone should be rotated to
  8191. * @param space The space that the axis is in
  8192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8193. */
  8194. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8195. /**
  8196. * Set the euler rotation of the bone in local of world space
  8197. * @param rotation The euler rotation that the bone should be set to
  8198. * @param space The space that the rotation is in
  8199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8200. */
  8201. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8202. /**
  8203. * Set the quaternion rotation of the bone in local of world space
  8204. * @param quat The quaternion rotation that the bone should be set to
  8205. * @param space The space that the rotation is in
  8206. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8207. */
  8208. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8209. /**
  8210. * Set the rotation matrix of the bone in local of world space
  8211. * @param rotMat The rotation matrix that the bone should be set to
  8212. * @param space The space that the rotation is in
  8213. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8214. */
  8215. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8216. private _rotateWithMatrix;
  8217. private _getNegativeRotationToRef;
  8218. /**
  8219. * Get the position of the bone in local or world space
  8220. * @param space The space that the returned position is in
  8221. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8222. * @returns The position of the bone
  8223. */
  8224. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8225. /**
  8226. * Copy the position of the bone to a vector3 in local or world space
  8227. * @param space The space that the returned position is in
  8228. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8229. * @param result The vector3 to copy the position to
  8230. */
  8231. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8232. /**
  8233. * Get the absolute position of the bone (world space)
  8234. * @param mesh The mesh that this bone is attached to
  8235. * @returns The absolute position of the bone
  8236. */
  8237. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8238. /**
  8239. * Copy the absolute position of the bone (world space) to the result param
  8240. * @param mesh The mesh that this bone is attached to
  8241. * @param result The vector3 to copy the absolute position to
  8242. */
  8243. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8244. /**
  8245. * Compute the absolute transforms of this bone and its children
  8246. */
  8247. computeAbsoluteTransforms(): void;
  8248. /**
  8249. * Get the world direction from an axis that is in the local space of the bone
  8250. * @param localAxis The local direction that is used to compute the world direction
  8251. * @param mesh The mesh that this bone is attached to
  8252. * @returns The world direction
  8253. */
  8254. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8255. /**
  8256. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8257. * @param localAxis The local direction that is used to compute the world direction
  8258. * @param mesh The mesh that this bone is attached to
  8259. * @param result The vector3 that the world direction will be copied to
  8260. */
  8261. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8262. /**
  8263. * Get the euler rotation of the bone in local or world space
  8264. * @param space The space that the rotation should be in
  8265. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8266. * @returns The euler rotation
  8267. */
  8268. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8269. /**
  8270. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8271. * @param space The space that the rotation should be in
  8272. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8273. * @param result The vector3 that the rotation should be copied to
  8274. */
  8275. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8276. /**
  8277. * Get the quaternion rotation of the bone in either local or world space
  8278. * @param space The space that the rotation should be in
  8279. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8280. * @returns The quaternion rotation
  8281. */
  8282. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8283. /**
  8284. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8285. * @param space The space that the rotation should be in
  8286. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8287. * @param result The quaternion that the rotation should be copied to
  8288. */
  8289. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8290. /**
  8291. * Get the rotation matrix of the bone in local or world space
  8292. * @param space The space that the rotation should be in
  8293. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8294. * @returns The rotation matrix
  8295. */
  8296. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8297. /**
  8298. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8299. * @param space The space that the rotation should be in
  8300. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8301. * @param result The quaternion that the rotation should be copied to
  8302. */
  8303. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8304. /**
  8305. * Get the world position of a point that is in the local space of the bone
  8306. * @param position The local position
  8307. * @param mesh The mesh that this bone is attached to
  8308. * @returns The world position
  8309. */
  8310. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8311. /**
  8312. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8313. * @param position The local position
  8314. * @param mesh The mesh that this bone is attached to
  8315. * @param result The vector3 that the world position should be copied to
  8316. */
  8317. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8318. /**
  8319. * Get the local position of a point that is in world space
  8320. * @param position The world position
  8321. * @param mesh The mesh that this bone is attached to
  8322. * @returns The local position
  8323. */
  8324. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8325. /**
  8326. * Get the local position of a point that is in world space and copy it to the result param
  8327. * @param position The world position
  8328. * @param mesh The mesh that this bone is attached to
  8329. * @param result The vector3 that the local position should be copied to
  8330. */
  8331. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8332. }
  8333. }
  8334. declare module "babylonjs/Misc/iInspectable" {
  8335. /**
  8336. * Enum that determines the text-wrapping mode to use.
  8337. */
  8338. export enum InspectableType {
  8339. /**
  8340. * Checkbox for booleans
  8341. */
  8342. Checkbox = 0,
  8343. /**
  8344. * Sliders for numbers
  8345. */
  8346. Slider = 1,
  8347. /**
  8348. * Vector3
  8349. */
  8350. Vector3 = 2,
  8351. /**
  8352. * Quaternions
  8353. */
  8354. Quaternion = 3,
  8355. /**
  8356. * Color3
  8357. */
  8358. Color3 = 4
  8359. }
  8360. /**
  8361. * Interface used to define custom inspectable properties.
  8362. * This interface is used by the inspector to display custom property grids
  8363. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8364. */
  8365. export interface IInspectable {
  8366. /**
  8367. * Gets the label to display
  8368. */
  8369. label: string;
  8370. /**
  8371. * Gets the name of the property to edit
  8372. */
  8373. propertyName: string;
  8374. /**
  8375. * Gets the type of the editor to use
  8376. */
  8377. type: InspectableType;
  8378. /**
  8379. * Gets the minimum value of the property when using in "slider" mode
  8380. */
  8381. min?: number;
  8382. /**
  8383. * Gets the maximum value of the property when using in "slider" mode
  8384. */
  8385. max?: number;
  8386. /**
  8387. * Gets the setp to use when using in "slider" mode
  8388. */
  8389. step?: number;
  8390. }
  8391. }
  8392. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8393. import { Nullable } from "babylonjs/types";
  8394. import { Scene } from "babylonjs/scene";
  8395. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8396. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8397. /**
  8398. * Class for creating a cube texture
  8399. */
  8400. export class CubeTexture extends BaseTexture {
  8401. private _delayedOnLoad;
  8402. /**
  8403. * The url of the texture
  8404. */
  8405. url: string;
  8406. /**
  8407. * Gets or sets the center of the bounding box associated with the cube texture.
  8408. * It must define where the camera used to render the texture was set
  8409. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8410. */
  8411. boundingBoxPosition: Vector3;
  8412. private _boundingBoxSize;
  8413. /**
  8414. * Gets or sets the size of the bounding box associated with the cube texture
  8415. * When defined, the cubemap will switch to local mode
  8416. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8417. * @example https://www.babylonjs-playground.com/#RNASML
  8418. */
  8419. /**
  8420. * Returns the bounding box size
  8421. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8422. */
  8423. boundingBoxSize: Vector3;
  8424. protected _rotationY: number;
  8425. /**
  8426. * Sets texture matrix rotation angle around Y axis in radians.
  8427. */
  8428. /**
  8429. * Gets texture matrix rotation angle around Y axis radians.
  8430. */
  8431. rotationY: number;
  8432. /**
  8433. * Are mip maps generated for this texture or not.
  8434. */
  8435. readonly noMipmap: boolean;
  8436. private _noMipmap;
  8437. private _files;
  8438. private _extensions;
  8439. private _textureMatrix;
  8440. private _format;
  8441. private _createPolynomials;
  8442. /** @hidden */
  8443. _prefiltered: boolean;
  8444. /**
  8445. * Creates a cube texture from an array of image urls
  8446. * @param files defines an array of image urls
  8447. * @param scene defines the hosting scene
  8448. * @param noMipmap specifies if mip maps are not used
  8449. * @returns a cube texture
  8450. */
  8451. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8452. /**
  8453. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8454. * @param url defines the url of the prefiltered texture
  8455. * @param scene defines the scene the texture is attached to
  8456. * @param forcedExtension defines the extension of the file if different from the url
  8457. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8458. * @return the prefiltered texture
  8459. */
  8460. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8461. /**
  8462. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8463. * as prefiltered data.
  8464. * @param rootUrl defines the url of the texture or the root name of the six images
  8465. * @param scene defines the scene the texture is attached to
  8466. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8467. * @param noMipmap defines if mipmaps should be created or not
  8468. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8469. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8470. * @param onError defines a callback triggered in case of error during load
  8471. * @param format defines the internal format to use for the texture once loaded
  8472. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8473. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8474. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8475. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8476. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8477. * @return the cube texture
  8478. */
  8479. 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);
  8480. /**
  8481. * Get the current class name of the texture useful for serialization or dynamic coding.
  8482. * @returns "CubeTexture"
  8483. */
  8484. getClassName(): string;
  8485. /**
  8486. * Update the url (and optional buffer) of this texture if url was null during construction.
  8487. * @param url the url of the texture
  8488. * @param forcedExtension defines the extension to use
  8489. * @param onLoad callback called when the texture is loaded (defaults to null)
  8490. */
  8491. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8492. /**
  8493. * Delays loading of the cube texture
  8494. * @param forcedExtension defines the extension to use
  8495. */
  8496. delayLoad(forcedExtension?: string): void;
  8497. /**
  8498. * Returns the reflection texture matrix
  8499. * @returns the reflection texture matrix
  8500. */
  8501. getReflectionTextureMatrix(): Matrix;
  8502. /**
  8503. * Sets the reflection texture matrix
  8504. * @param value Reflection texture matrix
  8505. */
  8506. setReflectionTextureMatrix(value: Matrix): void;
  8507. /**
  8508. * Parses text to create a cube texture
  8509. * @param parsedTexture define the serialized text to read from
  8510. * @param scene defines the hosting scene
  8511. * @param rootUrl defines the root url of the cube texture
  8512. * @returns a cube texture
  8513. */
  8514. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8515. /**
  8516. * Makes a clone, or deep copy, of the cube texture
  8517. * @returns a new cube texture
  8518. */
  8519. clone(): CubeTexture;
  8520. }
  8521. }
  8522. declare module "babylonjs/Shaders/postprocess.vertex" {
  8523. /** @hidden */
  8524. export var postprocessVertexShader: {
  8525. name: string;
  8526. shader: string;
  8527. };
  8528. }
  8529. declare module "babylonjs/Cameras/targetCamera" {
  8530. import { Nullable } from "babylonjs/types";
  8531. import { Camera } from "babylonjs/Cameras/camera";
  8532. import { Scene } from "babylonjs/scene";
  8533. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8534. /**
  8535. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8536. * This is the base of the follow, arc rotate cameras and Free camera
  8537. * @see http://doc.babylonjs.com/features/cameras
  8538. */
  8539. export class TargetCamera extends Camera {
  8540. private static _RigCamTransformMatrix;
  8541. private static _TargetTransformMatrix;
  8542. private static _TargetFocalPoint;
  8543. /**
  8544. * Define the current direction the camera is moving to
  8545. */
  8546. cameraDirection: Vector3;
  8547. /**
  8548. * Define the current rotation the camera is rotating to
  8549. */
  8550. cameraRotation: Vector2;
  8551. /**
  8552. * When set, the up vector of the camera will be updated by the rotation of the camera
  8553. */
  8554. updateUpVectorFromRotation: boolean;
  8555. private _tmpQuaternion;
  8556. /**
  8557. * Define the current rotation of the camera
  8558. */
  8559. rotation: Vector3;
  8560. /**
  8561. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8562. */
  8563. rotationQuaternion: Quaternion;
  8564. /**
  8565. * Define the current speed of the camera
  8566. */
  8567. speed: number;
  8568. /**
  8569. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8570. * around all axis.
  8571. */
  8572. noRotationConstraint: boolean;
  8573. /**
  8574. * Define the current target of the camera as an object or a position.
  8575. */
  8576. lockedTarget: any;
  8577. /** @hidden */
  8578. _currentTarget: Vector3;
  8579. /** @hidden */
  8580. _initialFocalDistance: number;
  8581. /** @hidden */
  8582. _viewMatrix: Matrix;
  8583. /** @hidden */
  8584. _camMatrix: Matrix;
  8585. /** @hidden */
  8586. _cameraTransformMatrix: Matrix;
  8587. /** @hidden */
  8588. _cameraRotationMatrix: Matrix;
  8589. /** @hidden */
  8590. _referencePoint: Vector3;
  8591. /** @hidden */
  8592. _transformedReferencePoint: Vector3;
  8593. protected _globalCurrentTarget: Vector3;
  8594. protected _globalCurrentUpVector: Vector3;
  8595. /** @hidden */
  8596. _reset: () => void;
  8597. private _defaultUp;
  8598. /**
  8599. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8600. * This is the base of the follow, arc rotate cameras and Free camera
  8601. * @see http://doc.babylonjs.com/features/cameras
  8602. * @param name Defines the name of the camera in the scene
  8603. * @param position Defines the start position of the camera in the scene
  8604. * @param scene Defines the scene the camera belongs to
  8605. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8606. */
  8607. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8608. /**
  8609. * Gets the position in front of the camera at a given distance.
  8610. * @param distance The distance from the camera we want the position to be
  8611. * @returns the position
  8612. */
  8613. getFrontPosition(distance: number): Vector3;
  8614. /** @hidden */
  8615. _getLockedTargetPosition(): Nullable<Vector3>;
  8616. private _storedPosition;
  8617. private _storedRotation;
  8618. private _storedRotationQuaternion;
  8619. /**
  8620. * Store current camera state of the camera (fov, position, rotation, etc..)
  8621. * @returns the camera
  8622. */
  8623. storeState(): Camera;
  8624. /**
  8625. * Restored camera state. You must call storeState() first
  8626. * @returns whether it was successful or not
  8627. * @hidden
  8628. */
  8629. _restoreStateValues(): boolean;
  8630. /** @hidden */
  8631. _initCache(): void;
  8632. /** @hidden */
  8633. _updateCache(ignoreParentClass?: boolean): void;
  8634. /** @hidden */
  8635. _isSynchronizedViewMatrix(): boolean;
  8636. /** @hidden */
  8637. _computeLocalCameraSpeed(): number;
  8638. /**
  8639. * Defines the target the camera should look at.
  8640. * This will automatically adapt alpha beta and radius to fit within the new target.
  8641. * @param target Defines the new target as a Vector or a mesh
  8642. */
  8643. setTarget(target: Vector3): void;
  8644. /**
  8645. * Return the current target position of the camera. This value is expressed in local space.
  8646. * @returns the target position
  8647. */
  8648. getTarget(): Vector3;
  8649. /** @hidden */
  8650. _decideIfNeedsToMove(): boolean;
  8651. /** @hidden */
  8652. _updatePosition(): void;
  8653. /** @hidden */
  8654. _checkInputs(): void;
  8655. protected _updateCameraRotationMatrix(): void;
  8656. /**
  8657. * 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)
  8658. * @returns the current camera
  8659. */
  8660. private _rotateUpVectorWithCameraRotationMatrix;
  8661. private _cachedRotationZ;
  8662. private _cachedQuaternionRotationZ;
  8663. /** @hidden */
  8664. _getViewMatrix(): Matrix;
  8665. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8666. /**
  8667. * @hidden
  8668. */
  8669. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8670. /**
  8671. * @hidden
  8672. */
  8673. _updateRigCameras(): void;
  8674. private _getRigCamPositionAndTarget;
  8675. /**
  8676. * Gets the current object class name.
  8677. * @return the class name
  8678. */
  8679. getClassName(): string;
  8680. }
  8681. }
  8682. declare module "babylonjs/Cameras/cameraInputsManager" {
  8683. import { Nullable } from "babylonjs/types";
  8684. import { Camera } from "babylonjs/Cameras/camera";
  8685. /**
  8686. * @ignore
  8687. * This is a list of all the different input types that are available in the application.
  8688. * Fo instance: ArcRotateCameraGamepadInput...
  8689. */
  8690. export var CameraInputTypes: {};
  8691. /**
  8692. * This is the contract to implement in order to create a new input class.
  8693. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8694. */
  8695. export interface ICameraInput<TCamera extends Camera> {
  8696. /**
  8697. * Defines the camera the input is attached to.
  8698. */
  8699. camera: Nullable<TCamera>;
  8700. /**
  8701. * Gets the class name of the current intput.
  8702. * @returns the class name
  8703. */
  8704. getClassName(): string;
  8705. /**
  8706. * Get the friendly name associated with the input class.
  8707. * @returns the input friendly name
  8708. */
  8709. getSimpleName(): string;
  8710. /**
  8711. * Attach the input controls to a specific dom element to get the input from.
  8712. * @param element Defines the element the controls should be listened from
  8713. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8714. */
  8715. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8716. /**
  8717. * Detach the current controls from the specified dom element.
  8718. * @param element Defines the element to stop listening the inputs from
  8719. */
  8720. detachControl(element: Nullable<HTMLElement>): void;
  8721. /**
  8722. * Update the current camera state depending on the inputs that have been used this frame.
  8723. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8724. */
  8725. checkInputs?: () => void;
  8726. }
  8727. /**
  8728. * Represents a map of input types to input instance or input index to input instance.
  8729. */
  8730. export interface CameraInputsMap<TCamera extends Camera> {
  8731. /**
  8732. * Accessor to the input by input type.
  8733. */
  8734. [name: string]: ICameraInput<TCamera>;
  8735. /**
  8736. * Accessor to the input by input index.
  8737. */
  8738. [idx: number]: ICameraInput<TCamera>;
  8739. }
  8740. /**
  8741. * This represents the input manager used within a camera.
  8742. * It helps dealing with all the different kind of input attached to a camera.
  8743. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8744. */
  8745. export class CameraInputsManager<TCamera extends Camera> {
  8746. /**
  8747. * Defines the list of inputs attahed to the camera.
  8748. */
  8749. attached: CameraInputsMap<TCamera>;
  8750. /**
  8751. * Defines the dom element the camera is collecting inputs from.
  8752. * This is null if the controls have not been attached.
  8753. */
  8754. attachedElement: Nullable<HTMLElement>;
  8755. /**
  8756. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8757. */
  8758. noPreventDefault: boolean;
  8759. /**
  8760. * Defined the camera the input manager belongs to.
  8761. */
  8762. camera: TCamera;
  8763. /**
  8764. * Update the current camera state depending on the inputs that have been used this frame.
  8765. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8766. */
  8767. checkInputs: () => void;
  8768. /**
  8769. * Instantiate a new Camera Input Manager.
  8770. * @param camera Defines the camera the input manager blongs to
  8771. */
  8772. constructor(camera: TCamera);
  8773. /**
  8774. * Add an input method to a camera
  8775. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8776. * @param input camera input method
  8777. */
  8778. add(input: ICameraInput<TCamera>): void;
  8779. /**
  8780. * Remove a specific input method from a camera
  8781. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8782. * @param inputToRemove camera input method
  8783. */
  8784. remove(inputToRemove: ICameraInput<TCamera>): void;
  8785. /**
  8786. * Remove a specific input type from a camera
  8787. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8788. * @param inputType the type of the input to remove
  8789. */
  8790. removeByType(inputType: string): void;
  8791. private _addCheckInputs;
  8792. /**
  8793. * Attach the input controls to the currently attached dom element to listen the events from.
  8794. * @param input Defines the input to attach
  8795. */
  8796. attachInput(input: ICameraInput<TCamera>): void;
  8797. /**
  8798. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8799. * @param element Defines the dom element to collect the events from
  8800. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8801. */
  8802. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8803. /**
  8804. * Detach the current manager inputs controls from a specific dom element.
  8805. * @param element Defines the dom element to collect the events from
  8806. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8807. */
  8808. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8809. /**
  8810. * Rebuild the dynamic inputCheck function from the current list of
  8811. * defined inputs in the manager.
  8812. */
  8813. rebuildInputCheck(): void;
  8814. /**
  8815. * Remove all attached input methods from a camera
  8816. */
  8817. clear(): void;
  8818. /**
  8819. * Serialize the current input manager attached to a camera.
  8820. * This ensures than once parsed,
  8821. * the input associated to the camera will be identical to the current ones
  8822. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8823. */
  8824. serialize(serializedCamera: any): void;
  8825. /**
  8826. * Parses an input manager serialized JSON to restore the previous list of inputs
  8827. * and states associated to a camera.
  8828. * @param parsedCamera Defines the JSON to parse
  8829. */
  8830. parse(parsedCamera: any): void;
  8831. }
  8832. }
  8833. declare module "babylonjs/Events/keyboardEvents" {
  8834. /**
  8835. * Gather the list of keyboard event types as constants.
  8836. */
  8837. export class KeyboardEventTypes {
  8838. /**
  8839. * The keydown event is fired when a key becomes active (pressed).
  8840. */
  8841. static readonly KEYDOWN: number;
  8842. /**
  8843. * The keyup event is fired when a key has been released.
  8844. */
  8845. static readonly KEYUP: number;
  8846. }
  8847. /**
  8848. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8849. */
  8850. export class KeyboardInfo {
  8851. /**
  8852. * Defines the type of event (KeyboardEventTypes)
  8853. */
  8854. type: number;
  8855. /**
  8856. * Defines the related dom event
  8857. */
  8858. event: KeyboardEvent;
  8859. /**
  8860. * Instantiates a new keyboard info.
  8861. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8862. * @param type Defines the type of event (KeyboardEventTypes)
  8863. * @param event Defines the related dom event
  8864. */
  8865. constructor(
  8866. /**
  8867. * Defines the type of event (KeyboardEventTypes)
  8868. */
  8869. type: number,
  8870. /**
  8871. * Defines the related dom event
  8872. */
  8873. event: KeyboardEvent);
  8874. }
  8875. /**
  8876. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8877. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8878. */
  8879. export class KeyboardInfoPre extends KeyboardInfo {
  8880. /**
  8881. * Defines the type of event (KeyboardEventTypes)
  8882. */
  8883. type: number;
  8884. /**
  8885. * Defines the related dom event
  8886. */
  8887. event: KeyboardEvent;
  8888. /**
  8889. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8890. */
  8891. skipOnPointerObservable: boolean;
  8892. /**
  8893. * Instantiates a new keyboard pre info.
  8894. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8895. * @param type Defines the type of event (KeyboardEventTypes)
  8896. * @param event Defines the related dom event
  8897. */
  8898. constructor(
  8899. /**
  8900. * Defines the type of event (KeyboardEventTypes)
  8901. */
  8902. type: number,
  8903. /**
  8904. * Defines the related dom event
  8905. */
  8906. event: KeyboardEvent);
  8907. }
  8908. }
  8909. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8910. import { Nullable } from "babylonjs/types";
  8911. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8912. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8913. /**
  8914. * Manage the keyboard inputs to control the movement of a free camera.
  8915. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8916. */
  8917. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8918. /**
  8919. * Defines the camera the input is attached to.
  8920. */
  8921. camera: FreeCamera;
  8922. /**
  8923. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8924. */
  8925. keysUp: number[];
  8926. /**
  8927. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8928. */
  8929. keysDown: number[];
  8930. /**
  8931. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8932. */
  8933. keysLeft: number[];
  8934. /**
  8935. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8936. */
  8937. keysRight: number[];
  8938. private _keys;
  8939. private _onCanvasBlurObserver;
  8940. private _onKeyboardObserver;
  8941. private _engine;
  8942. private _scene;
  8943. /**
  8944. * Attach the input controls to a specific dom element to get the input from.
  8945. * @param element Defines the element the controls should be listened from
  8946. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8947. */
  8948. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8949. /**
  8950. * Detach the current controls from the specified dom element.
  8951. * @param element Defines the element to stop listening the inputs from
  8952. */
  8953. detachControl(element: Nullable<HTMLElement>): void;
  8954. /**
  8955. * Update the current camera state depending on the inputs that have been used this frame.
  8956. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8957. */
  8958. checkInputs(): void;
  8959. /**
  8960. * Gets the class name of the current intput.
  8961. * @returns the class name
  8962. */
  8963. getClassName(): string;
  8964. /** @hidden */
  8965. _onLostFocus(): void;
  8966. /**
  8967. * Get the friendly name associated with the input class.
  8968. * @returns the input friendly name
  8969. */
  8970. getSimpleName(): string;
  8971. }
  8972. }
  8973. declare module "babylonjs/Lights/shadowLight" {
  8974. import { Camera } from "babylonjs/Cameras/camera";
  8975. import { Scene } from "babylonjs/scene";
  8976. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8978. import { Light } from "babylonjs/Lights/light";
  8979. /**
  8980. * Interface describing all the common properties and methods a shadow light needs to implement.
  8981. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8982. * as well as binding the different shadow properties to the effects.
  8983. */
  8984. export interface IShadowLight extends Light {
  8985. /**
  8986. * The light id in the scene (used in scene.findLighById for instance)
  8987. */
  8988. id: string;
  8989. /**
  8990. * The position the shdow will be casted from.
  8991. */
  8992. position: Vector3;
  8993. /**
  8994. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8995. */
  8996. direction: Vector3;
  8997. /**
  8998. * The transformed position. Position of the light in world space taking parenting in account.
  8999. */
  9000. transformedPosition: Vector3;
  9001. /**
  9002. * The transformed direction. Direction of the light in world space taking parenting in account.
  9003. */
  9004. transformedDirection: Vector3;
  9005. /**
  9006. * The friendly name of the light in the scene.
  9007. */
  9008. name: string;
  9009. /**
  9010. * Defines the shadow projection clipping minimum z value.
  9011. */
  9012. shadowMinZ: number;
  9013. /**
  9014. * Defines the shadow projection clipping maximum z value.
  9015. */
  9016. shadowMaxZ: number;
  9017. /**
  9018. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9019. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9020. */
  9021. computeTransformedInformation(): boolean;
  9022. /**
  9023. * Gets the scene the light belongs to.
  9024. * @returns The scene
  9025. */
  9026. getScene(): Scene;
  9027. /**
  9028. * Callback defining a custom Projection Matrix Builder.
  9029. * This can be used to override the default projection matrix computation.
  9030. */
  9031. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9032. /**
  9033. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9034. * @param matrix The materix to updated with the projection information
  9035. * @param viewMatrix The transform matrix of the light
  9036. * @param renderList The list of mesh to render in the map
  9037. * @returns The current light
  9038. */
  9039. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9040. /**
  9041. * Gets the current depth scale used in ESM.
  9042. * @returns The scale
  9043. */
  9044. getDepthScale(): number;
  9045. /**
  9046. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9047. * @returns true if a cube texture needs to be use
  9048. */
  9049. needCube(): boolean;
  9050. /**
  9051. * Detects if the projection matrix requires to be recomputed this frame.
  9052. * @returns true if it requires to be recomputed otherwise, false.
  9053. */
  9054. needProjectionMatrixCompute(): boolean;
  9055. /**
  9056. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9057. */
  9058. forceProjectionMatrixCompute(): void;
  9059. /**
  9060. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9061. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9062. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9063. */
  9064. getShadowDirection(faceIndex?: number): Vector3;
  9065. /**
  9066. * Gets the minZ used for shadow according to both the scene and the light.
  9067. * @param activeCamera The camera we are returning the min for
  9068. * @returns the depth min z
  9069. */
  9070. getDepthMinZ(activeCamera: Camera): number;
  9071. /**
  9072. * Gets the maxZ used for shadow according to both the scene and the light.
  9073. * @param activeCamera The camera we are returning the max for
  9074. * @returns the depth max z
  9075. */
  9076. getDepthMaxZ(activeCamera: Camera): number;
  9077. }
  9078. /**
  9079. * Base implementation IShadowLight
  9080. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9081. */
  9082. export abstract class ShadowLight extends Light implements IShadowLight {
  9083. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9084. protected _position: Vector3;
  9085. protected _setPosition(value: Vector3): void;
  9086. /**
  9087. * Sets the position the shadow will be casted from. Also use as the light position for both
  9088. * point and spot lights.
  9089. */
  9090. /**
  9091. * Sets the position the shadow will be casted from. Also use as the light position for both
  9092. * point and spot lights.
  9093. */
  9094. position: Vector3;
  9095. protected _direction: Vector3;
  9096. protected _setDirection(value: Vector3): void;
  9097. /**
  9098. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9099. * Also use as the light direction on spot and directional lights.
  9100. */
  9101. /**
  9102. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9103. * Also use as the light direction on spot and directional lights.
  9104. */
  9105. direction: Vector3;
  9106. private _shadowMinZ;
  9107. /**
  9108. * Gets the shadow projection clipping minimum z value.
  9109. */
  9110. /**
  9111. * Sets the shadow projection clipping minimum z value.
  9112. */
  9113. shadowMinZ: number;
  9114. private _shadowMaxZ;
  9115. /**
  9116. * Sets the shadow projection clipping maximum z value.
  9117. */
  9118. /**
  9119. * Gets the shadow projection clipping maximum z value.
  9120. */
  9121. shadowMaxZ: number;
  9122. /**
  9123. * Callback defining a custom Projection Matrix Builder.
  9124. * This can be used to override the default projection matrix computation.
  9125. */
  9126. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9127. /**
  9128. * The transformed position. Position of the light in world space taking parenting in account.
  9129. */
  9130. transformedPosition: Vector3;
  9131. /**
  9132. * The transformed direction. Direction of the light in world space taking parenting in account.
  9133. */
  9134. transformedDirection: Vector3;
  9135. private _needProjectionMatrixCompute;
  9136. /**
  9137. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9138. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9139. */
  9140. computeTransformedInformation(): boolean;
  9141. /**
  9142. * Return the depth scale used for the shadow map.
  9143. * @returns the depth scale.
  9144. */
  9145. getDepthScale(): number;
  9146. /**
  9147. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9148. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9149. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9150. */
  9151. getShadowDirection(faceIndex?: number): Vector3;
  9152. /**
  9153. * Returns the ShadowLight absolute position in the World.
  9154. * @returns the position vector in world space
  9155. */
  9156. getAbsolutePosition(): Vector3;
  9157. /**
  9158. * Sets the ShadowLight direction toward the passed target.
  9159. * @param target The point to target in local space
  9160. * @returns the updated ShadowLight direction
  9161. */
  9162. setDirectionToTarget(target: Vector3): Vector3;
  9163. /**
  9164. * Returns the light rotation in euler definition.
  9165. * @returns the x y z rotation in local space.
  9166. */
  9167. getRotation(): Vector3;
  9168. /**
  9169. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9170. * @returns true if a cube texture needs to be use
  9171. */
  9172. needCube(): boolean;
  9173. /**
  9174. * Detects if the projection matrix requires to be recomputed this frame.
  9175. * @returns true if it requires to be recomputed otherwise, false.
  9176. */
  9177. needProjectionMatrixCompute(): boolean;
  9178. /**
  9179. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9180. */
  9181. forceProjectionMatrixCompute(): void;
  9182. /** @hidden */
  9183. _initCache(): void;
  9184. /** @hidden */
  9185. _isSynchronized(): boolean;
  9186. /**
  9187. * Computes the world matrix of the node
  9188. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9189. * @returns the world matrix
  9190. */
  9191. computeWorldMatrix(force?: boolean): Matrix;
  9192. /**
  9193. * Gets the minZ used for shadow according to both the scene and the light.
  9194. * @param activeCamera The camera we are returning the min for
  9195. * @returns the depth min z
  9196. */
  9197. getDepthMinZ(activeCamera: Camera): number;
  9198. /**
  9199. * Gets the maxZ used for shadow according to both the scene and the light.
  9200. * @param activeCamera The camera we are returning the max for
  9201. * @returns the depth max z
  9202. */
  9203. getDepthMaxZ(activeCamera: Camera): number;
  9204. /**
  9205. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9206. * @param matrix The materix to updated with the projection information
  9207. * @param viewMatrix The transform matrix of the light
  9208. * @param renderList The list of mesh to render in the map
  9209. * @returns The current light
  9210. */
  9211. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9212. }
  9213. }
  9214. declare module "babylonjs/Materials/materialHelper" {
  9215. import { Nullable } from "babylonjs/types";
  9216. import { Scene } from "babylonjs/scene";
  9217. import { Engine } from "babylonjs/Engines/engine";
  9218. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9219. import { Light } from "babylonjs/Lights/light";
  9220. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9221. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9222. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9223. /**
  9224. * "Static Class" containing the most commonly used helper while dealing with material for
  9225. * rendering purpose.
  9226. *
  9227. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9228. *
  9229. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9230. */
  9231. export class MaterialHelper {
  9232. /**
  9233. * Bind the current view position to an effect.
  9234. * @param effect The effect to be bound
  9235. * @param scene The scene the eyes position is used from
  9236. */
  9237. static BindEyePosition(effect: Effect, scene: Scene): void;
  9238. /**
  9239. * Helps preparing the defines values about the UVs in used in the effect.
  9240. * UVs are shared as much as we can accross channels in the shaders.
  9241. * @param texture The texture we are preparing the UVs for
  9242. * @param defines The defines to update
  9243. * @param key The channel key "diffuse", "specular"... used in the shader
  9244. */
  9245. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9246. /**
  9247. * Binds a texture matrix value to its corrsponding uniform
  9248. * @param texture The texture to bind the matrix for
  9249. * @param uniformBuffer The uniform buffer receivin the data
  9250. * @param key The channel key "diffuse", "specular"... used in the shader
  9251. */
  9252. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9253. /**
  9254. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9255. * @param mesh defines the current mesh
  9256. * @param scene defines the current scene
  9257. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9258. * @param pointsCloud defines if point cloud rendering has to be turned on
  9259. * @param fogEnabled defines if fog has to be turned on
  9260. * @param alphaTest defines if alpha testing has to be turned on
  9261. * @param defines defines the current list of defines
  9262. */
  9263. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9264. /**
  9265. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9266. * @param scene defines the current scene
  9267. * @param engine defines the current engine
  9268. * @param defines specifies the list of active defines
  9269. * @param useInstances defines if instances have to be turned on
  9270. * @param useClipPlane defines if clip plane have to be turned on
  9271. */
  9272. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9273. /**
  9274. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9275. * @param mesh The mesh containing the geometry data we will draw
  9276. * @param defines The defines to update
  9277. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9278. * @param useBones Precise whether bones should be used or not (override mesh info)
  9279. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9280. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9281. * @returns false if defines are considered not dirty and have not been checked
  9282. */
  9283. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9284. /**
  9285. * Prepares the defines related to multiview
  9286. * @param scene The scene we are intending to draw
  9287. * @param defines The defines to update
  9288. */
  9289. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9290. /**
  9291. * Prepares the defines related to the light information passed in parameter
  9292. * @param scene The scene we are intending to draw
  9293. * @param mesh The mesh the effect is compiling for
  9294. * @param defines The defines to update
  9295. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9296. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9297. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9298. * @returns true if normals will be required for the rest of the effect
  9299. */
  9300. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9301. /**
  9302. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9303. * that won t be acctive due to defines being turned off.
  9304. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9305. * @param samplersList The samplers list
  9306. * @param defines The defines helping in the list generation
  9307. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9308. */
  9309. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9310. /**
  9311. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9312. * @param defines The defines to update while falling back
  9313. * @param fallbacks The authorized effect fallbacks
  9314. * @param maxSimultaneousLights The maximum number of lights allowed
  9315. * @param rank the current rank of the Effect
  9316. * @returns The newly affected rank
  9317. */
  9318. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9319. /**
  9320. * Prepares the list of attributes required for morph targets according to the effect defines.
  9321. * @param attribs The current list of supported attribs
  9322. * @param mesh The mesh to prepare the morph targets attributes for
  9323. * @param defines The current Defines of the effect
  9324. */
  9325. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9326. /**
  9327. * Prepares the list of attributes required for bones according to the effect defines.
  9328. * @param attribs The current list of supported attribs
  9329. * @param mesh The mesh to prepare the bones attributes for
  9330. * @param defines The current Defines of the effect
  9331. * @param fallbacks The current efffect fallback strategy
  9332. */
  9333. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9334. /**
  9335. * Prepares the list of attributes required for instances according to the effect defines.
  9336. * @param attribs The current list of supported attribs
  9337. * @param defines The current Defines of the effect
  9338. */
  9339. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9340. /**
  9341. * Binds the light shadow information to the effect for the given mesh.
  9342. * @param light The light containing the generator
  9343. * @param scene The scene the lights belongs to
  9344. * @param mesh The mesh we are binding the information to render
  9345. * @param lightIndex The light index in the effect used to render the mesh
  9346. * @param effect The effect we are binding the data to
  9347. */
  9348. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9349. /**
  9350. * Binds the light information to the effect.
  9351. * @param light The light containing the generator
  9352. * @param effect The effect we are binding the data to
  9353. * @param lightIndex The light index in the effect used to render
  9354. */
  9355. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9356. /**
  9357. * Binds the lights information from the scene to the effect for the given mesh.
  9358. * @param scene The scene the lights belongs to
  9359. * @param mesh The mesh we are binding the information to render
  9360. * @param effect The effect we are binding the data to
  9361. * @param defines The generated defines for the effect
  9362. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9363. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9364. */
  9365. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9366. private static _tempFogColor;
  9367. /**
  9368. * Binds the fog information from the scene to the effect for the given mesh.
  9369. * @param scene The scene the lights belongs to
  9370. * @param mesh The mesh we are binding the information to render
  9371. * @param effect The effect we are binding the data to
  9372. * @param linearSpace Defines if the fog effect is applied in linear space
  9373. */
  9374. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9375. /**
  9376. * Binds the bones information from the mesh to the effect.
  9377. * @param mesh The mesh we are binding the information to render
  9378. * @param effect The effect we are binding the data to
  9379. */
  9380. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9381. /**
  9382. * Binds the morph targets information from the mesh to the effect.
  9383. * @param abstractMesh The mesh we are binding the information to render
  9384. * @param effect The effect we are binding the data to
  9385. */
  9386. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9387. /**
  9388. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9389. * @param defines The generated defines used in the effect
  9390. * @param effect The effect we are binding the data to
  9391. * @param scene The scene we are willing to render with logarithmic scale for
  9392. */
  9393. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9394. /**
  9395. * Binds the clip plane information from the scene to the effect.
  9396. * @param scene The scene the clip plane information are extracted from
  9397. * @param effect The effect we are binding the data to
  9398. */
  9399. static BindClipPlane(effect: Effect, scene: Scene): void;
  9400. }
  9401. }
  9402. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9403. /** @hidden */
  9404. export var kernelBlurVaryingDeclaration: {
  9405. name: string;
  9406. shader: string;
  9407. };
  9408. }
  9409. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9410. /** @hidden */
  9411. export var kernelBlurFragment: {
  9412. name: string;
  9413. shader: string;
  9414. };
  9415. }
  9416. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9417. /** @hidden */
  9418. export var kernelBlurFragment2: {
  9419. name: string;
  9420. shader: string;
  9421. };
  9422. }
  9423. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9424. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9425. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9426. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9427. /** @hidden */
  9428. export var kernelBlurPixelShader: {
  9429. name: string;
  9430. shader: string;
  9431. };
  9432. }
  9433. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9434. /** @hidden */
  9435. export var kernelBlurVertex: {
  9436. name: string;
  9437. shader: string;
  9438. };
  9439. }
  9440. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9441. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9442. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9443. /** @hidden */
  9444. export var kernelBlurVertexShader: {
  9445. name: string;
  9446. shader: string;
  9447. };
  9448. }
  9449. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9450. import { Vector2 } from "babylonjs/Maths/math";
  9451. import { Nullable } from "babylonjs/types";
  9452. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9453. import { Camera } from "babylonjs/Cameras/camera";
  9454. import { Effect } from "babylonjs/Materials/effect";
  9455. import { Engine } from "babylonjs/Engines/engine";
  9456. import "babylonjs/Shaders/kernelBlur.fragment";
  9457. import "babylonjs/Shaders/kernelBlur.vertex";
  9458. /**
  9459. * The Blur Post Process which blurs an image based on a kernel and direction.
  9460. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9461. */
  9462. export class BlurPostProcess extends PostProcess {
  9463. /** The direction in which to blur the image. */
  9464. direction: Vector2;
  9465. private blockCompilation;
  9466. protected _kernel: number;
  9467. protected _idealKernel: number;
  9468. protected _packedFloat: boolean;
  9469. private _staticDefines;
  9470. /**
  9471. * Sets the length in pixels of the blur sample region
  9472. */
  9473. /**
  9474. * Gets the length in pixels of the blur sample region
  9475. */
  9476. kernel: number;
  9477. /**
  9478. * Sets wether or not the blur needs to unpack/repack floats
  9479. */
  9480. /**
  9481. * Gets wether or not the blur is unpacking/repacking floats
  9482. */
  9483. packedFloat: boolean;
  9484. /**
  9485. * Creates a new instance BlurPostProcess
  9486. * @param name The name of the effect.
  9487. * @param direction The direction in which to blur the image.
  9488. * @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.
  9489. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9490. * @param camera The camera to apply the render pass to.
  9491. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9492. * @param engine The engine which the post process will be applied. (default: current engine)
  9493. * @param reusable If the post process can be reused on the same frame. (default: false)
  9494. * @param textureType Type of textures used when performing the post process. (default: 0)
  9495. * @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)
  9496. */
  9497. constructor(name: string,
  9498. /** The direction in which to blur the image. */
  9499. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9500. /**
  9501. * Updates the effect with the current post process compile time values and recompiles the shader.
  9502. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9503. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9504. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9505. * @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
  9506. * @param onCompiled Called when the shader has been compiled.
  9507. * @param onError Called if there is an error when compiling a shader.
  9508. */
  9509. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9510. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9511. /**
  9512. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9513. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9514. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9515. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9516. * The gaps between physical kernels are compensated for in the weighting of the samples
  9517. * @param idealKernel Ideal blur kernel.
  9518. * @return Nearest best kernel.
  9519. */
  9520. protected _nearestBestKernel(idealKernel: number): number;
  9521. /**
  9522. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9523. * @param x The point on the Gaussian distribution to sample.
  9524. * @return the value of the Gaussian function at x.
  9525. */
  9526. protected _gaussianWeight(x: number): number;
  9527. /**
  9528. * Generates a string that can be used as a floating point number in GLSL.
  9529. * @param x Value to print.
  9530. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9531. * @return GLSL float string.
  9532. */
  9533. protected _glslFloat(x: number, decimalFigures?: number): string;
  9534. }
  9535. }
  9536. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9537. /** @hidden */
  9538. export var shadowMapPixelShader: {
  9539. name: string;
  9540. shader: string;
  9541. };
  9542. }
  9543. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9544. /** @hidden */
  9545. export var bonesDeclaration: {
  9546. name: string;
  9547. shader: string;
  9548. };
  9549. }
  9550. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9551. /** @hidden */
  9552. export var morphTargetsVertexGlobalDeclaration: {
  9553. name: string;
  9554. shader: string;
  9555. };
  9556. }
  9557. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9558. /** @hidden */
  9559. export var morphTargetsVertexDeclaration: {
  9560. name: string;
  9561. shader: string;
  9562. };
  9563. }
  9564. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9565. /** @hidden */
  9566. export var instancesDeclaration: {
  9567. name: string;
  9568. shader: string;
  9569. };
  9570. }
  9571. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9572. /** @hidden */
  9573. export var helperFunctions: {
  9574. name: string;
  9575. shader: string;
  9576. };
  9577. }
  9578. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9579. /** @hidden */
  9580. export var morphTargetsVertex: {
  9581. name: string;
  9582. shader: string;
  9583. };
  9584. }
  9585. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9586. /** @hidden */
  9587. export var instancesVertex: {
  9588. name: string;
  9589. shader: string;
  9590. };
  9591. }
  9592. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9593. /** @hidden */
  9594. export var bonesVertex: {
  9595. name: string;
  9596. shader: string;
  9597. };
  9598. }
  9599. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9600. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9601. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9602. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9603. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9604. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9605. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9606. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9607. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9608. /** @hidden */
  9609. export var shadowMapVertexShader: {
  9610. name: string;
  9611. shader: string;
  9612. };
  9613. }
  9614. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9615. /** @hidden */
  9616. export var depthBoxBlurPixelShader: {
  9617. name: string;
  9618. shader: string;
  9619. };
  9620. }
  9621. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9622. import { Nullable } from "babylonjs/types";
  9623. import { Scene } from "babylonjs/scene";
  9624. import { Matrix } from "babylonjs/Maths/math";
  9625. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9627. import { Mesh } from "babylonjs/Meshes/mesh";
  9628. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9629. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9630. import { Effect } from "babylonjs/Materials/effect";
  9631. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9632. import "babylonjs/Shaders/shadowMap.fragment";
  9633. import "babylonjs/Shaders/shadowMap.vertex";
  9634. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9635. import { Observable } from "babylonjs/Misc/observable";
  9636. /**
  9637. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9638. */
  9639. export interface ICustomShaderOptions {
  9640. /**
  9641. * Gets or sets the custom shader name to use
  9642. */
  9643. shaderName: string;
  9644. /**
  9645. * The list of attribute names used in the shader
  9646. */
  9647. attributes?: string[];
  9648. /**
  9649. * The list of unifrom names used in the shader
  9650. */
  9651. uniforms?: string[];
  9652. /**
  9653. * The list of sampler names used in the shader
  9654. */
  9655. samplers?: string[];
  9656. /**
  9657. * The list of defines used in the shader
  9658. */
  9659. defines?: string[];
  9660. }
  9661. /**
  9662. * Interface to implement to create a shadow generator compatible with BJS.
  9663. */
  9664. export interface IShadowGenerator {
  9665. /**
  9666. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9667. * @returns The render target texture if present otherwise, null
  9668. */
  9669. getShadowMap(): Nullable<RenderTargetTexture>;
  9670. /**
  9671. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9672. * @returns The render target texture if the shadow map is present otherwise, null
  9673. */
  9674. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9675. /**
  9676. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9677. * @param subMesh The submesh we want to render in the shadow map
  9678. * @param useInstances Defines wether will draw in the map using instances
  9679. * @returns true if ready otherwise, false
  9680. */
  9681. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9682. /**
  9683. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9684. * @param defines Defines of the material we want to update
  9685. * @param lightIndex Index of the light in the enabled light list of the material
  9686. */
  9687. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9688. /**
  9689. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9690. * defined in the generator but impacting the effect).
  9691. * It implies the unifroms available on the materials are the standard BJS ones.
  9692. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9693. * @param effect The effect we are binfing the information for
  9694. */
  9695. bindShadowLight(lightIndex: string, effect: Effect): void;
  9696. /**
  9697. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9698. * (eq to shadow prjection matrix * light transform matrix)
  9699. * @returns The transform matrix used to create the shadow map
  9700. */
  9701. getTransformMatrix(): Matrix;
  9702. /**
  9703. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9704. * Cube and 2D textures for instance.
  9705. */
  9706. recreateShadowMap(): void;
  9707. /**
  9708. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9709. * @param onCompiled Callback triggered at the and of the effects compilation
  9710. * @param options Sets of optional options forcing the compilation with different modes
  9711. */
  9712. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9713. useInstances: boolean;
  9714. }>): void;
  9715. /**
  9716. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9717. * @param options Sets of optional options forcing the compilation with different modes
  9718. * @returns A promise that resolves when the compilation completes
  9719. */
  9720. forceCompilationAsync(options?: Partial<{
  9721. useInstances: boolean;
  9722. }>): Promise<void>;
  9723. /**
  9724. * Serializes the shadow generator setup to a json object.
  9725. * @returns The serialized JSON object
  9726. */
  9727. serialize(): any;
  9728. /**
  9729. * Disposes the Shadow map and related Textures and effects.
  9730. */
  9731. dispose(): void;
  9732. }
  9733. /**
  9734. * Default implementation IShadowGenerator.
  9735. * This is the main object responsible of generating shadows in the framework.
  9736. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9737. */
  9738. export class ShadowGenerator implements IShadowGenerator {
  9739. /**
  9740. * Shadow generator mode None: no filtering applied.
  9741. */
  9742. static readonly FILTER_NONE: number;
  9743. /**
  9744. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9745. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9746. */
  9747. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9748. /**
  9749. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9750. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9751. */
  9752. static readonly FILTER_POISSONSAMPLING: number;
  9753. /**
  9754. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9755. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9756. */
  9757. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9758. /**
  9759. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9760. * edge artifacts on steep falloff.
  9761. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9762. */
  9763. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9764. /**
  9765. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9766. * edge artifacts on steep falloff.
  9767. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9768. */
  9769. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9770. /**
  9771. * Shadow generator mode PCF: Percentage Closer Filtering
  9772. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9773. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9774. */
  9775. static readonly FILTER_PCF: number;
  9776. /**
  9777. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9778. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9779. * Contact Hardening
  9780. */
  9781. static readonly FILTER_PCSS: number;
  9782. /**
  9783. * Reserved for PCF and PCSS
  9784. * Highest Quality.
  9785. *
  9786. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9787. *
  9788. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9789. */
  9790. static readonly QUALITY_HIGH: number;
  9791. /**
  9792. * Reserved for PCF and PCSS
  9793. * Good tradeoff for quality/perf cross devices
  9794. *
  9795. * Execute PCF on a 3*3 kernel.
  9796. *
  9797. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9798. */
  9799. static readonly QUALITY_MEDIUM: number;
  9800. /**
  9801. * Reserved for PCF and PCSS
  9802. * The lowest quality but the fastest.
  9803. *
  9804. * Execute PCF on a 1*1 kernel.
  9805. *
  9806. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9807. */
  9808. static readonly QUALITY_LOW: number;
  9809. /** Gets or sets the custom shader name to use */
  9810. customShaderOptions: ICustomShaderOptions;
  9811. /**
  9812. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9813. */
  9814. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9815. /**
  9816. * Observable triggered before a mesh is rendered in the shadow map.
  9817. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9818. */
  9819. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9820. private _bias;
  9821. /**
  9822. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9823. */
  9824. /**
  9825. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9826. */
  9827. bias: number;
  9828. private _normalBias;
  9829. /**
  9830. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9831. */
  9832. /**
  9833. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9834. */
  9835. normalBias: number;
  9836. private _blurBoxOffset;
  9837. /**
  9838. * Gets the blur box offset: offset applied during the blur pass.
  9839. * Only useful if useKernelBlur = false
  9840. */
  9841. /**
  9842. * Sets the blur box offset: offset applied during the blur pass.
  9843. * Only useful if useKernelBlur = false
  9844. */
  9845. blurBoxOffset: number;
  9846. private _blurScale;
  9847. /**
  9848. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9849. * 2 means half of the size.
  9850. */
  9851. /**
  9852. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9853. * 2 means half of the size.
  9854. */
  9855. blurScale: number;
  9856. private _blurKernel;
  9857. /**
  9858. * Gets the blur kernel: kernel size of the blur pass.
  9859. * Only useful if useKernelBlur = true
  9860. */
  9861. /**
  9862. * Sets the blur kernel: kernel size of the blur pass.
  9863. * Only useful if useKernelBlur = true
  9864. */
  9865. blurKernel: number;
  9866. private _useKernelBlur;
  9867. /**
  9868. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9869. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9870. */
  9871. /**
  9872. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9873. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9874. */
  9875. useKernelBlur: boolean;
  9876. private _depthScale;
  9877. /**
  9878. * Gets the depth scale used in ESM mode.
  9879. */
  9880. /**
  9881. * Sets the depth scale used in ESM mode.
  9882. * This can override the scale stored on the light.
  9883. */
  9884. depthScale: number;
  9885. private _filter;
  9886. /**
  9887. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9888. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9889. */
  9890. /**
  9891. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9892. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9893. */
  9894. filter: number;
  9895. /**
  9896. * Gets if the current filter is set to Poisson Sampling.
  9897. */
  9898. /**
  9899. * Sets the current filter to Poisson Sampling.
  9900. */
  9901. usePoissonSampling: boolean;
  9902. /**
  9903. * Gets if the current filter is set to ESM.
  9904. */
  9905. /**
  9906. * Sets the current filter is to ESM.
  9907. */
  9908. useExponentialShadowMap: boolean;
  9909. /**
  9910. * Gets if the current filter is set to filtered ESM.
  9911. */
  9912. /**
  9913. * Gets if the current filter is set to filtered ESM.
  9914. */
  9915. useBlurExponentialShadowMap: boolean;
  9916. /**
  9917. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9918. * exponential to prevent steep falloff artifacts).
  9919. */
  9920. /**
  9921. * Sets the current filter to "close ESM" (using the inverse of the
  9922. * exponential to prevent steep falloff artifacts).
  9923. */
  9924. useCloseExponentialShadowMap: boolean;
  9925. /**
  9926. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9927. * exponential to prevent steep falloff artifacts).
  9928. */
  9929. /**
  9930. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9931. * exponential to prevent steep falloff artifacts).
  9932. */
  9933. useBlurCloseExponentialShadowMap: boolean;
  9934. /**
  9935. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9936. */
  9937. /**
  9938. * Sets the current filter to "PCF" (percentage closer filtering).
  9939. */
  9940. usePercentageCloserFiltering: boolean;
  9941. private _filteringQuality;
  9942. /**
  9943. * Gets the PCF or PCSS Quality.
  9944. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9945. */
  9946. /**
  9947. * Sets the PCF or PCSS Quality.
  9948. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9949. */
  9950. filteringQuality: number;
  9951. /**
  9952. * Gets if the current filter is set to "PCSS" (contact hardening).
  9953. */
  9954. /**
  9955. * Sets the current filter to "PCSS" (contact hardening).
  9956. */
  9957. useContactHardeningShadow: boolean;
  9958. private _contactHardeningLightSizeUVRatio;
  9959. /**
  9960. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9961. * Using a ratio helps keeping shape stability independently of the map size.
  9962. *
  9963. * It does not account for the light projection as it was having too much
  9964. * instability during the light setup or during light position changes.
  9965. *
  9966. * Only valid if useContactHardeningShadow is true.
  9967. */
  9968. /**
  9969. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9970. * Using a ratio helps keeping shape stability independently of the map size.
  9971. *
  9972. * It does not account for the light projection as it was having too much
  9973. * instability during the light setup or during light position changes.
  9974. *
  9975. * Only valid if useContactHardeningShadow is true.
  9976. */
  9977. contactHardeningLightSizeUVRatio: number;
  9978. private _darkness;
  9979. /**
  9980. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9981. * 0 means strongest and 1 would means no shadow.
  9982. * @returns the darkness.
  9983. */
  9984. getDarkness(): number;
  9985. /**
  9986. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9987. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9988. * @returns the shadow generator allowing fluent coding.
  9989. */
  9990. setDarkness(darkness: number): ShadowGenerator;
  9991. private _transparencyShadow;
  9992. /**
  9993. * Sets the ability to have transparent shadow (boolean).
  9994. * @param transparent True if transparent else False
  9995. * @returns the shadow generator allowing fluent coding
  9996. */
  9997. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9998. private _shadowMap;
  9999. private _shadowMap2;
  10000. /**
  10001. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10002. * @returns The render target texture if present otherwise, null
  10003. */
  10004. getShadowMap(): Nullable<RenderTargetTexture>;
  10005. /**
  10006. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10007. * @returns The render target texture if the shadow map is present otherwise, null
  10008. */
  10009. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10010. /**
  10011. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10012. * @param mesh Mesh to add
  10013. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10014. * @returns the Shadow Generator itself
  10015. */
  10016. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10017. /**
  10018. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10019. * @param mesh Mesh to remove
  10020. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10021. * @returns the Shadow Generator itself
  10022. */
  10023. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10024. /**
  10025. * Controls the extent to which the shadows fade out at the edge of the frustum
  10026. * Used only by directionals and spots
  10027. */
  10028. frustumEdgeFalloff: number;
  10029. private _light;
  10030. /**
  10031. * Returns the associated light object.
  10032. * @returns the light generating the shadow
  10033. */
  10034. getLight(): IShadowLight;
  10035. /**
  10036. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10037. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10038. * It might on the other hand introduce peter panning.
  10039. */
  10040. forceBackFacesOnly: boolean;
  10041. private _scene;
  10042. private _lightDirection;
  10043. private _effect;
  10044. private _viewMatrix;
  10045. private _projectionMatrix;
  10046. private _transformMatrix;
  10047. private _cachedPosition;
  10048. private _cachedDirection;
  10049. private _cachedDefines;
  10050. private _currentRenderID;
  10051. private _boxBlurPostprocess;
  10052. private _kernelBlurXPostprocess;
  10053. private _kernelBlurYPostprocess;
  10054. private _blurPostProcesses;
  10055. private _mapSize;
  10056. private _currentFaceIndex;
  10057. private _currentFaceIndexCache;
  10058. private _textureType;
  10059. private _defaultTextureMatrix;
  10060. /** @hidden */
  10061. static _SceneComponentInitialization: (scene: Scene) => void;
  10062. /**
  10063. * Creates a ShadowGenerator object.
  10064. * A ShadowGenerator is the required tool to use the shadows.
  10065. * Each light casting shadows needs to use its own ShadowGenerator.
  10066. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10067. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10068. * @param light The light object generating the shadows.
  10069. * @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.
  10070. */
  10071. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10072. private _initializeGenerator;
  10073. private _initializeShadowMap;
  10074. private _initializeBlurRTTAndPostProcesses;
  10075. private _renderForShadowMap;
  10076. private _renderSubMeshForShadowMap;
  10077. private _applyFilterValues;
  10078. /**
  10079. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10080. * @param onCompiled Callback triggered at the and of the effects compilation
  10081. * @param options Sets of optional options forcing the compilation with different modes
  10082. */
  10083. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10084. useInstances: boolean;
  10085. }>): void;
  10086. /**
  10087. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10088. * @param options Sets of optional options forcing the compilation with different modes
  10089. * @returns A promise that resolves when the compilation completes
  10090. */
  10091. forceCompilationAsync(options?: Partial<{
  10092. useInstances: boolean;
  10093. }>): Promise<void>;
  10094. /**
  10095. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10096. * @param subMesh The submesh we want to render in the shadow map
  10097. * @param useInstances Defines wether will draw in the map using instances
  10098. * @returns true if ready otherwise, false
  10099. */
  10100. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10101. /**
  10102. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10103. * @param defines Defines of the material we want to update
  10104. * @param lightIndex Index of the light in the enabled light list of the material
  10105. */
  10106. prepareDefines(defines: any, lightIndex: number): void;
  10107. /**
  10108. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10109. * defined in the generator but impacting the effect).
  10110. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10111. * @param effect The effect we are binfing the information for
  10112. */
  10113. bindShadowLight(lightIndex: string, effect: Effect): void;
  10114. /**
  10115. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10116. * (eq to shadow prjection matrix * light transform matrix)
  10117. * @returns The transform matrix used to create the shadow map
  10118. */
  10119. getTransformMatrix(): Matrix;
  10120. /**
  10121. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10122. * Cube and 2D textures for instance.
  10123. */
  10124. recreateShadowMap(): void;
  10125. private _disposeBlurPostProcesses;
  10126. private _disposeRTTandPostProcesses;
  10127. /**
  10128. * Disposes the ShadowGenerator.
  10129. * Returns nothing.
  10130. */
  10131. dispose(): void;
  10132. /**
  10133. * Serializes the shadow generator setup to a json object.
  10134. * @returns The serialized JSON object
  10135. */
  10136. serialize(): any;
  10137. /**
  10138. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10139. * @param parsedShadowGenerator The JSON object to parse
  10140. * @param scene The scene to create the shadow map for
  10141. * @returns The parsed shadow generator
  10142. */
  10143. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10144. }
  10145. }
  10146. declare module "babylonjs/Lights/light" {
  10147. import { Nullable } from "babylonjs/types";
  10148. import { Scene } from "babylonjs/scene";
  10149. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10150. import { Node } from "babylonjs/node";
  10151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10152. import { Effect } from "babylonjs/Materials/effect";
  10153. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10154. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10155. /**
  10156. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10157. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10158. * 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.
  10159. */
  10160. export abstract class Light extends Node {
  10161. /**
  10162. * Falloff Default: light is falling off following the material specification:
  10163. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10164. */
  10165. static readonly FALLOFF_DEFAULT: number;
  10166. /**
  10167. * Falloff Physical: light is falling off following the inverse squared distance law.
  10168. */
  10169. static readonly FALLOFF_PHYSICAL: number;
  10170. /**
  10171. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10172. * to enhance interoperability with other engines.
  10173. */
  10174. static readonly FALLOFF_GLTF: number;
  10175. /**
  10176. * Falloff Standard: light is falling off like in the standard material
  10177. * to enhance interoperability with other materials.
  10178. */
  10179. static readonly FALLOFF_STANDARD: number;
  10180. /**
  10181. * If every light affecting the material is in this lightmapMode,
  10182. * material.lightmapTexture adds or multiplies
  10183. * (depends on material.useLightmapAsShadowmap)
  10184. * after every other light calculations.
  10185. */
  10186. static readonly LIGHTMAP_DEFAULT: number;
  10187. /**
  10188. * material.lightmapTexture as only diffuse lighting from this light
  10189. * adds only specular lighting from this light
  10190. * adds dynamic shadows
  10191. */
  10192. static readonly LIGHTMAP_SPECULAR: number;
  10193. /**
  10194. * material.lightmapTexture as only lighting
  10195. * no light calculation from this light
  10196. * only adds dynamic shadows from this light
  10197. */
  10198. static readonly LIGHTMAP_SHADOWSONLY: number;
  10199. /**
  10200. * Each light type uses the default quantity according to its type:
  10201. * point/spot lights use luminous intensity
  10202. * directional lights use illuminance
  10203. */
  10204. static readonly INTENSITYMODE_AUTOMATIC: number;
  10205. /**
  10206. * lumen (lm)
  10207. */
  10208. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10209. /**
  10210. * candela (lm/sr)
  10211. */
  10212. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10213. /**
  10214. * lux (lm/m^2)
  10215. */
  10216. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10217. /**
  10218. * nit (cd/m^2)
  10219. */
  10220. static readonly INTENSITYMODE_LUMINANCE: number;
  10221. /**
  10222. * Light type const id of the point light.
  10223. */
  10224. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10225. /**
  10226. * Light type const id of the directional light.
  10227. */
  10228. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10229. /**
  10230. * Light type const id of the spot light.
  10231. */
  10232. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10233. /**
  10234. * Light type const id of the hemispheric light.
  10235. */
  10236. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10237. /**
  10238. * Diffuse gives the basic color to an object.
  10239. */
  10240. diffuse: Color3;
  10241. /**
  10242. * Specular produces a highlight color on an object.
  10243. * Note: This is note affecting PBR materials.
  10244. */
  10245. specular: Color3;
  10246. /**
  10247. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10248. * falling off base on range or angle.
  10249. * This can be set to any values in Light.FALLOFF_x.
  10250. *
  10251. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10252. * other types of materials.
  10253. */
  10254. falloffType: number;
  10255. /**
  10256. * Strength of the light.
  10257. * Note: By default it is define in the framework own unit.
  10258. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10259. */
  10260. intensity: number;
  10261. private _range;
  10262. protected _inverseSquaredRange: number;
  10263. /**
  10264. * Defines how far from the source the light is impacting in scene units.
  10265. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10266. */
  10267. /**
  10268. * Defines how far from the source the light is impacting in scene units.
  10269. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10270. */
  10271. range: number;
  10272. /**
  10273. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10274. * of light.
  10275. */
  10276. private _photometricScale;
  10277. private _intensityMode;
  10278. /**
  10279. * Gets the photometric scale used to interpret the intensity.
  10280. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10281. */
  10282. /**
  10283. * Sets the photometric scale used to interpret the intensity.
  10284. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10285. */
  10286. intensityMode: number;
  10287. private _radius;
  10288. /**
  10289. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10290. */
  10291. /**
  10292. * sets the light radius used by PBR Materials to simulate soft area lights.
  10293. */
  10294. radius: number;
  10295. private _renderPriority;
  10296. /**
  10297. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10298. * exceeding the number allowed of the materials.
  10299. */
  10300. renderPriority: number;
  10301. private _shadowEnabled;
  10302. /**
  10303. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10304. * the current shadow generator.
  10305. */
  10306. /**
  10307. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10308. * the current shadow generator.
  10309. */
  10310. shadowEnabled: boolean;
  10311. private _includedOnlyMeshes;
  10312. /**
  10313. * Gets the only meshes impacted by this light.
  10314. */
  10315. /**
  10316. * Sets the only meshes impacted by this light.
  10317. */
  10318. includedOnlyMeshes: AbstractMesh[];
  10319. private _excludedMeshes;
  10320. /**
  10321. * Gets the meshes not impacted by this light.
  10322. */
  10323. /**
  10324. * Sets the meshes not impacted by this light.
  10325. */
  10326. excludedMeshes: AbstractMesh[];
  10327. private _excludeWithLayerMask;
  10328. /**
  10329. * Gets the layer id use to find what meshes are not impacted by the light.
  10330. * Inactive if 0
  10331. */
  10332. /**
  10333. * Sets the layer id use to find what meshes are not impacted by the light.
  10334. * Inactive if 0
  10335. */
  10336. excludeWithLayerMask: number;
  10337. private _includeOnlyWithLayerMask;
  10338. /**
  10339. * Gets the layer id use to find what meshes are impacted by the light.
  10340. * Inactive if 0
  10341. */
  10342. /**
  10343. * Sets the layer id use to find what meshes are impacted by the light.
  10344. * Inactive if 0
  10345. */
  10346. includeOnlyWithLayerMask: number;
  10347. private _lightmapMode;
  10348. /**
  10349. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10350. */
  10351. /**
  10352. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10353. */
  10354. lightmapMode: number;
  10355. /**
  10356. * Shadow generator associted to the light.
  10357. * @hidden Internal use only.
  10358. */
  10359. _shadowGenerator: Nullable<IShadowGenerator>;
  10360. /**
  10361. * @hidden Internal use only.
  10362. */
  10363. _excludedMeshesIds: string[];
  10364. /**
  10365. * @hidden Internal use only.
  10366. */
  10367. _includedOnlyMeshesIds: string[];
  10368. /**
  10369. * The current light unifom buffer.
  10370. * @hidden Internal use only.
  10371. */
  10372. _uniformBuffer: UniformBuffer;
  10373. /**
  10374. * Creates a Light object in the scene.
  10375. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10376. * @param name The firendly name of the light
  10377. * @param scene The scene the light belongs too
  10378. */
  10379. constructor(name: string, scene: Scene);
  10380. protected abstract _buildUniformLayout(): void;
  10381. /**
  10382. * Sets the passed Effect "effect" with the Light information.
  10383. * @param effect The effect to update
  10384. * @param lightIndex The index of the light in the effect to update
  10385. * @returns The light
  10386. */
  10387. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10388. /**
  10389. * Returns the string "Light".
  10390. * @returns the class name
  10391. */
  10392. getClassName(): string;
  10393. /** @hidden */
  10394. readonly _isLight: boolean;
  10395. /**
  10396. * Converts the light information to a readable string for debug purpose.
  10397. * @param fullDetails Supports for multiple levels of logging within scene loading
  10398. * @returns the human readable light info
  10399. */
  10400. toString(fullDetails?: boolean): string;
  10401. /** @hidden */
  10402. protected _syncParentEnabledState(): void;
  10403. /**
  10404. * Set the enabled state of this node.
  10405. * @param value - the new enabled state
  10406. */
  10407. setEnabled(value: boolean): void;
  10408. /**
  10409. * Returns the Light associated shadow generator if any.
  10410. * @return the associated shadow generator.
  10411. */
  10412. getShadowGenerator(): Nullable<IShadowGenerator>;
  10413. /**
  10414. * Returns a Vector3, the absolute light position in the World.
  10415. * @returns the world space position of the light
  10416. */
  10417. getAbsolutePosition(): Vector3;
  10418. /**
  10419. * Specifies if the light will affect the passed mesh.
  10420. * @param mesh The mesh to test against the light
  10421. * @return true the mesh is affected otherwise, false.
  10422. */
  10423. canAffectMesh(mesh: AbstractMesh): boolean;
  10424. /**
  10425. * Sort function to order lights for rendering.
  10426. * @param a First Light object to compare to second.
  10427. * @param b Second Light object to compare first.
  10428. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10429. */
  10430. static CompareLightsPriority(a: Light, b: Light): number;
  10431. /**
  10432. * Releases resources associated with this node.
  10433. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10434. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10435. */
  10436. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10437. /**
  10438. * Returns the light type ID (integer).
  10439. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10440. */
  10441. getTypeID(): number;
  10442. /**
  10443. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10444. * @returns the scaled intensity in intensity mode unit
  10445. */
  10446. getScaledIntensity(): number;
  10447. /**
  10448. * Returns a new Light object, named "name", from the current one.
  10449. * @param name The name of the cloned light
  10450. * @returns the new created light
  10451. */
  10452. clone(name: string): Nullable<Light>;
  10453. /**
  10454. * Serializes the current light into a Serialization object.
  10455. * @returns the serialized object.
  10456. */
  10457. serialize(): any;
  10458. /**
  10459. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10460. * This new light is named "name" and added to the passed scene.
  10461. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10462. * @param name The friendly name of the light
  10463. * @param scene The scene the new light will belong to
  10464. * @returns the constructor function
  10465. */
  10466. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10467. /**
  10468. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10469. * @param parsedLight The JSON representation of the light
  10470. * @param scene The scene to create the parsed light in
  10471. * @returns the created light after parsing
  10472. */
  10473. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10474. private _hookArrayForExcluded;
  10475. private _hookArrayForIncludedOnly;
  10476. private _resyncMeshes;
  10477. /**
  10478. * Forces the meshes to update their light related information in their rendering used effects
  10479. * @hidden Internal Use Only
  10480. */
  10481. _markMeshesAsLightDirty(): void;
  10482. /**
  10483. * Recomputes the cached photometric scale if needed.
  10484. */
  10485. private _computePhotometricScale;
  10486. /**
  10487. * Returns the Photometric Scale according to the light type and intensity mode.
  10488. */
  10489. private _getPhotometricScale;
  10490. /**
  10491. * Reorder the light in the scene according to their defined priority.
  10492. * @hidden Internal Use Only
  10493. */
  10494. _reorderLightsInScene(): void;
  10495. /**
  10496. * Prepares the list of defines specific to the light type.
  10497. * @param defines the list of defines
  10498. * @param lightIndex defines the index of the light for the effect
  10499. */
  10500. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10501. }
  10502. }
  10503. declare module "babylonjs/Actions/action" {
  10504. import { Observable } from "babylonjs/Misc/observable";
  10505. import { Condition } from "babylonjs/Actions/condition";
  10506. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10507. import { ActionManager } from "babylonjs/Actions/actionManager";
  10508. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10509. /**
  10510. * Interface used to define Action
  10511. */
  10512. export interface IAction {
  10513. /**
  10514. * Trigger for the action
  10515. */
  10516. trigger: number;
  10517. /** Options of the trigger */
  10518. triggerOptions: any;
  10519. /**
  10520. * Gets the trigger parameters
  10521. * @returns the trigger parameters
  10522. */
  10523. getTriggerParameter(): any;
  10524. /**
  10525. * Internal only - executes current action event
  10526. * @hidden
  10527. */
  10528. _executeCurrent(evt?: ActionEvent): void;
  10529. /**
  10530. * Serialize placeholder for child classes
  10531. * @param parent of child
  10532. * @returns the serialized object
  10533. */
  10534. serialize(parent: any): any;
  10535. /**
  10536. * Internal only
  10537. * @hidden
  10538. */
  10539. _prepare(): void;
  10540. /**
  10541. * Internal only - manager for action
  10542. * @hidden
  10543. */
  10544. _actionManager: AbstractActionManager;
  10545. }
  10546. /**
  10547. * The action to be carried out following a trigger
  10548. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10549. */
  10550. export class Action implements IAction {
  10551. /** the trigger, with or without parameters, for the action */
  10552. triggerOptions: any;
  10553. /**
  10554. * Trigger for the action
  10555. */
  10556. trigger: number;
  10557. /**
  10558. * Internal only - manager for action
  10559. * @hidden
  10560. */
  10561. _actionManager: ActionManager;
  10562. private _nextActiveAction;
  10563. private _child;
  10564. private _condition?;
  10565. private _triggerParameter;
  10566. /**
  10567. * An event triggered prior to action being executed.
  10568. */
  10569. onBeforeExecuteObservable: Observable<Action>;
  10570. /**
  10571. * Creates a new Action
  10572. * @param triggerOptions the trigger, with or without parameters, for the action
  10573. * @param condition an optional determinant of action
  10574. */
  10575. constructor(
  10576. /** the trigger, with or without parameters, for the action */
  10577. triggerOptions: any, condition?: Condition);
  10578. /**
  10579. * Internal only
  10580. * @hidden
  10581. */
  10582. _prepare(): void;
  10583. /**
  10584. * Gets the trigger parameters
  10585. * @returns the trigger parameters
  10586. */
  10587. getTriggerParameter(): any;
  10588. /**
  10589. * Internal only - executes current action event
  10590. * @hidden
  10591. */
  10592. _executeCurrent(evt?: ActionEvent): void;
  10593. /**
  10594. * Execute placeholder for child classes
  10595. * @param evt optional action event
  10596. */
  10597. execute(evt?: ActionEvent): void;
  10598. /**
  10599. * Skips to next active action
  10600. */
  10601. skipToNextActiveAction(): void;
  10602. /**
  10603. * Adds action to chain of actions, may be a DoNothingAction
  10604. * @param action defines the next action to execute
  10605. * @returns The action passed in
  10606. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10607. */
  10608. then(action: Action): Action;
  10609. /**
  10610. * Internal only
  10611. * @hidden
  10612. */
  10613. _getProperty(propertyPath: string): string;
  10614. /**
  10615. * Internal only
  10616. * @hidden
  10617. */
  10618. _getEffectiveTarget(target: any, propertyPath: string): any;
  10619. /**
  10620. * Serialize placeholder for child classes
  10621. * @param parent of child
  10622. * @returns the serialized object
  10623. */
  10624. serialize(parent: any): any;
  10625. /**
  10626. * Internal only called by serialize
  10627. * @hidden
  10628. */
  10629. protected _serialize(serializedAction: any, parent?: any): any;
  10630. /**
  10631. * Internal only
  10632. * @hidden
  10633. */
  10634. static _SerializeValueAsString: (value: any) => string;
  10635. /**
  10636. * Internal only
  10637. * @hidden
  10638. */
  10639. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10640. name: string;
  10641. targetType: string;
  10642. value: string;
  10643. };
  10644. }
  10645. }
  10646. declare module "babylonjs/Actions/condition" {
  10647. import { ActionManager } from "babylonjs/Actions/actionManager";
  10648. /**
  10649. * A Condition applied to an Action
  10650. */
  10651. export class Condition {
  10652. /**
  10653. * Internal only - manager for action
  10654. * @hidden
  10655. */
  10656. _actionManager: ActionManager;
  10657. /**
  10658. * Internal only
  10659. * @hidden
  10660. */
  10661. _evaluationId: number;
  10662. /**
  10663. * Internal only
  10664. * @hidden
  10665. */
  10666. _currentResult: boolean;
  10667. /**
  10668. * Creates a new Condition
  10669. * @param actionManager the manager of the action the condition is applied to
  10670. */
  10671. constructor(actionManager: ActionManager);
  10672. /**
  10673. * Check if the current condition is valid
  10674. * @returns a boolean
  10675. */
  10676. isValid(): boolean;
  10677. /**
  10678. * Internal only
  10679. * @hidden
  10680. */
  10681. _getProperty(propertyPath: string): string;
  10682. /**
  10683. * Internal only
  10684. * @hidden
  10685. */
  10686. _getEffectiveTarget(target: any, propertyPath: string): any;
  10687. /**
  10688. * Serialize placeholder for child classes
  10689. * @returns the serialized object
  10690. */
  10691. serialize(): any;
  10692. /**
  10693. * Internal only
  10694. * @hidden
  10695. */
  10696. protected _serialize(serializedCondition: any): any;
  10697. }
  10698. /**
  10699. * Defines specific conditional operators as extensions of Condition
  10700. */
  10701. export class ValueCondition extends Condition {
  10702. /** path to specify the property of the target the conditional operator uses */
  10703. propertyPath: string;
  10704. /** the value compared by the conditional operator against the current value of the property */
  10705. value: any;
  10706. /** the conditional operator, default ValueCondition.IsEqual */
  10707. operator: number;
  10708. /**
  10709. * Internal only
  10710. * @hidden
  10711. */
  10712. private static _IsEqual;
  10713. /**
  10714. * Internal only
  10715. * @hidden
  10716. */
  10717. private static _IsDifferent;
  10718. /**
  10719. * Internal only
  10720. * @hidden
  10721. */
  10722. private static _IsGreater;
  10723. /**
  10724. * Internal only
  10725. * @hidden
  10726. */
  10727. private static _IsLesser;
  10728. /**
  10729. * returns the number for IsEqual
  10730. */
  10731. static readonly IsEqual: number;
  10732. /**
  10733. * Returns the number for IsDifferent
  10734. */
  10735. static readonly IsDifferent: number;
  10736. /**
  10737. * Returns the number for IsGreater
  10738. */
  10739. static readonly IsGreater: number;
  10740. /**
  10741. * Returns the number for IsLesser
  10742. */
  10743. static readonly IsLesser: number;
  10744. /**
  10745. * Internal only The action manager for the condition
  10746. * @hidden
  10747. */
  10748. _actionManager: ActionManager;
  10749. /**
  10750. * Internal only
  10751. * @hidden
  10752. */
  10753. private _target;
  10754. /**
  10755. * Internal only
  10756. * @hidden
  10757. */
  10758. private _effectiveTarget;
  10759. /**
  10760. * Internal only
  10761. * @hidden
  10762. */
  10763. private _property;
  10764. /**
  10765. * Creates a new ValueCondition
  10766. * @param actionManager manager for the action the condition applies to
  10767. * @param target for the action
  10768. * @param propertyPath path to specify the property of the target the conditional operator uses
  10769. * @param value the value compared by the conditional operator against the current value of the property
  10770. * @param operator the conditional operator, default ValueCondition.IsEqual
  10771. */
  10772. constructor(actionManager: ActionManager, target: any,
  10773. /** path to specify the property of the target the conditional operator uses */
  10774. propertyPath: string,
  10775. /** the value compared by the conditional operator against the current value of the property */
  10776. value: any,
  10777. /** the conditional operator, default ValueCondition.IsEqual */
  10778. operator?: number);
  10779. /**
  10780. * Compares the given value with the property value for the specified conditional operator
  10781. * @returns the result of the comparison
  10782. */
  10783. isValid(): boolean;
  10784. /**
  10785. * Serialize the ValueCondition into a JSON compatible object
  10786. * @returns serialization object
  10787. */
  10788. serialize(): any;
  10789. /**
  10790. * Gets the name of the conditional operator for the ValueCondition
  10791. * @param operator the conditional operator
  10792. * @returns the name
  10793. */
  10794. static GetOperatorName(operator: number): string;
  10795. }
  10796. /**
  10797. * Defines a predicate condition as an extension of Condition
  10798. */
  10799. export class PredicateCondition extends Condition {
  10800. /** defines the predicate function used to validate the condition */
  10801. predicate: () => boolean;
  10802. /**
  10803. * Internal only - manager for action
  10804. * @hidden
  10805. */
  10806. _actionManager: ActionManager;
  10807. /**
  10808. * Creates a new PredicateCondition
  10809. * @param actionManager manager for the action the condition applies to
  10810. * @param predicate defines the predicate function used to validate the condition
  10811. */
  10812. constructor(actionManager: ActionManager,
  10813. /** defines the predicate function used to validate the condition */
  10814. predicate: () => boolean);
  10815. /**
  10816. * @returns the validity of the predicate condition
  10817. */
  10818. isValid(): boolean;
  10819. }
  10820. /**
  10821. * Defines a state condition as an extension of Condition
  10822. */
  10823. export class StateCondition extends Condition {
  10824. /** Value to compare with target state */
  10825. value: string;
  10826. /**
  10827. * Internal only - manager for action
  10828. * @hidden
  10829. */
  10830. _actionManager: ActionManager;
  10831. /**
  10832. * Internal only
  10833. * @hidden
  10834. */
  10835. private _target;
  10836. /**
  10837. * Creates a new StateCondition
  10838. * @param actionManager manager for the action the condition applies to
  10839. * @param target of the condition
  10840. * @param value to compare with target state
  10841. */
  10842. constructor(actionManager: ActionManager, target: any,
  10843. /** Value to compare with target state */
  10844. value: string);
  10845. /**
  10846. * Gets a boolean indicating if the current condition is met
  10847. * @returns the validity of the state
  10848. */
  10849. isValid(): boolean;
  10850. /**
  10851. * Serialize the StateCondition into a JSON compatible object
  10852. * @returns serialization object
  10853. */
  10854. serialize(): any;
  10855. }
  10856. }
  10857. declare module "babylonjs/Actions/directActions" {
  10858. import { Action } from "babylonjs/Actions/action";
  10859. import { Condition } from "babylonjs/Actions/condition";
  10860. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10861. /**
  10862. * This defines an action responsible to toggle a boolean once triggered.
  10863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10864. */
  10865. export class SwitchBooleanAction extends Action {
  10866. /**
  10867. * The path to the boolean property in the target object
  10868. */
  10869. propertyPath: string;
  10870. private _target;
  10871. private _effectiveTarget;
  10872. private _property;
  10873. /**
  10874. * Instantiate the action
  10875. * @param triggerOptions defines the trigger options
  10876. * @param target defines the object containing the boolean
  10877. * @param propertyPath defines the path to the boolean property in the target object
  10878. * @param condition defines the trigger related conditions
  10879. */
  10880. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10881. /** @hidden */
  10882. _prepare(): void;
  10883. /**
  10884. * Execute the action toggle the boolean value.
  10885. */
  10886. execute(): void;
  10887. /**
  10888. * Serializes the actions and its related information.
  10889. * @param parent defines the object to serialize in
  10890. * @returns the serialized object
  10891. */
  10892. serialize(parent: any): any;
  10893. }
  10894. /**
  10895. * This defines an action responsible to set a the state field of the target
  10896. * to a desired value once triggered.
  10897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10898. */
  10899. export class SetStateAction extends Action {
  10900. /**
  10901. * The value to store in the state field.
  10902. */
  10903. value: string;
  10904. private _target;
  10905. /**
  10906. * Instantiate the action
  10907. * @param triggerOptions defines the trigger options
  10908. * @param target defines the object containing the state property
  10909. * @param value defines the value to store in the state field
  10910. * @param condition defines the trigger related conditions
  10911. */
  10912. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10913. /**
  10914. * Execute the action and store the value on the target state property.
  10915. */
  10916. execute(): void;
  10917. /**
  10918. * Serializes the actions and its related information.
  10919. * @param parent defines the object to serialize in
  10920. * @returns the serialized object
  10921. */
  10922. serialize(parent: any): any;
  10923. }
  10924. /**
  10925. * This defines an action responsible to set a property of the target
  10926. * to a desired value once triggered.
  10927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10928. */
  10929. export class SetValueAction extends Action {
  10930. /**
  10931. * The path of the property to set in the target.
  10932. */
  10933. propertyPath: string;
  10934. /**
  10935. * The value to set in the property
  10936. */
  10937. value: any;
  10938. private _target;
  10939. private _effectiveTarget;
  10940. private _property;
  10941. /**
  10942. * Instantiate the action
  10943. * @param triggerOptions defines the trigger options
  10944. * @param target defines the object containing the property
  10945. * @param propertyPath defines the path of the property to set in the target
  10946. * @param value defines the value to set in the property
  10947. * @param condition defines the trigger related conditions
  10948. */
  10949. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10950. /** @hidden */
  10951. _prepare(): void;
  10952. /**
  10953. * Execute the action and set the targetted property to the desired value.
  10954. */
  10955. execute(): void;
  10956. /**
  10957. * Serializes the actions and its related information.
  10958. * @param parent defines the object to serialize in
  10959. * @returns the serialized object
  10960. */
  10961. serialize(parent: any): any;
  10962. }
  10963. /**
  10964. * This defines an action responsible to increment the target value
  10965. * to a desired value once triggered.
  10966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10967. */
  10968. export class IncrementValueAction extends Action {
  10969. /**
  10970. * The path of the property to increment in the target.
  10971. */
  10972. propertyPath: string;
  10973. /**
  10974. * The value we should increment the property by.
  10975. */
  10976. value: any;
  10977. private _target;
  10978. private _effectiveTarget;
  10979. private _property;
  10980. /**
  10981. * Instantiate the action
  10982. * @param triggerOptions defines the trigger options
  10983. * @param target defines the object containing the property
  10984. * @param propertyPath defines the path of the property to increment in the target
  10985. * @param value defines the value value we should increment the property by
  10986. * @param condition defines the trigger related conditions
  10987. */
  10988. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10989. /** @hidden */
  10990. _prepare(): void;
  10991. /**
  10992. * Execute the action and increment the target of the value amount.
  10993. */
  10994. execute(): void;
  10995. /**
  10996. * Serializes the actions and its related information.
  10997. * @param parent defines the object to serialize in
  10998. * @returns the serialized object
  10999. */
  11000. serialize(parent: any): any;
  11001. }
  11002. /**
  11003. * This defines an action responsible to start an animation once triggered.
  11004. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11005. */
  11006. export class PlayAnimationAction extends Action {
  11007. /**
  11008. * Where the animation should start (animation frame)
  11009. */
  11010. from: number;
  11011. /**
  11012. * Where the animation should stop (animation frame)
  11013. */
  11014. to: number;
  11015. /**
  11016. * Define if the animation should loop or stop after the first play.
  11017. */
  11018. loop?: boolean;
  11019. private _target;
  11020. /**
  11021. * Instantiate the action
  11022. * @param triggerOptions defines the trigger options
  11023. * @param target defines the target animation or animation name
  11024. * @param from defines from where the animation should start (animation frame)
  11025. * @param end defines where the animation should stop (animation frame)
  11026. * @param loop defines if the animation should loop or stop after the first play
  11027. * @param condition defines the trigger related conditions
  11028. */
  11029. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11030. /** @hidden */
  11031. _prepare(): void;
  11032. /**
  11033. * Execute the action and play the animation.
  11034. */
  11035. execute(): void;
  11036. /**
  11037. * Serializes the actions and its related information.
  11038. * @param parent defines the object to serialize in
  11039. * @returns the serialized object
  11040. */
  11041. serialize(parent: any): any;
  11042. }
  11043. /**
  11044. * This defines an action responsible to stop an animation once triggered.
  11045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11046. */
  11047. export class StopAnimationAction extends Action {
  11048. private _target;
  11049. /**
  11050. * Instantiate the action
  11051. * @param triggerOptions defines the trigger options
  11052. * @param target defines the target animation or animation name
  11053. * @param condition defines the trigger related conditions
  11054. */
  11055. constructor(triggerOptions: any, target: any, condition?: Condition);
  11056. /** @hidden */
  11057. _prepare(): void;
  11058. /**
  11059. * Execute the action and stop the animation.
  11060. */
  11061. execute(): void;
  11062. /**
  11063. * Serializes the actions and its related information.
  11064. * @param parent defines the object to serialize in
  11065. * @returns the serialized object
  11066. */
  11067. serialize(parent: any): any;
  11068. }
  11069. /**
  11070. * This defines an action responsible that does nothing once triggered.
  11071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11072. */
  11073. export class DoNothingAction extends Action {
  11074. /**
  11075. * Instantiate the action
  11076. * @param triggerOptions defines the trigger options
  11077. * @param condition defines the trigger related conditions
  11078. */
  11079. constructor(triggerOptions?: any, condition?: Condition);
  11080. /**
  11081. * Execute the action and do nothing.
  11082. */
  11083. execute(): void;
  11084. /**
  11085. * Serializes the actions and its related information.
  11086. * @param parent defines the object to serialize in
  11087. * @returns the serialized object
  11088. */
  11089. serialize(parent: any): any;
  11090. }
  11091. /**
  11092. * This defines an action responsible to trigger several actions once triggered.
  11093. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11094. */
  11095. export class CombineAction extends Action {
  11096. /**
  11097. * The list of aggregated animations to run.
  11098. */
  11099. children: Action[];
  11100. /**
  11101. * Instantiate the action
  11102. * @param triggerOptions defines the trigger options
  11103. * @param children defines the list of aggregated animations to run
  11104. * @param condition defines the trigger related conditions
  11105. */
  11106. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11107. /** @hidden */
  11108. _prepare(): void;
  11109. /**
  11110. * Execute the action and executes all the aggregated actions.
  11111. */
  11112. execute(evt: ActionEvent): void;
  11113. /**
  11114. * Serializes the actions and its related information.
  11115. * @param parent defines the object to serialize in
  11116. * @returns the serialized object
  11117. */
  11118. serialize(parent: any): any;
  11119. }
  11120. /**
  11121. * This defines an action responsible to run code (external event) once triggered.
  11122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11123. */
  11124. export class ExecuteCodeAction extends Action {
  11125. /**
  11126. * The callback function to run.
  11127. */
  11128. func: (evt: ActionEvent) => void;
  11129. /**
  11130. * Instantiate the action
  11131. * @param triggerOptions defines the trigger options
  11132. * @param func defines the callback function to run
  11133. * @param condition defines the trigger related conditions
  11134. */
  11135. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11136. /**
  11137. * Execute the action and run the attached code.
  11138. */
  11139. execute(evt: ActionEvent): void;
  11140. }
  11141. /**
  11142. * This defines an action responsible to set the parent property of the target once triggered.
  11143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11144. */
  11145. export class SetParentAction extends Action {
  11146. private _parent;
  11147. private _target;
  11148. /**
  11149. * Instantiate the action
  11150. * @param triggerOptions defines the trigger options
  11151. * @param target defines the target containing the parent property
  11152. * @param parent defines from where the animation should start (animation frame)
  11153. * @param condition defines the trigger related conditions
  11154. */
  11155. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11156. /** @hidden */
  11157. _prepare(): void;
  11158. /**
  11159. * Execute the action and set the parent property.
  11160. */
  11161. execute(): void;
  11162. /**
  11163. * Serializes the actions and its related information.
  11164. * @param parent defines the object to serialize in
  11165. * @returns the serialized object
  11166. */
  11167. serialize(parent: any): any;
  11168. }
  11169. }
  11170. declare module "babylonjs/Actions/actionManager" {
  11171. import { Nullable } from "babylonjs/types";
  11172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11173. import { Scene } from "babylonjs/scene";
  11174. import { IAction } from "babylonjs/Actions/action";
  11175. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11176. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11177. /**
  11178. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11179. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11181. */
  11182. export class ActionManager extends AbstractActionManager {
  11183. /**
  11184. * Nothing
  11185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11186. */
  11187. static readonly NothingTrigger: number;
  11188. /**
  11189. * On pick
  11190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11191. */
  11192. static readonly OnPickTrigger: number;
  11193. /**
  11194. * On left pick
  11195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11196. */
  11197. static readonly OnLeftPickTrigger: number;
  11198. /**
  11199. * On right pick
  11200. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11201. */
  11202. static readonly OnRightPickTrigger: number;
  11203. /**
  11204. * On center pick
  11205. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11206. */
  11207. static readonly OnCenterPickTrigger: number;
  11208. /**
  11209. * On pick down
  11210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11211. */
  11212. static readonly OnPickDownTrigger: number;
  11213. /**
  11214. * On double pick
  11215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11216. */
  11217. static readonly OnDoublePickTrigger: number;
  11218. /**
  11219. * On pick up
  11220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11221. */
  11222. static readonly OnPickUpTrigger: number;
  11223. /**
  11224. * On pick out.
  11225. * This trigger will only be raised if you also declared a OnPickDown
  11226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11227. */
  11228. static readonly OnPickOutTrigger: number;
  11229. /**
  11230. * On long press
  11231. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11232. */
  11233. static readonly OnLongPressTrigger: number;
  11234. /**
  11235. * On pointer over
  11236. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11237. */
  11238. static readonly OnPointerOverTrigger: number;
  11239. /**
  11240. * On pointer out
  11241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11242. */
  11243. static readonly OnPointerOutTrigger: number;
  11244. /**
  11245. * On every frame
  11246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11247. */
  11248. static readonly OnEveryFrameTrigger: number;
  11249. /**
  11250. * On intersection enter
  11251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11252. */
  11253. static readonly OnIntersectionEnterTrigger: number;
  11254. /**
  11255. * On intersection exit
  11256. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11257. */
  11258. static readonly OnIntersectionExitTrigger: number;
  11259. /**
  11260. * On key down
  11261. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11262. */
  11263. static readonly OnKeyDownTrigger: number;
  11264. /**
  11265. * On key up
  11266. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11267. */
  11268. static readonly OnKeyUpTrigger: number;
  11269. private _scene;
  11270. /**
  11271. * Creates a new action manager
  11272. * @param scene defines the hosting scene
  11273. */
  11274. constructor(scene: Scene);
  11275. /**
  11276. * Releases all associated resources
  11277. */
  11278. dispose(): void;
  11279. /**
  11280. * Gets hosting scene
  11281. * @returns the hosting scene
  11282. */
  11283. getScene(): Scene;
  11284. /**
  11285. * Does this action manager handles actions of any of the given triggers
  11286. * @param triggers defines the triggers to be tested
  11287. * @return a boolean indicating whether one (or more) of the triggers is handled
  11288. */
  11289. hasSpecificTriggers(triggers: number[]): boolean;
  11290. /**
  11291. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11292. * speed.
  11293. * @param triggerA defines the trigger to be tested
  11294. * @param triggerB defines the trigger to be tested
  11295. * @return a boolean indicating whether one (or more) of the triggers is handled
  11296. */
  11297. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11298. /**
  11299. * Does this action manager handles actions of a given trigger
  11300. * @param trigger defines the trigger to be tested
  11301. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11302. * @return whether the trigger is handled
  11303. */
  11304. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11305. /**
  11306. * Does this action manager has pointer triggers
  11307. */
  11308. readonly hasPointerTriggers: boolean;
  11309. /**
  11310. * Does this action manager has pick triggers
  11311. */
  11312. readonly hasPickTriggers: boolean;
  11313. /**
  11314. * Registers an action to this action manager
  11315. * @param action defines the action to be registered
  11316. * @return the action amended (prepared) after registration
  11317. */
  11318. registerAction(action: IAction): Nullable<IAction>;
  11319. /**
  11320. * Unregisters an action to this action manager
  11321. * @param action defines the action to be unregistered
  11322. * @return a boolean indicating whether the action has been unregistered
  11323. */
  11324. unregisterAction(action: IAction): Boolean;
  11325. /**
  11326. * Process a specific trigger
  11327. * @param trigger defines the trigger to process
  11328. * @param evt defines the event details to be processed
  11329. */
  11330. processTrigger(trigger: number, evt?: IActionEvent): void;
  11331. /** @hidden */
  11332. _getEffectiveTarget(target: any, propertyPath: string): any;
  11333. /** @hidden */
  11334. _getProperty(propertyPath: string): string;
  11335. /**
  11336. * Serialize this manager to a JSON object
  11337. * @param name defines the property name to store this manager
  11338. * @returns a JSON representation of this manager
  11339. */
  11340. serialize(name: string): any;
  11341. /**
  11342. * Creates a new ActionManager from a JSON data
  11343. * @param parsedActions defines the JSON data to read from
  11344. * @param object defines the hosting mesh
  11345. * @param scene defines the hosting scene
  11346. */
  11347. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11348. /**
  11349. * Get a trigger name by index
  11350. * @param trigger defines the trigger index
  11351. * @returns a trigger name
  11352. */
  11353. static GetTriggerName(trigger: number): string;
  11354. }
  11355. }
  11356. declare module "babylonjs/Culling/ray" {
  11357. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11358. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11360. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11361. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11362. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11363. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11364. /**
  11365. * Class representing a ray with position and direction
  11366. */
  11367. export class Ray {
  11368. /** origin point */
  11369. origin: Vector3;
  11370. /** direction */
  11371. direction: Vector3;
  11372. /** length of the ray */
  11373. length: number;
  11374. private static readonly TmpVector3;
  11375. private _tmpRay;
  11376. /**
  11377. * Creates a new ray
  11378. * @param origin origin point
  11379. * @param direction direction
  11380. * @param length length of the ray
  11381. */
  11382. constructor(
  11383. /** origin point */
  11384. origin: Vector3,
  11385. /** direction */
  11386. direction: Vector3,
  11387. /** length of the ray */
  11388. length?: number);
  11389. /**
  11390. * Checks if the ray intersects a box
  11391. * @param minimum bound of the box
  11392. * @param maximum bound of the box
  11393. * @param intersectionTreshold extra extend to be added to the box in all direction
  11394. * @returns if the box was hit
  11395. */
  11396. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11397. /**
  11398. * Checks if the ray intersects a box
  11399. * @param box the bounding box to check
  11400. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11401. * @returns if the box was hit
  11402. */
  11403. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11404. /**
  11405. * If the ray hits a sphere
  11406. * @param sphere the bounding sphere to check
  11407. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11408. * @returns true if it hits the sphere
  11409. */
  11410. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11411. /**
  11412. * If the ray hits a triange
  11413. * @param vertex0 triangle vertex
  11414. * @param vertex1 triangle vertex
  11415. * @param vertex2 triangle vertex
  11416. * @returns intersection information if hit
  11417. */
  11418. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11419. /**
  11420. * Checks if ray intersects a plane
  11421. * @param plane the plane to check
  11422. * @returns the distance away it was hit
  11423. */
  11424. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11425. /**
  11426. * Checks if ray intersects a mesh
  11427. * @param mesh the mesh to check
  11428. * @param fastCheck if only the bounding box should checked
  11429. * @returns picking info of the intersecton
  11430. */
  11431. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11432. /**
  11433. * Checks if ray intersects a mesh
  11434. * @param meshes the meshes to check
  11435. * @param fastCheck if only the bounding box should checked
  11436. * @param results array to store result in
  11437. * @returns Array of picking infos
  11438. */
  11439. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11440. private _comparePickingInfo;
  11441. private static smallnum;
  11442. private static rayl;
  11443. /**
  11444. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11445. * @param sega the first point of the segment to test the intersection against
  11446. * @param segb the second point of the segment to test the intersection against
  11447. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11448. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11449. */
  11450. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11451. /**
  11452. * Update the ray from viewport position
  11453. * @param x position
  11454. * @param y y position
  11455. * @param viewportWidth viewport width
  11456. * @param viewportHeight viewport height
  11457. * @param world world matrix
  11458. * @param view view matrix
  11459. * @param projection projection matrix
  11460. * @returns this ray updated
  11461. */
  11462. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11463. /**
  11464. * Creates a ray with origin and direction of 0,0,0
  11465. * @returns the new ray
  11466. */
  11467. static Zero(): Ray;
  11468. /**
  11469. * Creates a new ray from screen space and viewport
  11470. * @param x position
  11471. * @param y y position
  11472. * @param viewportWidth viewport width
  11473. * @param viewportHeight viewport height
  11474. * @param world world matrix
  11475. * @param view view matrix
  11476. * @param projection projection matrix
  11477. * @returns new ray
  11478. */
  11479. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11480. /**
  11481. * 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
  11482. * transformed to the given world matrix.
  11483. * @param origin The origin point
  11484. * @param end The end point
  11485. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11486. * @returns the new ray
  11487. */
  11488. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11489. /**
  11490. * Transforms a ray by a matrix
  11491. * @param ray ray to transform
  11492. * @param matrix matrix to apply
  11493. * @returns the resulting new ray
  11494. */
  11495. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11496. /**
  11497. * Transforms a ray by a matrix
  11498. * @param ray ray to transform
  11499. * @param matrix matrix to apply
  11500. * @param result ray to store result in
  11501. */
  11502. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11503. /**
  11504. * Unproject a ray from screen space to object space
  11505. * @param sourceX defines the screen space x coordinate to use
  11506. * @param sourceY defines the screen space y coordinate to use
  11507. * @param viewportWidth defines the current width of the viewport
  11508. * @param viewportHeight defines the current height of the viewport
  11509. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11510. * @param view defines the view matrix to use
  11511. * @param projection defines the projection matrix to use
  11512. */
  11513. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11514. }
  11515. /**
  11516. * Type used to define predicate used to select faces when a mesh intersection is detected
  11517. */
  11518. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11519. module "babylonjs/scene" {
  11520. interface Scene {
  11521. /** @hidden */
  11522. _tempPickingRay: Nullable<Ray>;
  11523. /** @hidden */
  11524. _cachedRayForTransform: Ray;
  11525. /** @hidden */
  11526. _pickWithRayInverseMatrix: Matrix;
  11527. /** @hidden */
  11528. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11529. /** @hidden */
  11530. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11531. }
  11532. }
  11533. }
  11534. declare module "babylonjs/sceneComponent" {
  11535. import { Scene } from "babylonjs/scene";
  11536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11537. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11538. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11539. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11540. import { Nullable } from "babylonjs/types";
  11541. import { Camera } from "babylonjs/Cameras/camera";
  11542. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11543. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11544. import { AbstractScene } from "babylonjs/abstractScene";
  11545. /**
  11546. * Groups all the scene component constants in one place to ease maintenance.
  11547. * @hidden
  11548. */
  11549. export class SceneComponentConstants {
  11550. static readonly NAME_EFFECTLAYER: string;
  11551. static readonly NAME_LAYER: string;
  11552. static readonly NAME_LENSFLARESYSTEM: string;
  11553. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11554. static readonly NAME_PARTICLESYSTEM: string;
  11555. static readonly NAME_GAMEPAD: string;
  11556. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11557. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11558. static readonly NAME_DEPTHRENDERER: string;
  11559. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11560. static readonly NAME_SPRITE: string;
  11561. static readonly NAME_OUTLINERENDERER: string;
  11562. static readonly NAME_PROCEDURALTEXTURE: string;
  11563. static readonly NAME_SHADOWGENERATOR: string;
  11564. static readonly NAME_OCTREE: string;
  11565. static readonly NAME_PHYSICSENGINE: string;
  11566. static readonly NAME_AUDIO: string;
  11567. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11568. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11569. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11570. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11571. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11572. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11573. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11574. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11575. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11576. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11577. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11578. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11579. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11580. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11581. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11582. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11583. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11584. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11585. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11586. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11587. static readonly STEP_AFTERRENDER_AUDIO: number;
  11588. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11589. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11590. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11591. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11592. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11593. static readonly STEP_POINTERMOVE_SPRITE: number;
  11594. static readonly STEP_POINTERDOWN_SPRITE: number;
  11595. static readonly STEP_POINTERUP_SPRITE: number;
  11596. }
  11597. /**
  11598. * This represents a scene component.
  11599. *
  11600. * This is used to decouple the dependency the scene is having on the different workloads like
  11601. * layers, post processes...
  11602. */
  11603. export interface ISceneComponent {
  11604. /**
  11605. * The name of the component. Each component must have a unique name.
  11606. */
  11607. name: string;
  11608. /**
  11609. * The scene the component belongs to.
  11610. */
  11611. scene: Scene;
  11612. /**
  11613. * Register the component to one instance of a scene.
  11614. */
  11615. register(): void;
  11616. /**
  11617. * Rebuilds the elements related to this component in case of
  11618. * context lost for instance.
  11619. */
  11620. rebuild(): void;
  11621. /**
  11622. * Disposes the component and the associated ressources.
  11623. */
  11624. dispose(): void;
  11625. }
  11626. /**
  11627. * This represents a SERIALIZABLE scene component.
  11628. *
  11629. * This extends Scene Component to add Serialization methods on top.
  11630. */
  11631. export interface ISceneSerializableComponent extends ISceneComponent {
  11632. /**
  11633. * Adds all the element from the container to the scene
  11634. * @param container the container holding the elements
  11635. */
  11636. addFromContainer(container: AbstractScene): void;
  11637. /**
  11638. * Removes all the elements in the container from the scene
  11639. * @param container contains the elements to remove
  11640. * @param dispose if the removed element should be disposed (default: false)
  11641. */
  11642. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11643. /**
  11644. * Serializes the component data to the specified json object
  11645. * @param serializationObject The object to serialize to
  11646. */
  11647. serialize(serializationObject: any): void;
  11648. }
  11649. /**
  11650. * Strong typing of a Mesh related stage step action
  11651. */
  11652. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11653. /**
  11654. * Strong typing of a Evaluate Sub Mesh related stage step action
  11655. */
  11656. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11657. /**
  11658. * Strong typing of a Active Mesh related stage step action
  11659. */
  11660. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11661. /**
  11662. * Strong typing of a Camera related stage step action
  11663. */
  11664. export type CameraStageAction = (camera: Camera) => void;
  11665. /**
  11666. * Strong typing of a Render Target related stage step action
  11667. */
  11668. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11669. /**
  11670. * Strong typing of a RenderingGroup related stage step action
  11671. */
  11672. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11673. /**
  11674. * Strong typing of a Mesh Render related stage step action
  11675. */
  11676. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11677. /**
  11678. * Strong typing of a simple stage step action
  11679. */
  11680. export type SimpleStageAction = () => void;
  11681. /**
  11682. * Strong typing of a render target action.
  11683. */
  11684. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11685. /**
  11686. * Strong typing of a pointer move action.
  11687. */
  11688. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11689. /**
  11690. * Strong typing of a pointer up/down action.
  11691. */
  11692. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11693. /**
  11694. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11695. * @hidden
  11696. */
  11697. export class Stage<T extends Function> extends Array<{
  11698. index: number;
  11699. component: ISceneComponent;
  11700. action: T;
  11701. }> {
  11702. /**
  11703. * Hide ctor from the rest of the world.
  11704. * @param items The items to add.
  11705. */
  11706. private constructor();
  11707. /**
  11708. * Creates a new Stage.
  11709. * @returns A new instance of a Stage
  11710. */
  11711. static Create<T extends Function>(): Stage<T>;
  11712. /**
  11713. * Registers a step in an ordered way in the targeted stage.
  11714. * @param index Defines the position to register the step in
  11715. * @param component Defines the component attached to the step
  11716. * @param action Defines the action to launch during the step
  11717. */
  11718. registerStep(index: number, component: ISceneComponent, action: T): void;
  11719. /**
  11720. * Clears all the steps from the stage.
  11721. */
  11722. clear(): void;
  11723. }
  11724. }
  11725. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11726. import { Nullable } from "babylonjs/types";
  11727. import { Observable } from "babylonjs/Misc/observable";
  11728. import { Scene } from "babylonjs/scene";
  11729. import { Sprite } from "babylonjs/Sprites/sprite";
  11730. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11731. import { Ray } from "babylonjs/Culling/ray";
  11732. import { Camera } from "babylonjs/Cameras/camera";
  11733. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11734. import { ISceneComponent } from "babylonjs/sceneComponent";
  11735. module "babylonjs/scene" {
  11736. interface Scene {
  11737. /** @hidden */
  11738. _pointerOverSprite: Nullable<Sprite>;
  11739. /** @hidden */
  11740. _pickedDownSprite: Nullable<Sprite>;
  11741. /** @hidden */
  11742. _tempSpritePickingRay: Nullable<Ray>;
  11743. /**
  11744. * All of the sprite managers added to this scene
  11745. * @see http://doc.babylonjs.com/babylon101/sprites
  11746. */
  11747. spriteManagers: Array<ISpriteManager>;
  11748. /**
  11749. * An event triggered when sprites rendering is about to start
  11750. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11751. */
  11752. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11753. /**
  11754. * An event triggered when sprites rendering is done
  11755. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11756. */
  11757. onAfterSpritesRenderingObservable: Observable<Scene>;
  11758. /** @hidden */
  11759. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11760. /** Launch a ray to try to pick a sprite in the scene
  11761. * @param x position on screen
  11762. * @param y position on screen
  11763. * @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
  11764. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11765. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11766. * @returns a PickingInfo
  11767. */
  11768. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11769. /** Use the given ray to pick a sprite in the scene
  11770. * @param ray The ray (in world space) to use to pick meshes
  11771. * @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
  11772. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11773. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11774. * @returns a PickingInfo
  11775. */
  11776. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11777. /**
  11778. * Force the sprite under the pointer
  11779. * @param sprite defines the sprite to use
  11780. */
  11781. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11782. /**
  11783. * Gets the sprite under the pointer
  11784. * @returns a Sprite or null if no sprite is under the pointer
  11785. */
  11786. getPointerOverSprite(): Nullable<Sprite>;
  11787. }
  11788. }
  11789. /**
  11790. * Defines the sprite scene component responsible to manage sprites
  11791. * in a given scene.
  11792. */
  11793. export class SpriteSceneComponent implements ISceneComponent {
  11794. /**
  11795. * The component name helpfull to identify the component in the list of scene components.
  11796. */
  11797. readonly name: string;
  11798. /**
  11799. * The scene the component belongs to.
  11800. */
  11801. scene: Scene;
  11802. /** @hidden */
  11803. private _spritePredicate;
  11804. /**
  11805. * Creates a new instance of the component for the given scene
  11806. * @param scene Defines the scene to register the component in
  11807. */
  11808. constructor(scene: Scene);
  11809. /**
  11810. * Registers the component in a given scene
  11811. */
  11812. register(): void;
  11813. /**
  11814. * Rebuilds the elements related to this component in case of
  11815. * context lost for instance.
  11816. */
  11817. rebuild(): void;
  11818. /**
  11819. * Disposes the component and the associated ressources.
  11820. */
  11821. dispose(): void;
  11822. private _pickSpriteButKeepRay;
  11823. private _pointerMove;
  11824. private _pointerDown;
  11825. private _pointerUp;
  11826. }
  11827. }
  11828. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11829. /** @hidden */
  11830. export var fogFragmentDeclaration: {
  11831. name: string;
  11832. shader: string;
  11833. };
  11834. }
  11835. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11836. /** @hidden */
  11837. export var fogFragment: {
  11838. name: string;
  11839. shader: string;
  11840. };
  11841. }
  11842. declare module "babylonjs/Shaders/sprites.fragment" {
  11843. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11844. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11845. /** @hidden */
  11846. export var spritesPixelShader: {
  11847. name: string;
  11848. shader: string;
  11849. };
  11850. }
  11851. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11852. /** @hidden */
  11853. export var fogVertexDeclaration: {
  11854. name: string;
  11855. shader: string;
  11856. };
  11857. }
  11858. declare module "babylonjs/Shaders/sprites.vertex" {
  11859. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11860. /** @hidden */
  11861. export var spritesVertexShader: {
  11862. name: string;
  11863. shader: string;
  11864. };
  11865. }
  11866. declare module "babylonjs/Sprites/spriteManager" {
  11867. import { IDisposable, Scene } from "babylonjs/scene";
  11868. import { Nullable } from "babylonjs/types";
  11869. import { Observable } from "babylonjs/Misc/observable";
  11870. import { Sprite } from "babylonjs/Sprites/sprite";
  11871. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11872. import { Camera } from "babylonjs/Cameras/camera";
  11873. import { Texture } from "babylonjs/Materials/Textures/texture";
  11874. import "babylonjs/Shaders/sprites.fragment";
  11875. import "babylonjs/Shaders/sprites.vertex";
  11876. import { Ray } from "babylonjs/Culling/ray";
  11877. /**
  11878. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11879. */
  11880. export interface ISpriteManager extends IDisposable {
  11881. /**
  11882. * Restricts the camera to viewing objects with the same layerMask.
  11883. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11884. */
  11885. layerMask: number;
  11886. /**
  11887. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11888. */
  11889. isPickable: boolean;
  11890. /**
  11891. * Specifies the rendering group id for this mesh (0 by default)
  11892. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11893. */
  11894. renderingGroupId: number;
  11895. /**
  11896. * Defines the list of sprites managed by the manager.
  11897. */
  11898. sprites: Array<Sprite>;
  11899. /**
  11900. * Tests the intersection of a sprite with a specific ray.
  11901. * @param ray The ray we are sending to test the collision
  11902. * @param camera The camera space we are sending rays in
  11903. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11904. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11905. * @returns picking info or null.
  11906. */
  11907. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11908. /**
  11909. * Renders the list of sprites on screen.
  11910. */
  11911. render(): void;
  11912. }
  11913. /**
  11914. * Class used to manage multiple sprites on the same spritesheet
  11915. * @see http://doc.babylonjs.com/babylon101/sprites
  11916. */
  11917. export class SpriteManager implements ISpriteManager {
  11918. /** defines the manager's name */
  11919. name: string;
  11920. /** Gets the list of sprites */
  11921. sprites: Sprite[];
  11922. /** Gets or sets the rendering group id (0 by default) */
  11923. renderingGroupId: number;
  11924. /** Gets or sets camera layer mask */
  11925. layerMask: number;
  11926. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11927. fogEnabled: boolean;
  11928. /** Gets or sets a boolean indicating if the sprites are pickable */
  11929. isPickable: boolean;
  11930. /** Defines the default width of a cell in the spritesheet */
  11931. cellWidth: number;
  11932. /** Defines the default height of a cell in the spritesheet */
  11933. cellHeight: number;
  11934. /**
  11935. * An event triggered when the manager is disposed.
  11936. */
  11937. onDisposeObservable: Observable<SpriteManager>;
  11938. private _onDisposeObserver;
  11939. /**
  11940. * Callback called when the manager is disposed
  11941. */
  11942. onDispose: () => void;
  11943. private _capacity;
  11944. private _spriteTexture;
  11945. private _epsilon;
  11946. private _scene;
  11947. private _vertexData;
  11948. private _buffer;
  11949. private _vertexBuffers;
  11950. private _indexBuffer;
  11951. private _effectBase;
  11952. private _effectFog;
  11953. /**
  11954. * Gets or sets the spritesheet texture
  11955. */
  11956. texture: Texture;
  11957. /**
  11958. * Creates a new sprite manager
  11959. * @param name defines the manager's name
  11960. * @param imgUrl defines the sprite sheet url
  11961. * @param capacity defines the maximum allowed number of sprites
  11962. * @param cellSize defines the size of a sprite cell
  11963. * @param scene defines the hosting scene
  11964. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11965. * @param samplingMode defines the smapling mode to use with spritesheet
  11966. */
  11967. constructor(
  11968. /** defines the manager's name */
  11969. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11970. private _appendSpriteVertex;
  11971. /**
  11972. * Intersects the sprites with a ray
  11973. * @param ray defines the ray to intersect with
  11974. * @param camera defines the current active camera
  11975. * @param predicate defines a predicate used to select candidate sprites
  11976. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11977. * @returns null if no hit or a PickingInfo
  11978. */
  11979. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11980. /**
  11981. * Render all child sprites
  11982. */
  11983. render(): void;
  11984. /**
  11985. * Release associated resources
  11986. */
  11987. dispose(): void;
  11988. }
  11989. }
  11990. declare module "babylonjs/Sprites/sprite" {
  11991. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11992. import { Nullable } from "babylonjs/types";
  11993. import { ActionManager } from "babylonjs/Actions/actionManager";
  11994. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11995. /**
  11996. * Class used to represent a sprite
  11997. * @see http://doc.babylonjs.com/babylon101/sprites
  11998. */
  11999. export class Sprite {
  12000. /** defines the name */
  12001. name: string;
  12002. /** Gets or sets the current world position */
  12003. position: Vector3;
  12004. /** Gets or sets the main color */
  12005. color: Color4;
  12006. /** Gets or sets the width */
  12007. width: number;
  12008. /** Gets or sets the height */
  12009. height: number;
  12010. /** Gets or sets rotation angle */
  12011. angle: number;
  12012. /** Gets or sets the cell index in the sprite sheet */
  12013. cellIndex: number;
  12014. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12015. invertU: number;
  12016. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12017. invertV: number;
  12018. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12019. disposeWhenFinishedAnimating: boolean;
  12020. /** Gets the list of attached animations */
  12021. animations: Animation[];
  12022. /** Gets or sets a boolean indicating if the sprite can be picked */
  12023. isPickable: boolean;
  12024. /**
  12025. * Gets or sets the associated action manager
  12026. */
  12027. actionManager: Nullable<ActionManager>;
  12028. private _animationStarted;
  12029. private _loopAnimation;
  12030. private _fromIndex;
  12031. private _toIndex;
  12032. private _delay;
  12033. private _direction;
  12034. private _manager;
  12035. private _time;
  12036. private _onAnimationEnd;
  12037. /**
  12038. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12039. */
  12040. isVisible: boolean;
  12041. /**
  12042. * Gets or sets the sprite size
  12043. */
  12044. size: number;
  12045. /**
  12046. * Creates a new Sprite
  12047. * @param name defines the name
  12048. * @param manager defines the manager
  12049. */
  12050. constructor(
  12051. /** defines the name */
  12052. name: string, manager: ISpriteManager);
  12053. /**
  12054. * Starts an animation
  12055. * @param from defines the initial key
  12056. * @param to defines the end key
  12057. * @param loop defines if the animation must loop
  12058. * @param delay defines the start delay (in ms)
  12059. * @param onAnimationEnd defines a callback to call when animation ends
  12060. */
  12061. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12062. /** Stops current animation (if any) */
  12063. stopAnimation(): void;
  12064. /** @hidden */
  12065. _animate(deltaTime: number): void;
  12066. /** Release associated resources */
  12067. dispose(): void;
  12068. }
  12069. }
  12070. declare module "babylonjs/Collisions/pickingInfo" {
  12071. import { Nullable } from "babylonjs/types";
  12072. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12074. import { Sprite } from "babylonjs/Sprites/sprite";
  12075. import { Ray } from "babylonjs/Culling/ray";
  12076. /**
  12077. * Information about the result of picking within a scene
  12078. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12079. */
  12080. export class PickingInfo {
  12081. /** @hidden */
  12082. _pickingUnavailable: boolean;
  12083. /**
  12084. * If the pick collided with an object
  12085. */
  12086. hit: boolean;
  12087. /**
  12088. * Distance away where the pick collided
  12089. */
  12090. distance: number;
  12091. /**
  12092. * The location of pick collision
  12093. */
  12094. pickedPoint: Nullable<Vector3>;
  12095. /**
  12096. * The mesh corresponding the the pick collision
  12097. */
  12098. pickedMesh: Nullable<AbstractMesh>;
  12099. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12100. bu: number;
  12101. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12102. bv: number;
  12103. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12104. faceId: number;
  12105. /** Id of the the submesh that was picked */
  12106. subMeshId: number;
  12107. /** If a sprite was picked, this will be the sprite the pick collided with */
  12108. pickedSprite: Nullable<Sprite>;
  12109. /**
  12110. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12111. */
  12112. originMesh: Nullable<AbstractMesh>;
  12113. /**
  12114. * The ray that was used to perform the picking.
  12115. */
  12116. ray: Nullable<Ray>;
  12117. /**
  12118. * Gets the normal correspodning to the face the pick collided with
  12119. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12120. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12121. * @returns The normal correspodning to the face the pick collided with
  12122. */
  12123. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12124. /**
  12125. * Gets the texture coordinates of where the pick occured
  12126. * @returns the vector containing the coordnates of the texture
  12127. */
  12128. getTextureCoordinates(): Nullable<Vector2>;
  12129. }
  12130. }
  12131. declare module "babylonjs/Events/pointerEvents" {
  12132. import { Nullable } from "babylonjs/types";
  12133. import { Vector2 } from "babylonjs/Maths/math";
  12134. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12135. import { Ray } from "babylonjs/Culling/ray";
  12136. /**
  12137. * Gather the list of pointer event types as constants.
  12138. */
  12139. export class PointerEventTypes {
  12140. /**
  12141. * 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.
  12142. */
  12143. static readonly POINTERDOWN: number;
  12144. /**
  12145. * The pointerup event is fired when a pointer is no longer active.
  12146. */
  12147. static readonly POINTERUP: number;
  12148. /**
  12149. * The pointermove event is fired when a pointer changes coordinates.
  12150. */
  12151. static readonly POINTERMOVE: number;
  12152. /**
  12153. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12154. */
  12155. static readonly POINTERWHEEL: number;
  12156. /**
  12157. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12158. */
  12159. static readonly POINTERPICK: number;
  12160. /**
  12161. * The pointertap event is fired when a the object has been touched and released without drag.
  12162. */
  12163. static readonly POINTERTAP: number;
  12164. /**
  12165. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12166. */
  12167. static readonly POINTERDOUBLETAP: number;
  12168. }
  12169. /**
  12170. * Base class of pointer info types.
  12171. */
  12172. export class PointerInfoBase {
  12173. /**
  12174. * Defines the type of event (PointerEventTypes)
  12175. */
  12176. type: number;
  12177. /**
  12178. * Defines the related dom event
  12179. */
  12180. event: PointerEvent | MouseWheelEvent;
  12181. /**
  12182. * Instantiates the base class of pointers info.
  12183. * @param type Defines the type of event (PointerEventTypes)
  12184. * @param event Defines the related dom event
  12185. */
  12186. constructor(
  12187. /**
  12188. * Defines the type of event (PointerEventTypes)
  12189. */
  12190. type: number,
  12191. /**
  12192. * Defines the related dom event
  12193. */
  12194. event: PointerEvent | MouseWheelEvent);
  12195. }
  12196. /**
  12197. * This class is used to store pointer related info for the onPrePointerObservable event.
  12198. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12199. */
  12200. export class PointerInfoPre extends PointerInfoBase {
  12201. /**
  12202. * Ray from a pointer if availible (eg. 6dof controller)
  12203. */
  12204. ray: Nullable<Ray>;
  12205. /**
  12206. * Defines the local position of the pointer on the canvas.
  12207. */
  12208. localPosition: Vector2;
  12209. /**
  12210. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12211. */
  12212. skipOnPointerObservable: boolean;
  12213. /**
  12214. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12215. * @param type Defines the type of event (PointerEventTypes)
  12216. * @param event Defines the related dom event
  12217. * @param localX Defines the local x coordinates of the pointer when the event occured
  12218. * @param localY Defines the local y coordinates of the pointer when the event occured
  12219. */
  12220. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12221. }
  12222. /**
  12223. * This type contains all the data related to a pointer event in Babylon.js.
  12224. * 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.
  12225. */
  12226. export class PointerInfo extends PointerInfoBase {
  12227. /**
  12228. * Defines the picking info associated to the info (if any)\
  12229. */
  12230. pickInfo: Nullable<PickingInfo>;
  12231. /**
  12232. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12233. * @param type Defines the type of event (PointerEventTypes)
  12234. * @param event Defines the related dom event
  12235. * @param pickInfo Defines the picking info associated to the info (if any)\
  12236. */
  12237. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12238. /**
  12239. * Defines the picking info associated to the info (if any)\
  12240. */
  12241. pickInfo: Nullable<PickingInfo>);
  12242. }
  12243. /**
  12244. * Data relating to a touch event on the screen.
  12245. */
  12246. export interface PointerTouch {
  12247. /**
  12248. * X coordinate of touch.
  12249. */
  12250. x: number;
  12251. /**
  12252. * Y coordinate of touch.
  12253. */
  12254. y: number;
  12255. /**
  12256. * Id of touch. Unique for each finger.
  12257. */
  12258. pointerId: number;
  12259. /**
  12260. * Event type passed from DOM.
  12261. */
  12262. type: any;
  12263. }
  12264. }
  12265. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12266. import { Observable } from "babylonjs/Misc/observable";
  12267. import { Nullable } from "babylonjs/types";
  12268. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12269. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12270. /**
  12271. * Manage the mouse inputs to control the movement of a free camera.
  12272. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12273. */
  12274. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12275. /**
  12276. * Define if touch is enabled in the mouse input
  12277. */
  12278. touchEnabled: boolean;
  12279. /**
  12280. * Defines the camera the input is attached to.
  12281. */
  12282. camera: FreeCamera;
  12283. /**
  12284. * Defines the buttons associated with the input to handle camera move.
  12285. */
  12286. buttons: number[];
  12287. /**
  12288. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12289. */
  12290. angularSensibility: number;
  12291. private _pointerInput;
  12292. private _onMouseMove;
  12293. private _observer;
  12294. private previousPosition;
  12295. /**
  12296. * Observable for when a pointer move event occurs containing the move offset
  12297. */
  12298. onPointerMovedObservable: Observable<{
  12299. offsetX: number;
  12300. offsetY: number;
  12301. }>;
  12302. /**
  12303. * @hidden
  12304. * If the camera should be rotated automatically based on pointer movement
  12305. */
  12306. _allowCameraRotation: boolean;
  12307. /**
  12308. * Manage the mouse inputs to control the movement of a free camera.
  12309. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12310. * @param touchEnabled Defines if touch is enabled or not
  12311. */
  12312. constructor(
  12313. /**
  12314. * Define if touch is enabled in the mouse input
  12315. */
  12316. touchEnabled?: boolean);
  12317. /**
  12318. * Attach the input controls to a specific dom element to get the input from.
  12319. * @param element Defines the element the controls should be listened from
  12320. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12321. */
  12322. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12323. /**
  12324. * Called on JS contextmenu event.
  12325. * Override this method to provide functionality.
  12326. */
  12327. protected onContextMenu(evt: PointerEvent): void;
  12328. /**
  12329. * Detach the current controls from the specified dom element.
  12330. * @param element Defines the element to stop listening the inputs from
  12331. */
  12332. detachControl(element: Nullable<HTMLElement>): void;
  12333. /**
  12334. * Gets the class name of the current intput.
  12335. * @returns the class name
  12336. */
  12337. getClassName(): string;
  12338. /**
  12339. * Get the friendly name associated with the input class.
  12340. * @returns the input friendly name
  12341. */
  12342. getSimpleName(): string;
  12343. }
  12344. }
  12345. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12346. import { Nullable } from "babylonjs/types";
  12347. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12348. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12349. /**
  12350. * Manage the touch inputs to control the movement of a free camera.
  12351. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12352. */
  12353. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12354. /**
  12355. * Defines the camera the input is attached to.
  12356. */
  12357. camera: FreeCamera;
  12358. /**
  12359. * Defines the touch sensibility for rotation.
  12360. * The higher the faster.
  12361. */
  12362. touchAngularSensibility: number;
  12363. /**
  12364. * Defines the touch sensibility for move.
  12365. * The higher the faster.
  12366. */
  12367. touchMoveSensibility: number;
  12368. private _offsetX;
  12369. private _offsetY;
  12370. private _pointerPressed;
  12371. private _pointerInput;
  12372. private _observer;
  12373. private _onLostFocus;
  12374. /**
  12375. * Attach the input controls to a specific dom element to get the input from.
  12376. * @param element Defines the element the controls should be listened from
  12377. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12378. */
  12379. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12380. /**
  12381. * Detach the current controls from the specified dom element.
  12382. * @param element Defines the element to stop listening the inputs from
  12383. */
  12384. detachControl(element: Nullable<HTMLElement>): void;
  12385. /**
  12386. * Update the current camera state depending on the inputs that have been used this frame.
  12387. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12388. */
  12389. checkInputs(): void;
  12390. /**
  12391. * Gets the class name of the current intput.
  12392. * @returns the class name
  12393. */
  12394. getClassName(): string;
  12395. /**
  12396. * Get the friendly name associated with the input class.
  12397. * @returns the input friendly name
  12398. */
  12399. getSimpleName(): string;
  12400. }
  12401. }
  12402. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12403. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12404. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12405. import { FreeCameraKeyboardMoveInput } from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  12406. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12407. import { Nullable } from "babylonjs/types";
  12408. /**
  12409. * Default Inputs manager for the FreeCamera.
  12410. * It groups all the default supported inputs for ease of use.
  12411. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12412. */
  12413. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12414. /**
  12415. * @hidden
  12416. */
  12417. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12418. /**
  12419. * @hidden
  12420. */
  12421. _mouseInput: Nullable<FreeCameraMouseInput>;
  12422. /**
  12423. * Instantiates a new FreeCameraInputsManager.
  12424. * @param camera Defines the camera the inputs belong to
  12425. */
  12426. constructor(camera: FreeCamera);
  12427. /**
  12428. * Add keyboard input support to the input manager.
  12429. * @returns the current input manager
  12430. */
  12431. addKeyboard(): FreeCameraInputsManager;
  12432. /**
  12433. * Add mouse input support to the input manager.
  12434. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12435. * @returns the current input manager
  12436. */
  12437. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12438. /**
  12439. * Removes the mouse input support from the manager
  12440. * @returns the current input manager
  12441. */
  12442. removeMouse(): FreeCameraInputsManager;
  12443. /**
  12444. * Add touch input support to the input manager.
  12445. * @returns the current input manager
  12446. */
  12447. addTouch(): FreeCameraInputsManager;
  12448. }
  12449. }
  12450. declare module "babylonjs/Cameras/freeCamera" {
  12451. import { Vector3 } from "babylonjs/Maths/math";
  12452. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12453. import { Scene } from "babylonjs/scene";
  12454. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12455. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12456. /**
  12457. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12458. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12459. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12460. */
  12461. export class FreeCamera extends TargetCamera {
  12462. /**
  12463. * Define the collision ellipsoid of the camera.
  12464. * This is helpful to simulate a camera body like the player body around the camera
  12465. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12466. */
  12467. ellipsoid: Vector3;
  12468. /**
  12469. * Define an offset for the position of the ellipsoid around the camera.
  12470. * This can be helpful to determine the center of the body near the gravity center of the body
  12471. * instead of its head.
  12472. */
  12473. ellipsoidOffset: Vector3;
  12474. /**
  12475. * Enable or disable collisions of the camera with the rest of the scene objects.
  12476. */
  12477. checkCollisions: boolean;
  12478. /**
  12479. * Enable or disable gravity on the camera.
  12480. */
  12481. applyGravity: boolean;
  12482. /**
  12483. * Define the input manager associated to the camera.
  12484. */
  12485. inputs: FreeCameraInputsManager;
  12486. /**
  12487. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12488. * Higher values reduce sensitivity.
  12489. */
  12490. /**
  12491. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12492. * Higher values reduce sensitivity.
  12493. */
  12494. angularSensibility: number;
  12495. /**
  12496. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12497. */
  12498. keysUp: number[];
  12499. /**
  12500. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12501. */
  12502. keysDown: number[];
  12503. /**
  12504. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12505. */
  12506. keysLeft: number[];
  12507. /**
  12508. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12509. */
  12510. keysRight: number[];
  12511. /**
  12512. * Event raised when the camera collide with a mesh in the scene.
  12513. */
  12514. onCollide: (collidedMesh: AbstractMesh) => void;
  12515. private _collider;
  12516. private _needMoveForGravity;
  12517. private _oldPosition;
  12518. private _diffPosition;
  12519. private _newPosition;
  12520. /** @hidden */
  12521. _localDirection: Vector3;
  12522. /** @hidden */
  12523. _transformedDirection: Vector3;
  12524. /**
  12525. * Instantiates a Free Camera.
  12526. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12527. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12528. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12529. * @param name Define the name of the camera in the scene
  12530. * @param position Define the start position of the camera in the scene
  12531. * @param scene Define the scene the camera belongs to
  12532. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12533. */
  12534. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12535. /**
  12536. * Attached controls to the current camera.
  12537. * @param element Defines the element the controls should be listened from
  12538. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12539. */
  12540. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12541. /**
  12542. * Detach the current controls from the camera.
  12543. * The camera will stop reacting to inputs.
  12544. * @param element Defines the element to stop listening the inputs from
  12545. */
  12546. detachControl(element: HTMLElement): void;
  12547. private _collisionMask;
  12548. /**
  12549. * Define a collision mask to limit the list of object the camera can collide with
  12550. */
  12551. collisionMask: number;
  12552. /** @hidden */
  12553. _collideWithWorld(displacement: Vector3): void;
  12554. private _onCollisionPositionChange;
  12555. /** @hidden */
  12556. _checkInputs(): void;
  12557. /** @hidden */
  12558. _decideIfNeedsToMove(): boolean;
  12559. /** @hidden */
  12560. _updatePosition(): void;
  12561. /**
  12562. * Destroy the camera and release the current resources hold by it.
  12563. */
  12564. dispose(): void;
  12565. /**
  12566. * Gets the current object class name.
  12567. * @return the class name
  12568. */
  12569. getClassName(): string;
  12570. }
  12571. }
  12572. declare module "babylonjs/Gamepads/gamepad" {
  12573. import { Observable } from "babylonjs/Misc/observable";
  12574. /**
  12575. * Represents a gamepad control stick position
  12576. */
  12577. export class StickValues {
  12578. /**
  12579. * The x component of the control stick
  12580. */
  12581. x: number;
  12582. /**
  12583. * The y component of the control stick
  12584. */
  12585. y: number;
  12586. /**
  12587. * Initializes the gamepad x and y control stick values
  12588. * @param x The x component of the gamepad control stick value
  12589. * @param y The y component of the gamepad control stick value
  12590. */
  12591. constructor(
  12592. /**
  12593. * The x component of the control stick
  12594. */
  12595. x: number,
  12596. /**
  12597. * The y component of the control stick
  12598. */
  12599. y: number);
  12600. }
  12601. /**
  12602. * An interface which manages callbacks for gamepad button changes
  12603. */
  12604. export interface GamepadButtonChanges {
  12605. /**
  12606. * Called when a gamepad has been changed
  12607. */
  12608. changed: boolean;
  12609. /**
  12610. * Called when a gamepad press event has been triggered
  12611. */
  12612. pressChanged: boolean;
  12613. /**
  12614. * Called when a touch event has been triggered
  12615. */
  12616. touchChanged: boolean;
  12617. /**
  12618. * Called when a value has changed
  12619. */
  12620. valueChanged: boolean;
  12621. }
  12622. /**
  12623. * Represents a gamepad
  12624. */
  12625. export class Gamepad {
  12626. /**
  12627. * The id of the gamepad
  12628. */
  12629. id: string;
  12630. /**
  12631. * The index of the gamepad
  12632. */
  12633. index: number;
  12634. /**
  12635. * The browser gamepad
  12636. */
  12637. browserGamepad: any;
  12638. /**
  12639. * Specifies what type of gamepad this represents
  12640. */
  12641. type: number;
  12642. private _leftStick;
  12643. private _rightStick;
  12644. /** @hidden */
  12645. _isConnected: boolean;
  12646. private _leftStickAxisX;
  12647. private _leftStickAxisY;
  12648. private _rightStickAxisX;
  12649. private _rightStickAxisY;
  12650. /**
  12651. * Triggered when the left control stick has been changed
  12652. */
  12653. private _onleftstickchanged;
  12654. /**
  12655. * Triggered when the right control stick has been changed
  12656. */
  12657. private _onrightstickchanged;
  12658. /**
  12659. * Represents a gamepad controller
  12660. */
  12661. static GAMEPAD: number;
  12662. /**
  12663. * Represents a generic controller
  12664. */
  12665. static GENERIC: number;
  12666. /**
  12667. * Represents an XBox controller
  12668. */
  12669. static XBOX: number;
  12670. /**
  12671. * Represents a pose-enabled controller
  12672. */
  12673. static POSE_ENABLED: number;
  12674. /**
  12675. * Specifies whether the left control stick should be Y-inverted
  12676. */
  12677. protected _invertLeftStickY: boolean;
  12678. /**
  12679. * Specifies if the gamepad has been connected
  12680. */
  12681. readonly isConnected: boolean;
  12682. /**
  12683. * Initializes the gamepad
  12684. * @param id The id of the gamepad
  12685. * @param index The index of the gamepad
  12686. * @param browserGamepad The browser gamepad
  12687. * @param leftStickX The x component of the left joystick
  12688. * @param leftStickY The y component of the left joystick
  12689. * @param rightStickX The x component of the right joystick
  12690. * @param rightStickY The y component of the right joystick
  12691. */
  12692. constructor(
  12693. /**
  12694. * The id of the gamepad
  12695. */
  12696. id: string,
  12697. /**
  12698. * The index of the gamepad
  12699. */
  12700. index: number,
  12701. /**
  12702. * The browser gamepad
  12703. */
  12704. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12705. /**
  12706. * Callback triggered when the left joystick has changed
  12707. * @param callback
  12708. */
  12709. onleftstickchanged(callback: (values: StickValues) => void): void;
  12710. /**
  12711. * Callback triggered when the right joystick has changed
  12712. * @param callback
  12713. */
  12714. onrightstickchanged(callback: (values: StickValues) => void): void;
  12715. /**
  12716. * Gets the left joystick
  12717. */
  12718. /**
  12719. * Sets the left joystick values
  12720. */
  12721. leftStick: StickValues;
  12722. /**
  12723. * Gets the right joystick
  12724. */
  12725. /**
  12726. * Sets the right joystick value
  12727. */
  12728. rightStick: StickValues;
  12729. /**
  12730. * Updates the gamepad joystick positions
  12731. */
  12732. update(): void;
  12733. /**
  12734. * Disposes the gamepad
  12735. */
  12736. dispose(): void;
  12737. }
  12738. /**
  12739. * Represents a generic gamepad
  12740. */
  12741. export class GenericPad extends Gamepad {
  12742. private _buttons;
  12743. private _onbuttondown;
  12744. private _onbuttonup;
  12745. /**
  12746. * Observable triggered when a button has been pressed
  12747. */
  12748. onButtonDownObservable: Observable<number>;
  12749. /**
  12750. * Observable triggered when a button has been released
  12751. */
  12752. onButtonUpObservable: Observable<number>;
  12753. /**
  12754. * Callback triggered when a button has been pressed
  12755. * @param callback Called when a button has been pressed
  12756. */
  12757. onbuttondown(callback: (buttonPressed: number) => void): void;
  12758. /**
  12759. * Callback triggered when a button has been released
  12760. * @param callback Called when a button has been released
  12761. */
  12762. onbuttonup(callback: (buttonReleased: number) => void): void;
  12763. /**
  12764. * Initializes the generic gamepad
  12765. * @param id The id of the generic gamepad
  12766. * @param index The index of the generic gamepad
  12767. * @param browserGamepad The browser gamepad
  12768. */
  12769. constructor(id: string, index: number, browserGamepad: any);
  12770. private _setButtonValue;
  12771. /**
  12772. * Updates the generic gamepad
  12773. */
  12774. update(): void;
  12775. /**
  12776. * Disposes the generic gamepad
  12777. */
  12778. dispose(): void;
  12779. }
  12780. }
  12781. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12782. import { Observable } from "babylonjs/Misc/observable";
  12783. import { Nullable } from "babylonjs/types";
  12784. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12785. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12786. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12787. import { Ray } from "babylonjs/Culling/ray";
  12788. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12789. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12790. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12791. /**
  12792. * Defines the types of pose enabled controllers that are supported
  12793. */
  12794. export enum PoseEnabledControllerType {
  12795. /**
  12796. * HTC Vive
  12797. */
  12798. VIVE = 0,
  12799. /**
  12800. * Oculus Rift
  12801. */
  12802. OCULUS = 1,
  12803. /**
  12804. * Windows mixed reality
  12805. */
  12806. WINDOWS = 2,
  12807. /**
  12808. * Samsung gear VR
  12809. */
  12810. GEAR_VR = 3,
  12811. /**
  12812. * Google Daydream
  12813. */
  12814. DAYDREAM = 4,
  12815. /**
  12816. * Generic
  12817. */
  12818. GENERIC = 5
  12819. }
  12820. /**
  12821. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12822. */
  12823. export interface MutableGamepadButton {
  12824. /**
  12825. * Value of the button/trigger
  12826. */
  12827. value: number;
  12828. /**
  12829. * If the button/trigger is currently touched
  12830. */
  12831. touched: boolean;
  12832. /**
  12833. * If the button/trigger is currently pressed
  12834. */
  12835. pressed: boolean;
  12836. }
  12837. /**
  12838. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12839. * @hidden
  12840. */
  12841. export interface ExtendedGamepadButton extends GamepadButton {
  12842. /**
  12843. * If the button/trigger is currently pressed
  12844. */
  12845. readonly pressed: boolean;
  12846. /**
  12847. * If the button/trigger is currently touched
  12848. */
  12849. readonly touched: boolean;
  12850. /**
  12851. * Value of the button/trigger
  12852. */
  12853. readonly value: number;
  12854. }
  12855. /** @hidden */
  12856. export interface _GamePadFactory {
  12857. /**
  12858. * Returns wether or not the current gamepad can be created for this type of controller.
  12859. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12860. * @returns true if it can be created, otherwise false
  12861. */
  12862. canCreate(gamepadInfo: any): boolean;
  12863. /**
  12864. * Creates a new instance of the Gamepad.
  12865. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12866. * @returns the new gamepad instance
  12867. */
  12868. create(gamepadInfo: any): Gamepad;
  12869. }
  12870. /**
  12871. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12872. */
  12873. export class PoseEnabledControllerHelper {
  12874. /** @hidden */
  12875. static _ControllerFactories: _GamePadFactory[];
  12876. /** @hidden */
  12877. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12878. /**
  12879. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12880. * @param vrGamepad the gamepad to initialized
  12881. * @returns a vr controller of the type the gamepad identified as
  12882. */
  12883. static InitiateController(vrGamepad: any): Gamepad;
  12884. }
  12885. /**
  12886. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12887. */
  12888. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12889. private _deviceRoomPosition;
  12890. private _deviceRoomRotationQuaternion;
  12891. /**
  12892. * The device position in babylon space
  12893. */
  12894. devicePosition: Vector3;
  12895. /**
  12896. * The device rotation in babylon space
  12897. */
  12898. deviceRotationQuaternion: Quaternion;
  12899. /**
  12900. * The scale factor of the device in babylon space
  12901. */
  12902. deviceScaleFactor: number;
  12903. /**
  12904. * (Likely devicePosition should be used instead) The device position in its room space
  12905. */
  12906. position: Vector3;
  12907. /**
  12908. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12909. */
  12910. rotationQuaternion: Quaternion;
  12911. /**
  12912. * The type of controller (Eg. Windows mixed reality)
  12913. */
  12914. controllerType: PoseEnabledControllerType;
  12915. protected _calculatedPosition: Vector3;
  12916. private _calculatedRotation;
  12917. /**
  12918. * The raw pose from the device
  12919. */
  12920. rawPose: DevicePose;
  12921. private _trackPosition;
  12922. private _maxRotationDistFromHeadset;
  12923. private _draggedRoomRotation;
  12924. /**
  12925. * @hidden
  12926. */
  12927. _disableTrackPosition(fixedPosition: Vector3): void;
  12928. /**
  12929. * Internal, the mesh attached to the controller
  12930. * @hidden
  12931. */
  12932. _mesh: Nullable<AbstractMesh>;
  12933. private _poseControlledCamera;
  12934. private _leftHandSystemQuaternion;
  12935. /**
  12936. * Internal, matrix used to convert room space to babylon space
  12937. * @hidden
  12938. */
  12939. _deviceToWorld: Matrix;
  12940. /**
  12941. * Node to be used when casting a ray from the controller
  12942. * @hidden
  12943. */
  12944. _pointingPoseNode: Nullable<TransformNode>;
  12945. /**
  12946. * Name of the child mesh that can be used to cast a ray from the controller
  12947. */
  12948. static readonly POINTING_POSE: string;
  12949. /**
  12950. * Creates a new PoseEnabledController from a gamepad
  12951. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12952. */
  12953. constructor(browserGamepad: any);
  12954. private _workingMatrix;
  12955. /**
  12956. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12957. */
  12958. update(): void;
  12959. /**
  12960. * Updates only the pose device and mesh without doing any button event checking
  12961. */
  12962. protected _updatePoseAndMesh(): void;
  12963. /**
  12964. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12965. * @param poseData raw pose fromthe device
  12966. */
  12967. updateFromDevice(poseData: DevicePose): void;
  12968. /**
  12969. * @hidden
  12970. */
  12971. _meshAttachedObservable: Observable<AbstractMesh>;
  12972. /**
  12973. * Attaches a mesh to the controller
  12974. * @param mesh the mesh to be attached
  12975. */
  12976. attachToMesh(mesh: AbstractMesh): void;
  12977. /**
  12978. * Attaches the controllers mesh to a camera
  12979. * @param camera the camera the mesh should be attached to
  12980. */
  12981. attachToPoseControlledCamera(camera: TargetCamera): void;
  12982. /**
  12983. * Disposes of the controller
  12984. */
  12985. dispose(): void;
  12986. /**
  12987. * The mesh that is attached to the controller
  12988. */
  12989. readonly mesh: Nullable<AbstractMesh>;
  12990. /**
  12991. * Gets the ray of the controller in the direction the controller is pointing
  12992. * @param length the length the resulting ray should be
  12993. * @returns a ray in the direction the controller is pointing
  12994. */
  12995. getForwardRay(length?: number): Ray;
  12996. }
  12997. }
  12998. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12999. import { Observable } from "babylonjs/Misc/observable";
  13000. import { Scene } from "babylonjs/scene";
  13001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13002. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13003. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13004. /**
  13005. * Defines the WebVRController object that represents controllers tracked in 3D space
  13006. */
  13007. export abstract class WebVRController extends PoseEnabledController {
  13008. /**
  13009. * Internal, the default controller model for the controller
  13010. */
  13011. protected _defaultModel: AbstractMesh;
  13012. /**
  13013. * Fired when the trigger state has changed
  13014. */
  13015. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13016. /**
  13017. * Fired when the main button state has changed
  13018. */
  13019. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13020. /**
  13021. * Fired when the secondary button state has changed
  13022. */
  13023. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13024. /**
  13025. * Fired when the pad state has changed
  13026. */
  13027. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13028. /**
  13029. * Fired when controllers stick values have changed
  13030. */
  13031. onPadValuesChangedObservable: Observable<StickValues>;
  13032. /**
  13033. * Array of button availible on the controller
  13034. */
  13035. protected _buttons: Array<MutableGamepadButton>;
  13036. private _onButtonStateChange;
  13037. /**
  13038. * Fired when a controller button's state has changed
  13039. * @param callback the callback containing the button that was modified
  13040. */
  13041. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13042. /**
  13043. * X and Y axis corrisponding to the controllers joystick
  13044. */
  13045. pad: StickValues;
  13046. /**
  13047. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13048. */
  13049. hand: string;
  13050. /**
  13051. * The default controller model for the controller
  13052. */
  13053. readonly defaultModel: AbstractMesh;
  13054. /**
  13055. * Creates a new WebVRController from a gamepad
  13056. * @param vrGamepad the gamepad that the WebVRController should be created from
  13057. */
  13058. constructor(vrGamepad: any);
  13059. /**
  13060. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13061. */
  13062. update(): void;
  13063. /**
  13064. * Function to be called when a button is modified
  13065. */
  13066. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13067. /**
  13068. * Loads a mesh and attaches it to the controller
  13069. * @param scene the scene the mesh should be added to
  13070. * @param meshLoaded callback for when the mesh has been loaded
  13071. */
  13072. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13073. private _setButtonValue;
  13074. private _changes;
  13075. private _checkChanges;
  13076. /**
  13077. * Disposes of th webVRCOntroller
  13078. */
  13079. dispose(): void;
  13080. }
  13081. }
  13082. declare module "babylonjs/Lights/hemisphericLight" {
  13083. import { Nullable } from "babylonjs/types";
  13084. import { Scene } from "babylonjs/scene";
  13085. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13086. import { Effect } from "babylonjs/Materials/effect";
  13087. import { Light } from "babylonjs/Lights/light";
  13088. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13089. /**
  13090. * The HemisphericLight simulates the ambient environment light,
  13091. * so the passed direction is the light reflection direction, not the incoming direction.
  13092. */
  13093. export class HemisphericLight extends Light {
  13094. /**
  13095. * The groundColor is the light in the opposite direction to the one specified during creation.
  13096. * 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.
  13097. */
  13098. groundColor: Color3;
  13099. /**
  13100. * The light reflection direction, not the incoming direction.
  13101. */
  13102. direction: Vector3;
  13103. /**
  13104. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13105. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13106. * The HemisphericLight can't cast shadows.
  13107. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13108. * @param name The friendly name of the light
  13109. * @param direction The direction of the light reflection
  13110. * @param scene The scene the light belongs to
  13111. */
  13112. constructor(name: string, direction: Vector3, scene: Scene);
  13113. protected _buildUniformLayout(): void;
  13114. /**
  13115. * Returns the string "HemisphericLight".
  13116. * @return The class name
  13117. */
  13118. getClassName(): string;
  13119. /**
  13120. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13121. * Returns the updated direction.
  13122. * @param target The target the direction should point to
  13123. * @return The computed direction
  13124. */
  13125. setDirectionToTarget(target: Vector3): Vector3;
  13126. /**
  13127. * Returns the shadow generator associated to the light.
  13128. * @returns Always null for hemispheric lights because it does not support shadows.
  13129. */
  13130. getShadowGenerator(): Nullable<IShadowGenerator>;
  13131. /**
  13132. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13133. * @param effect The effect to update
  13134. * @param lightIndex The index of the light in the effect to update
  13135. * @returns The hemispheric light
  13136. */
  13137. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13138. /**
  13139. * Computes the world matrix of the node
  13140. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13141. * @param useWasUpdatedFlag defines a reserved property
  13142. * @returns the world matrix
  13143. */
  13144. computeWorldMatrix(): Matrix;
  13145. /**
  13146. * Returns the integer 3.
  13147. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13148. */
  13149. getTypeID(): number;
  13150. /**
  13151. * Prepares the list of defines specific to the light type.
  13152. * @param defines the list of defines
  13153. * @param lightIndex defines the index of the light for the effect
  13154. */
  13155. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13156. }
  13157. }
  13158. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13159. /** @hidden */
  13160. export var vrMultiviewToSingleviewPixelShader: {
  13161. name: string;
  13162. shader: string;
  13163. };
  13164. }
  13165. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13166. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13167. import { Scene } from "babylonjs/scene";
  13168. /**
  13169. * Renders to multiple views with a single draw call
  13170. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13171. */
  13172. export class MultiviewRenderTarget extends RenderTargetTexture {
  13173. /**
  13174. * Creates a multiview render target
  13175. * @param scene scene used with the render target
  13176. * @param size the size of the render target (used for each view)
  13177. */
  13178. constructor(scene: Scene, size?: number | {
  13179. width: number;
  13180. height: number;
  13181. } | {
  13182. ratio: number;
  13183. });
  13184. /**
  13185. * @hidden
  13186. * @param faceIndex the face index, if its a cube texture
  13187. */
  13188. _bindFrameBuffer(faceIndex?: number): void;
  13189. /**
  13190. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13191. * @returns the view count
  13192. */
  13193. getViewCount(): number;
  13194. }
  13195. }
  13196. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13197. import { Camera } from "babylonjs/Cameras/camera";
  13198. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13199. import { Nullable } from "babylonjs/types";
  13200. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13201. import { Matrix } from "babylonjs/Maths/math";
  13202. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13203. module "babylonjs/Engines/engine" {
  13204. interface Engine {
  13205. /**
  13206. * Creates a new multiview render target
  13207. * @param width defines the width of the texture
  13208. * @param height defines the height of the texture
  13209. * @returns the created multiview texture
  13210. */
  13211. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13212. /**
  13213. * Binds a multiview framebuffer to be drawn to
  13214. * @param multiviewTexture texture to bind
  13215. */
  13216. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13217. }
  13218. }
  13219. module "babylonjs/Cameras/camera" {
  13220. interface Camera {
  13221. /**
  13222. * @hidden
  13223. * 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)
  13224. */
  13225. _useMultiviewToSingleView: boolean;
  13226. /**
  13227. * @hidden
  13228. * 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)
  13229. */
  13230. _multiviewTexture: Nullable<RenderTargetTexture>;
  13231. /**
  13232. * @hidden
  13233. * ensures the multiview texture of the camera exists and has the specified width/height
  13234. * @param width height to set on the multiview texture
  13235. * @param height width to set on the multiview texture
  13236. */
  13237. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13238. }
  13239. }
  13240. module "babylonjs/scene" {
  13241. interface Scene {
  13242. /** @hidden */
  13243. _transformMatrixR: Matrix;
  13244. /** @hidden */
  13245. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13246. /** @hidden */
  13247. _createMultiviewUbo(): void;
  13248. /** @hidden */
  13249. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13250. /** @hidden */
  13251. _renderMultiviewToSingleView(camera: Camera): void;
  13252. }
  13253. }
  13254. }
  13255. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13256. import { Camera } from "babylonjs/Cameras/camera";
  13257. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13258. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13259. import "babylonjs/Engines/Extensions/engine.multiview";
  13260. /**
  13261. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13262. * This will not be used for webXR as it supports displaying texture arrays directly
  13263. */
  13264. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13265. /**
  13266. * Initializes a VRMultiviewToSingleview
  13267. * @param name name of the post process
  13268. * @param camera camera to be applied to
  13269. * @param scaleFactor scaling factor to the size of the output texture
  13270. */
  13271. constructor(name: string, camera: Camera, scaleFactor: number);
  13272. }
  13273. }
  13274. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13275. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13276. import { Nullable } from "babylonjs/types";
  13277. import { Observable } from "babylonjs/Misc/observable";
  13278. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13279. import { Scene } from "babylonjs/scene";
  13280. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13281. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13282. import { Node } from "babylonjs/node";
  13283. import { Ray } from "babylonjs/Culling/ray";
  13284. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13285. /**
  13286. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13287. * IMPORTANT!! The data is right-hand data.
  13288. * @export
  13289. * @interface DevicePose
  13290. */
  13291. export interface DevicePose {
  13292. /**
  13293. * The position of the device, values in array are [x,y,z].
  13294. */
  13295. readonly position: Nullable<Float32Array>;
  13296. /**
  13297. * The linearVelocity of the device, values in array are [x,y,z].
  13298. */
  13299. readonly linearVelocity: Nullable<Float32Array>;
  13300. /**
  13301. * The linearAcceleration of the device, values in array are [x,y,z].
  13302. */
  13303. readonly linearAcceleration: Nullable<Float32Array>;
  13304. /**
  13305. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13306. */
  13307. readonly orientation: Nullable<Float32Array>;
  13308. /**
  13309. * The angularVelocity of the device, values in array are [x,y,z].
  13310. */
  13311. readonly angularVelocity: Nullable<Float32Array>;
  13312. /**
  13313. * The angularAcceleration of the device, values in array are [x,y,z].
  13314. */
  13315. readonly angularAcceleration: Nullable<Float32Array>;
  13316. }
  13317. /**
  13318. * Interface representing a pose controlled object in Babylon.
  13319. * A pose controlled object has both regular pose values as well as pose values
  13320. * from an external device such as a VR head mounted display
  13321. */
  13322. export interface PoseControlled {
  13323. /**
  13324. * The position of the object in babylon space.
  13325. */
  13326. position: Vector3;
  13327. /**
  13328. * The rotation quaternion of the object in babylon space.
  13329. */
  13330. rotationQuaternion: Quaternion;
  13331. /**
  13332. * The position of the device in babylon space.
  13333. */
  13334. devicePosition?: Vector3;
  13335. /**
  13336. * The rotation quaternion of the device in babylon space.
  13337. */
  13338. deviceRotationQuaternion: Quaternion;
  13339. /**
  13340. * The raw pose coming from the device.
  13341. */
  13342. rawPose: Nullable<DevicePose>;
  13343. /**
  13344. * The scale of the device to be used when translating from device space to babylon space.
  13345. */
  13346. deviceScaleFactor: number;
  13347. /**
  13348. * Updates the poseControlled values based on the input device pose.
  13349. * @param poseData the pose data to update the object with
  13350. */
  13351. updateFromDevice(poseData: DevicePose): void;
  13352. }
  13353. /**
  13354. * Set of options to customize the webVRCamera
  13355. */
  13356. export interface WebVROptions {
  13357. /**
  13358. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13359. */
  13360. trackPosition?: boolean;
  13361. /**
  13362. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13363. */
  13364. positionScale?: number;
  13365. /**
  13366. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13367. */
  13368. displayName?: string;
  13369. /**
  13370. * Should the native controller meshes be initialized. (default: true)
  13371. */
  13372. controllerMeshes?: boolean;
  13373. /**
  13374. * Creating a default HemiLight only on controllers. (default: true)
  13375. */
  13376. defaultLightingOnControllers?: boolean;
  13377. /**
  13378. * If you don't want to use the default VR button of the helper. (default: false)
  13379. */
  13380. useCustomVRButton?: boolean;
  13381. /**
  13382. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13383. */
  13384. customVRButton?: HTMLButtonElement;
  13385. /**
  13386. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13387. */
  13388. rayLength?: number;
  13389. /**
  13390. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13391. */
  13392. defaultHeight?: number;
  13393. /**
  13394. * If multiview should be used if availible (default: false)
  13395. */
  13396. useMultiview?: boolean;
  13397. }
  13398. /**
  13399. * This represents a WebVR camera.
  13400. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13401. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13402. */
  13403. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13404. private webVROptions;
  13405. /**
  13406. * @hidden
  13407. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13408. */
  13409. _vrDevice: any;
  13410. /**
  13411. * The rawPose of the vrDevice.
  13412. */
  13413. rawPose: Nullable<DevicePose>;
  13414. private _onVREnabled;
  13415. private _specsVersion;
  13416. private _attached;
  13417. private _frameData;
  13418. protected _descendants: Array<Node>;
  13419. private _deviceRoomPosition;
  13420. /** @hidden */
  13421. _deviceRoomRotationQuaternion: Quaternion;
  13422. private _standingMatrix;
  13423. /**
  13424. * Represents device position in babylon space.
  13425. */
  13426. devicePosition: Vector3;
  13427. /**
  13428. * Represents device rotation in babylon space.
  13429. */
  13430. deviceRotationQuaternion: Quaternion;
  13431. /**
  13432. * The scale of the device to be used when translating from device space to babylon space.
  13433. */
  13434. deviceScaleFactor: number;
  13435. private _deviceToWorld;
  13436. private _worldToDevice;
  13437. /**
  13438. * References to the webVR controllers for the vrDevice.
  13439. */
  13440. controllers: Array<WebVRController>;
  13441. /**
  13442. * Emits an event when a controller is attached.
  13443. */
  13444. onControllersAttachedObservable: Observable<WebVRController[]>;
  13445. /**
  13446. * Emits an event when a controller's mesh has been loaded;
  13447. */
  13448. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13449. /**
  13450. * Emits an event when the HMD's pose has been updated.
  13451. */
  13452. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13453. private _poseSet;
  13454. /**
  13455. * If the rig cameras be used as parent instead of this camera.
  13456. */
  13457. rigParenting: boolean;
  13458. private _lightOnControllers;
  13459. private _defaultHeight?;
  13460. /**
  13461. * Instantiates a WebVRFreeCamera.
  13462. * @param name The name of the WebVRFreeCamera
  13463. * @param position The starting anchor position for the camera
  13464. * @param scene The scene the camera belongs to
  13465. * @param webVROptions a set of customizable options for the webVRCamera
  13466. */
  13467. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13468. /**
  13469. * Gets the device distance from the ground in meters.
  13470. * @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.
  13471. */
  13472. deviceDistanceToRoomGround(): number;
  13473. /**
  13474. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13475. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13476. */
  13477. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13478. /**
  13479. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13480. * @returns A promise with a boolean set to if the standing matrix is supported.
  13481. */
  13482. useStandingMatrixAsync(): Promise<boolean>;
  13483. /**
  13484. * Disposes the camera
  13485. */
  13486. dispose(): void;
  13487. /**
  13488. * Gets a vrController by name.
  13489. * @param name The name of the controller to retreive
  13490. * @returns the controller matching the name specified or null if not found
  13491. */
  13492. getControllerByName(name: string): Nullable<WebVRController>;
  13493. private _leftController;
  13494. /**
  13495. * The controller corrisponding to the users left hand.
  13496. */
  13497. readonly leftController: Nullable<WebVRController>;
  13498. private _rightController;
  13499. /**
  13500. * The controller corrisponding to the users right hand.
  13501. */
  13502. readonly rightController: Nullable<WebVRController>;
  13503. /**
  13504. * Casts a ray forward from the vrCamera's gaze.
  13505. * @param length Length of the ray (default: 100)
  13506. * @returns the ray corrisponding to the gaze
  13507. */
  13508. getForwardRay(length?: number): Ray;
  13509. /**
  13510. * @hidden
  13511. * Updates the camera based on device's frame data
  13512. */
  13513. _checkInputs(): void;
  13514. /**
  13515. * Updates the poseControlled values based on the input device pose.
  13516. * @param poseData Pose coming from the device
  13517. */
  13518. updateFromDevice(poseData: DevicePose): void;
  13519. private _htmlElementAttached;
  13520. private _detachIfAttached;
  13521. /**
  13522. * WebVR's attach control will start broadcasting frames to the device.
  13523. * Note that in certain browsers (chrome for example) this function must be called
  13524. * within a user-interaction callback. Example:
  13525. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13526. *
  13527. * @param element html element to attach the vrDevice to
  13528. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13529. */
  13530. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13531. /**
  13532. * Detaches the camera from the html element and disables VR
  13533. *
  13534. * @param element html element to detach from
  13535. */
  13536. detachControl(element: HTMLElement): void;
  13537. /**
  13538. * @returns the name of this class
  13539. */
  13540. getClassName(): string;
  13541. /**
  13542. * Calls resetPose on the vrDisplay
  13543. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13544. */
  13545. resetToCurrentRotation(): void;
  13546. /**
  13547. * @hidden
  13548. * Updates the rig cameras (left and right eye)
  13549. */
  13550. _updateRigCameras(): void;
  13551. private _workingVector;
  13552. private _oneVector;
  13553. private _workingMatrix;
  13554. private updateCacheCalled;
  13555. private _correctPositionIfNotTrackPosition;
  13556. /**
  13557. * @hidden
  13558. * Updates the cached values of the camera
  13559. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13560. */
  13561. _updateCache(ignoreParentClass?: boolean): void;
  13562. /**
  13563. * @hidden
  13564. * Get current device position in babylon world
  13565. */
  13566. _computeDevicePosition(): void;
  13567. /**
  13568. * Updates the current device position and rotation in the babylon world
  13569. */
  13570. update(): void;
  13571. /**
  13572. * @hidden
  13573. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13574. * @returns an identity matrix
  13575. */
  13576. _getViewMatrix(): Matrix;
  13577. private _tmpMatrix;
  13578. /**
  13579. * This function is called by the two RIG cameras.
  13580. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13581. * @hidden
  13582. */
  13583. _getWebVRViewMatrix(): Matrix;
  13584. /** @hidden */
  13585. _getWebVRProjectionMatrix(): Matrix;
  13586. private _onGamepadConnectedObserver;
  13587. private _onGamepadDisconnectedObserver;
  13588. private _updateCacheWhenTrackingDisabledObserver;
  13589. /**
  13590. * Initializes the controllers and their meshes
  13591. */
  13592. initControllers(): void;
  13593. }
  13594. }
  13595. declare module "babylonjs/PostProcesses/postProcess" {
  13596. import { Nullable } from "babylonjs/types";
  13597. import { SmartArray } from "babylonjs/Misc/smartArray";
  13598. import { Observable } from "babylonjs/Misc/observable";
  13599. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13600. import { Camera } from "babylonjs/Cameras/camera";
  13601. import { Effect } from "babylonjs/Materials/effect";
  13602. import "babylonjs/Shaders/postprocess.vertex";
  13603. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13604. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13605. import { Engine } from "babylonjs/Engines/engine";
  13606. /**
  13607. * Size options for a post process
  13608. */
  13609. export type PostProcessOptions = {
  13610. width: number;
  13611. height: number;
  13612. };
  13613. /**
  13614. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13615. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13616. */
  13617. export class PostProcess {
  13618. /** Name of the PostProcess. */
  13619. name: string;
  13620. /**
  13621. * Gets or sets the unique id of the post process
  13622. */
  13623. uniqueId: number;
  13624. /**
  13625. * Width of the texture to apply the post process on
  13626. */
  13627. width: number;
  13628. /**
  13629. * Height of the texture to apply the post process on
  13630. */
  13631. height: number;
  13632. /**
  13633. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13634. * @hidden
  13635. */
  13636. _outputTexture: Nullable<InternalTexture>;
  13637. /**
  13638. * Sampling mode used by the shader
  13639. * See https://doc.babylonjs.com/classes/3.1/texture
  13640. */
  13641. renderTargetSamplingMode: number;
  13642. /**
  13643. * Clear color to use when screen clearing
  13644. */
  13645. clearColor: Color4;
  13646. /**
  13647. * If the buffer needs to be cleared before applying the post process. (default: true)
  13648. * Should be set to false if shader will overwrite all previous pixels.
  13649. */
  13650. autoClear: boolean;
  13651. /**
  13652. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13653. */
  13654. alphaMode: number;
  13655. /**
  13656. * Sets the setAlphaBlendConstants of the babylon engine
  13657. */
  13658. alphaConstants: Color4;
  13659. /**
  13660. * Animations to be used for the post processing
  13661. */
  13662. animations: import("babylonjs/Animations/animation").Animation[];
  13663. /**
  13664. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13665. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13666. */
  13667. enablePixelPerfectMode: boolean;
  13668. /**
  13669. * Force the postprocess to be applied without taking in account viewport
  13670. */
  13671. forceFullscreenViewport: boolean;
  13672. /**
  13673. * List of inspectable custom properties (used by the Inspector)
  13674. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13675. */
  13676. inspectableCustomProperties: IInspectable[];
  13677. /**
  13678. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13679. *
  13680. * | Value | Type | Description |
  13681. * | ----- | ----------------------------------- | ----------- |
  13682. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13683. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13684. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13685. *
  13686. */
  13687. scaleMode: number;
  13688. /**
  13689. * Force textures to be a power of two (default: false)
  13690. */
  13691. alwaysForcePOT: boolean;
  13692. private _samples;
  13693. /**
  13694. * Number of sample textures (default: 1)
  13695. */
  13696. samples: number;
  13697. /**
  13698. * Modify the scale of the post process to be the same as the viewport (default: false)
  13699. */
  13700. adaptScaleToCurrentViewport: boolean;
  13701. private _camera;
  13702. private _scene;
  13703. private _engine;
  13704. private _options;
  13705. private _reusable;
  13706. private _textureType;
  13707. /**
  13708. * Smart array of input and output textures for the post process.
  13709. * @hidden
  13710. */
  13711. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13712. /**
  13713. * The index in _textures that corresponds to the output texture.
  13714. * @hidden
  13715. */
  13716. _currentRenderTextureInd: number;
  13717. private _effect;
  13718. private _samplers;
  13719. private _fragmentUrl;
  13720. private _vertexUrl;
  13721. private _parameters;
  13722. private _scaleRatio;
  13723. protected _indexParameters: any;
  13724. private _shareOutputWithPostProcess;
  13725. private _texelSize;
  13726. private _forcedOutputTexture;
  13727. /**
  13728. * Returns the fragment url or shader name used in the post process.
  13729. * @returns the fragment url or name in the shader store.
  13730. */
  13731. getEffectName(): string;
  13732. /**
  13733. * An event triggered when the postprocess is activated.
  13734. */
  13735. onActivateObservable: Observable<Camera>;
  13736. private _onActivateObserver;
  13737. /**
  13738. * A function that is added to the onActivateObservable
  13739. */
  13740. onActivate: Nullable<(camera: Camera) => void>;
  13741. /**
  13742. * An event triggered when the postprocess changes its size.
  13743. */
  13744. onSizeChangedObservable: Observable<PostProcess>;
  13745. private _onSizeChangedObserver;
  13746. /**
  13747. * A function that is added to the onSizeChangedObservable
  13748. */
  13749. onSizeChanged: (postProcess: PostProcess) => void;
  13750. /**
  13751. * An event triggered when the postprocess applies its effect.
  13752. */
  13753. onApplyObservable: Observable<Effect>;
  13754. private _onApplyObserver;
  13755. /**
  13756. * A function that is added to the onApplyObservable
  13757. */
  13758. onApply: (effect: Effect) => void;
  13759. /**
  13760. * An event triggered before rendering the postprocess
  13761. */
  13762. onBeforeRenderObservable: Observable<Effect>;
  13763. private _onBeforeRenderObserver;
  13764. /**
  13765. * A function that is added to the onBeforeRenderObservable
  13766. */
  13767. onBeforeRender: (effect: Effect) => void;
  13768. /**
  13769. * An event triggered after rendering the postprocess
  13770. */
  13771. onAfterRenderObservable: Observable<Effect>;
  13772. private _onAfterRenderObserver;
  13773. /**
  13774. * A function that is added to the onAfterRenderObservable
  13775. */
  13776. onAfterRender: (efect: Effect) => void;
  13777. /**
  13778. * 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
  13779. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13780. */
  13781. inputTexture: InternalTexture;
  13782. /**
  13783. * Gets the camera which post process is applied to.
  13784. * @returns The camera the post process is applied to.
  13785. */
  13786. getCamera(): Camera;
  13787. /**
  13788. * Gets the texel size of the postprocess.
  13789. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13790. */
  13791. readonly texelSize: Vector2;
  13792. /**
  13793. * Creates a new instance PostProcess
  13794. * @param name The name of the PostProcess.
  13795. * @param fragmentUrl The url of the fragment shader to be used.
  13796. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13797. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13798. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13799. * @param camera The camera to apply the render pass to.
  13800. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13801. * @param engine The engine which the post process will be applied. (default: current engine)
  13802. * @param reusable If the post process can be reused on the same frame. (default: false)
  13803. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13804. * @param textureType Type of textures used when performing the post process. (default: 0)
  13805. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13806. * @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
  13807. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13808. */
  13809. constructor(
  13810. /** Name of the PostProcess. */
  13811. 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);
  13812. /**
  13813. * Gets a string idenfifying the name of the class
  13814. * @returns "PostProcess" string
  13815. */
  13816. getClassName(): string;
  13817. /**
  13818. * Gets the engine which this post process belongs to.
  13819. * @returns The engine the post process was enabled with.
  13820. */
  13821. getEngine(): Engine;
  13822. /**
  13823. * The effect that is created when initializing the post process.
  13824. * @returns The created effect corrisponding the the postprocess.
  13825. */
  13826. getEffect(): Effect;
  13827. /**
  13828. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13829. * @param postProcess The post process to share the output with.
  13830. * @returns This post process.
  13831. */
  13832. shareOutputWith(postProcess: PostProcess): PostProcess;
  13833. /**
  13834. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13835. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13836. */
  13837. useOwnOutput(): void;
  13838. /**
  13839. * Updates the effect with the current post process compile time values and recompiles the shader.
  13840. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13841. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13842. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13843. * @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
  13844. * @param onCompiled Called when the shader has been compiled.
  13845. * @param onError Called if there is an error when compiling a shader.
  13846. */
  13847. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13848. /**
  13849. * The post process is reusable if it can be used multiple times within one frame.
  13850. * @returns If the post process is reusable
  13851. */
  13852. isReusable(): boolean;
  13853. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13854. markTextureDirty(): void;
  13855. /**
  13856. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13857. * 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.
  13858. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13859. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13860. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13861. * @returns The target texture that was bound to be written to.
  13862. */
  13863. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13864. /**
  13865. * If the post process is supported.
  13866. */
  13867. readonly isSupported: boolean;
  13868. /**
  13869. * The aspect ratio of the output texture.
  13870. */
  13871. readonly aspectRatio: number;
  13872. /**
  13873. * Get a value indicating if the post-process is ready to be used
  13874. * @returns true if the post-process is ready (shader is compiled)
  13875. */
  13876. isReady(): boolean;
  13877. /**
  13878. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13879. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13880. */
  13881. apply(): Nullable<Effect>;
  13882. private _disposeTextures;
  13883. /**
  13884. * Disposes the post process.
  13885. * @param camera The camera to dispose the post process on.
  13886. */
  13887. dispose(camera?: Camera): void;
  13888. }
  13889. }
  13890. declare module "babylonjs/PostProcesses/postProcessManager" {
  13891. import { Nullable } from "babylonjs/types";
  13892. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13893. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13894. import { Scene } from "babylonjs/scene";
  13895. /**
  13896. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13897. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13898. */
  13899. export class PostProcessManager {
  13900. private _scene;
  13901. private _indexBuffer;
  13902. private _vertexBuffers;
  13903. /**
  13904. * Creates a new instance PostProcess
  13905. * @param scene The scene that the post process is associated with.
  13906. */
  13907. constructor(scene: Scene);
  13908. private _prepareBuffers;
  13909. private _buildIndexBuffer;
  13910. /**
  13911. * Rebuilds the vertex buffers of the manager.
  13912. * @hidden
  13913. */
  13914. _rebuild(): void;
  13915. /**
  13916. * Prepares a frame to be run through a post process.
  13917. * @param sourceTexture The input texture to the post procesess. (default: null)
  13918. * @param postProcesses An array of post processes to be run. (default: null)
  13919. * @returns True if the post processes were able to be run.
  13920. * @hidden
  13921. */
  13922. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13923. /**
  13924. * Manually render a set of post processes to a texture.
  13925. * @param postProcesses An array of post processes to be run.
  13926. * @param targetTexture The target texture to render to.
  13927. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13928. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13929. * @param lodLevel defines which lod of the texture to render to
  13930. */
  13931. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13932. /**
  13933. * Finalize the result of the output of the postprocesses.
  13934. * @param doNotPresent If true the result will not be displayed to the screen.
  13935. * @param targetTexture The target texture to render to.
  13936. * @param faceIndex The index of the face to bind the target texture to.
  13937. * @param postProcesses The array of post processes to render.
  13938. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13939. * @hidden
  13940. */
  13941. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13942. /**
  13943. * Disposes of the post process manager.
  13944. */
  13945. dispose(): void;
  13946. }
  13947. }
  13948. declare module "babylonjs/Layers/layerSceneComponent" {
  13949. import { Scene } from "babylonjs/scene";
  13950. import { ISceneComponent } from "babylonjs/sceneComponent";
  13951. import { Layer } from "babylonjs/Layers/layer";
  13952. module "babylonjs/abstractScene" {
  13953. interface AbstractScene {
  13954. /**
  13955. * The list of layers (background and foreground) of the scene
  13956. */
  13957. layers: Array<Layer>;
  13958. }
  13959. }
  13960. /**
  13961. * Defines the layer scene component responsible to manage any layers
  13962. * in a given scene.
  13963. */
  13964. export class LayerSceneComponent implements ISceneComponent {
  13965. /**
  13966. * The component name helpfull to identify the component in the list of scene components.
  13967. */
  13968. readonly name: string;
  13969. /**
  13970. * The scene the component belongs to.
  13971. */
  13972. scene: Scene;
  13973. private _engine;
  13974. /**
  13975. * Creates a new instance of the component for the given scene
  13976. * @param scene Defines the scene to register the component in
  13977. */
  13978. constructor(scene: Scene);
  13979. /**
  13980. * Registers the component in a given scene
  13981. */
  13982. register(): void;
  13983. /**
  13984. * Rebuilds the elements related to this component in case of
  13985. * context lost for instance.
  13986. */
  13987. rebuild(): void;
  13988. /**
  13989. * Disposes the component and the associated ressources.
  13990. */
  13991. dispose(): void;
  13992. private _draw;
  13993. private _drawCameraPredicate;
  13994. private _drawCameraBackground;
  13995. private _drawCameraForeground;
  13996. private _drawRenderTargetPredicate;
  13997. private _drawRenderTargetBackground;
  13998. private _drawRenderTargetForeground;
  13999. }
  14000. }
  14001. declare module "babylonjs/Shaders/layer.fragment" {
  14002. /** @hidden */
  14003. export var layerPixelShader: {
  14004. name: string;
  14005. shader: string;
  14006. };
  14007. }
  14008. declare module "babylonjs/Shaders/layer.vertex" {
  14009. /** @hidden */
  14010. export var layerVertexShader: {
  14011. name: string;
  14012. shader: string;
  14013. };
  14014. }
  14015. declare module "babylonjs/Layers/layer" {
  14016. import { Observable } from "babylonjs/Misc/observable";
  14017. import { Nullable } from "babylonjs/types";
  14018. import { Scene } from "babylonjs/scene";
  14019. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14020. import { Texture } from "babylonjs/Materials/Textures/texture";
  14021. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14022. import "babylonjs/Shaders/layer.fragment";
  14023. import "babylonjs/Shaders/layer.vertex";
  14024. /**
  14025. * This represents a full screen 2d layer.
  14026. * This can be useful to display a picture in the background of your scene for instance.
  14027. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14028. */
  14029. export class Layer {
  14030. /**
  14031. * Define the name of the layer.
  14032. */
  14033. name: string;
  14034. /**
  14035. * Define the texture the layer should display.
  14036. */
  14037. texture: Nullable<Texture>;
  14038. /**
  14039. * Is the layer in background or foreground.
  14040. */
  14041. isBackground: boolean;
  14042. /**
  14043. * Define the color of the layer (instead of texture).
  14044. */
  14045. color: Color4;
  14046. /**
  14047. * Define the scale of the layer in order to zoom in out of the texture.
  14048. */
  14049. scale: Vector2;
  14050. /**
  14051. * Define an offset for the layer in order to shift the texture.
  14052. */
  14053. offset: Vector2;
  14054. /**
  14055. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14056. */
  14057. alphaBlendingMode: number;
  14058. /**
  14059. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14060. * Alpha test will not mix with the background color in case of transparency.
  14061. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14062. */
  14063. alphaTest: boolean;
  14064. /**
  14065. * Define a mask to restrict the layer to only some of the scene cameras.
  14066. */
  14067. layerMask: number;
  14068. /**
  14069. * Define the list of render target the layer is visible into.
  14070. */
  14071. renderTargetTextures: RenderTargetTexture[];
  14072. /**
  14073. * Define if the layer is only used in renderTarget or if it also
  14074. * renders in the main frame buffer of the canvas.
  14075. */
  14076. renderOnlyInRenderTargetTextures: boolean;
  14077. private _scene;
  14078. private _vertexBuffers;
  14079. private _indexBuffer;
  14080. private _effect;
  14081. private _alphaTestEffect;
  14082. /**
  14083. * An event triggered when the layer is disposed.
  14084. */
  14085. onDisposeObservable: Observable<Layer>;
  14086. private _onDisposeObserver;
  14087. /**
  14088. * Back compatibility with callback before the onDisposeObservable existed.
  14089. * The set callback will be triggered when the layer has been disposed.
  14090. */
  14091. onDispose: () => void;
  14092. /**
  14093. * An event triggered before rendering the scene
  14094. */
  14095. onBeforeRenderObservable: Observable<Layer>;
  14096. private _onBeforeRenderObserver;
  14097. /**
  14098. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14099. * The set callback will be triggered just before rendering the layer.
  14100. */
  14101. onBeforeRender: () => void;
  14102. /**
  14103. * An event triggered after rendering the scene
  14104. */
  14105. onAfterRenderObservable: Observable<Layer>;
  14106. private _onAfterRenderObserver;
  14107. /**
  14108. * Back compatibility with callback before the onAfterRenderObservable existed.
  14109. * The set callback will be triggered just after rendering the layer.
  14110. */
  14111. onAfterRender: () => void;
  14112. /**
  14113. * Instantiates a new layer.
  14114. * This represents a full screen 2d layer.
  14115. * This can be useful to display a picture in the background of your scene for instance.
  14116. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14117. * @param name Define the name of the layer in the scene
  14118. * @param imgUrl Define the url of the texture to display in the layer
  14119. * @param scene Define the scene the layer belongs to
  14120. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14121. * @param color Defines a color for the layer
  14122. */
  14123. constructor(
  14124. /**
  14125. * Define the name of the layer.
  14126. */
  14127. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14128. private _createIndexBuffer;
  14129. /** @hidden */
  14130. _rebuild(): void;
  14131. /**
  14132. * Renders the layer in the scene.
  14133. */
  14134. render(): void;
  14135. /**
  14136. * Disposes and releases the associated ressources.
  14137. */
  14138. dispose(): void;
  14139. }
  14140. }
  14141. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14142. import { Scene } from "babylonjs/scene";
  14143. import { ISceneComponent } from "babylonjs/sceneComponent";
  14144. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14145. module "babylonjs/abstractScene" {
  14146. interface AbstractScene {
  14147. /**
  14148. * The list of procedural textures added to the scene
  14149. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14150. */
  14151. proceduralTextures: Array<ProceduralTexture>;
  14152. }
  14153. }
  14154. /**
  14155. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14156. * in a given scene.
  14157. */
  14158. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14159. /**
  14160. * The component name helpfull to identify the component in the list of scene components.
  14161. */
  14162. readonly name: string;
  14163. /**
  14164. * The scene the component belongs to.
  14165. */
  14166. scene: Scene;
  14167. /**
  14168. * Creates a new instance of the component for the given scene
  14169. * @param scene Defines the scene to register the component in
  14170. */
  14171. constructor(scene: Scene);
  14172. /**
  14173. * Registers the component in a given scene
  14174. */
  14175. register(): void;
  14176. /**
  14177. * Rebuilds the elements related to this component in case of
  14178. * context lost for instance.
  14179. */
  14180. rebuild(): void;
  14181. /**
  14182. * Disposes the component and the associated ressources.
  14183. */
  14184. dispose(): void;
  14185. private _beforeClear;
  14186. }
  14187. }
  14188. declare module "babylonjs/Shaders/procedural.vertex" {
  14189. /** @hidden */
  14190. export var proceduralVertexShader: {
  14191. name: string;
  14192. shader: string;
  14193. };
  14194. }
  14195. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14196. import { Observable } from "babylonjs/Misc/observable";
  14197. import { Nullable } from "babylonjs/types";
  14198. import { Scene } from "babylonjs/scene";
  14199. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14200. import { Effect } from "babylonjs/Materials/effect";
  14201. import { Texture } from "babylonjs/Materials/Textures/texture";
  14202. import "babylonjs/Shaders/procedural.vertex";
  14203. /**
  14204. * 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.
  14205. * This is the base class of any Procedural texture and contains most of the shareable code.
  14206. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14207. */
  14208. export class ProceduralTexture extends Texture {
  14209. isCube: boolean;
  14210. /**
  14211. * Define if the texture is enabled or not (disabled texture will not render)
  14212. */
  14213. isEnabled: boolean;
  14214. /**
  14215. * Define if the texture must be cleared before rendering (default is true)
  14216. */
  14217. autoClear: boolean;
  14218. /**
  14219. * Callback called when the texture is generated
  14220. */
  14221. onGenerated: () => void;
  14222. /**
  14223. * Event raised when the texture is generated
  14224. */
  14225. onGeneratedObservable: Observable<ProceduralTexture>;
  14226. /** @hidden */
  14227. _generateMipMaps: boolean;
  14228. /** @hidden **/
  14229. _effect: Effect;
  14230. /** @hidden */
  14231. _textures: {
  14232. [key: string]: Texture;
  14233. };
  14234. private _size;
  14235. private _currentRefreshId;
  14236. private _refreshRate;
  14237. private _vertexBuffers;
  14238. private _indexBuffer;
  14239. private _uniforms;
  14240. private _samplers;
  14241. private _fragment;
  14242. private _floats;
  14243. private _ints;
  14244. private _floatsArrays;
  14245. private _colors3;
  14246. private _colors4;
  14247. private _vectors2;
  14248. private _vectors3;
  14249. private _matrices;
  14250. private _fallbackTexture;
  14251. private _fallbackTextureUsed;
  14252. private _engine;
  14253. private _cachedDefines;
  14254. private _contentUpdateId;
  14255. private _contentData;
  14256. /**
  14257. * Instantiates a new procedural texture.
  14258. * 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.
  14259. * This is the base class of any Procedural texture and contains most of the shareable code.
  14260. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14261. * @param name Define the name of the texture
  14262. * @param size Define the size of the texture to create
  14263. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14264. * @param scene Define the scene the texture belongs to
  14265. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14266. * @param generateMipMaps Define if the texture should creates mip maps or not
  14267. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14268. */
  14269. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14270. /**
  14271. * The effect that is created when initializing the post process.
  14272. * @returns The created effect corrisponding the the postprocess.
  14273. */
  14274. getEffect(): Effect;
  14275. /**
  14276. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14277. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14278. */
  14279. getContent(): Nullable<ArrayBufferView>;
  14280. private _createIndexBuffer;
  14281. /** @hidden */
  14282. _rebuild(): void;
  14283. /**
  14284. * Resets the texture in order to recreate its associated resources.
  14285. * This can be called in case of context loss
  14286. */
  14287. reset(): void;
  14288. protected _getDefines(): string;
  14289. /**
  14290. * Is the texture ready to be used ? (rendered at least once)
  14291. * @returns true if ready, otherwise, false.
  14292. */
  14293. isReady(): boolean;
  14294. /**
  14295. * Resets the refresh counter of the texture and start bak from scratch.
  14296. * Could be useful to regenerate the texture if it is setup to render only once.
  14297. */
  14298. resetRefreshCounter(): void;
  14299. /**
  14300. * Set the fragment shader to use in order to render the texture.
  14301. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14302. */
  14303. setFragment(fragment: any): void;
  14304. /**
  14305. * Define the refresh rate of the texture or the rendering frequency.
  14306. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14307. */
  14308. refreshRate: number;
  14309. /** @hidden */
  14310. _shouldRender(): boolean;
  14311. /**
  14312. * Get the size the texture is rendering at.
  14313. * @returns the size (texture is always squared)
  14314. */
  14315. getRenderSize(): number;
  14316. /**
  14317. * Resize the texture to new value.
  14318. * @param size Define the new size the texture should have
  14319. * @param generateMipMaps Define whether the new texture should create mip maps
  14320. */
  14321. resize(size: number, generateMipMaps: boolean): void;
  14322. private _checkUniform;
  14323. /**
  14324. * Set a texture in the shader program used to render.
  14325. * @param name Define the name of the uniform samplers as defined in the shader
  14326. * @param texture Define the texture to bind to this sampler
  14327. * @return the texture itself allowing "fluent" like uniform updates
  14328. */
  14329. setTexture(name: string, texture: Texture): ProceduralTexture;
  14330. /**
  14331. * Set a float in the shader.
  14332. * @param name Define the name of the uniform as defined in the shader
  14333. * @param value Define the value to give to the uniform
  14334. * @return the texture itself allowing "fluent" like uniform updates
  14335. */
  14336. setFloat(name: string, value: number): ProceduralTexture;
  14337. /**
  14338. * Set a int in the shader.
  14339. * @param name Define the name of the uniform as defined in the shader
  14340. * @param value Define the value to give to the uniform
  14341. * @return the texture itself allowing "fluent" like uniform updates
  14342. */
  14343. setInt(name: string, value: number): ProceduralTexture;
  14344. /**
  14345. * Set an array of floats in the shader.
  14346. * @param name Define the name of the uniform as defined in the shader
  14347. * @param value Define the value to give to the uniform
  14348. * @return the texture itself allowing "fluent" like uniform updates
  14349. */
  14350. setFloats(name: string, value: number[]): ProceduralTexture;
  14351. /**
  14352. * Set a vec3 in the shader from a Color3.
  14353. * @param name Define the name of the uniform as defined in the shader
  14354. * @param value Define the value to give to the uniform
  14355. * @return the texture itself allowing "fluent" like uniform updates
  14356. */
  14357. setColor3(name: string, value: Color3): ProceduralTexture;
  14358. /**
  14359. * Set a vec4 in the shader from a Color4.
  14360. * @param name Define the name of the uniform as defined in the shader
  14361. * @param value Define the value to give to the uniform
  14362. * @return the texture itself allowing "fluent" like uniform updates
  14363. */
  14364. setColor4(name: string, value: Color4): ProceduralTexture;
  14365. /**
  14366. * Set a vec2 in the shader from a Vector2.
  14367. * @param name Define the name of the uniform as defined in the shader
  14368. * @param value Define the value to give to the uniform
  14369. * @return the texture itself allowing "fluent" like uniform updates
  14370. */
  14371. setVector2(name: string, value: Vector2): ProceduralTexture;
  14372. /**
  14373. * Set a vec3 in the shader from a Vector3.
  14374. * @param name Define the name of the uniform as defined in the shader
  14375. * @param value Define the value to give to the uniform
  14376. * @return the texture itself allowing "fluent" like uniform updates
  14377. */
  14378. setVector3(name: string, value: Vector3): ProceduralTexture;
  14379. /**
  14380. * Set a mat4 in the shader from a MAtrix.
  14381. * @param name Define the name of the uniform as defined in the shader
  14382. * @param value Define the value to give to the uniform
  14383. * @return the texture itself allowing "fluent" like uniform updates
  14384. */
  14385. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14386. /**
  14387. * Render the texture to its associated render target.
  14388. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14389. */
  14390. render(useCameraPostProcess?: boolean): void;
  14391. /**
  14392. * Clone the texture.
  14393. * @returns the cloned texture
  14394. */
  14395. clone(): ProceduralTexture;
  14396. /**
  14397. * Dispose the texture and release its asoociated resources.
  14398. */
  14399. dispose(): void;
  14400. }
  14401. }
  14402. declare module "babylonjs/Particles/baseParticleSystem" {
  14403. import { Nullable } from "babylonjs/types";
  14404. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14406. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14407. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14408. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14409. import { Scene } from "babylonjs/scene";
  14410. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14411. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14412. import { Texture } from "babylonjs/Materials/Textures/texture";
  14413. import { Animation } from "babylonjs/Animations/animation";
  14414. /**
  14415. * This represents the base class for particle system in Babylon.
  14416. * 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.
  14417. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14418. * @example https://doc.babylonjs.com/babylon101/particles
  14419. */
  14420. export class BaseParticleSystem {
  14421. /**
  14422. * Source color is added to the destination color without alpha affecting the result
  14423. */
  14424. static BLENDMODE_ONEONE: number;
  14425. /**
  14426. * Blend current color and particle color using particle’s alpha
  14427. */
  14428. static BLENDMODE_STANDARD: number;
  14429. /**
  14430. * Add current color and particle color multiplied by particle’s alpha
  14431. */
  14432. static BLENDMODE_ADD: number;
  14433. /**
  14434. * Multiply current color with particle color
  14435. */
  14436. static BLENDMODE_MULTIPLY: number;
  14437. /**
  14438. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14439. */
  14440. static BLENDMODE_MULTIPLYADD: number;
  14441. /**
  14442. * List of animations used by the particle system.
  14443. */
  14444. animations: Animation[];
  14445. /**
  14446. * The id of the Particle system.
  14447. */
  14448. id: string;
  14449. /**
  14450. * The friendly name of the Particle system.
  14451. */
  14452. name: string;
  14453. /**
  14454. * The rendering group used by the Particle system to chose when to render.
  14455. */
  14456. renderingGroupId: number;
  14457. /**
  14458. * The emitter represents the Mesh or position we are attaching the particle system to.
  14459. */
  14460. emitter: Nullable<AbstractMesh | Vector3>;
  14461. /**
  14462. * The maximum number of particles to emit per frame
  14463. */
  14464. emitRate: number;
  14465. /**
  14466. * If you want to launch only a few particles at once, that can be done, as well.
  14467. */
  14468. manualEmitCount: number;
  14469. /**
  14470. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14471. */
  14472. updateSpeed: number;
  14473. /**
  14474. * The amount of time the particle system is running (depends of the overall update speed).
  14475. */
  14476. targetStopDuration: number;
  14477. /**
  14478. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14479. */
  14480. disposeOnStop: boolean;
  14481. /**
  14482. * Minimum power of emitting particles.
  14483. */
  14484. minEmitPower: number;
  14485. /**
  14486. * Maximum power of emitting particles.
  14487. */
  14488. maxEmitPower: number;
  14489. /**
  14490. * Minimum life time of emitting particles.
  14491. */
  14492. minLifeTime: number;
  14493. /**
  14494. * Maximum life time of emitting particles.
  14495. */
  14496. maxLifeTime: number;
  14497. /**
  14498. * Minimum Size of emitting particles.
  14499. */
  14500. minSize: number;
  14501. /**
  14502. * Maximum Size of emitting particles.
  14503. */
  14504. maxSize: number;
  14505. /**
  14506. * Minimum scale of emitting particles on X axis.
  14507. */
  14508. minScaleX: number;
  14509. /**
  14510. * Maximum scale of emitting particles on X axis.
  14511. */
  14512. maxScaleX: number;
  14513. /**
  14514. * Minimum scale of emitting particles on Y axis.
  14515. */
  14516. minScaleY: number;
  14517. /**
  14518. * Maximum scale of emitting particles on Y axis.
  14519. */
  14520. maxScaleY: number;
  14521. /**
  14522. * Gets or sets the minimal initial rotation in radians.
  14523. */
  14524. minInitialRotation: number;
  14525. /**
  14526. * Gets or sets the maximal initial rotation in radians.
  14527. */
  14528. maxInitialRotation: number;
  14529. /**
  14530. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14531. */
  14532. minAngularSpeed: number;
  14533. /**
  14534. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14535. */
  14536. maxAngularSpeed: number;
  14537. /**
  14538. * The texture used to render each particle. (this can be a spritesheet)
  14539. */
  14540. particleTexture: Nullable<Texture>;
  14541. /**
  14542. * The layer mask we are rendering the particles through.
  14543. */
  14544. layerMask: number;
  14545. /**
  14546. * This can help using your own shader to render the particle system.
  14547. * The according effect will be created
  14548. */
  14549. customShader: any;
  14550. /**
  14551. * By default particle system starts as soon as they are created. This prevents the
  14552. * automatic start to happen and let you decide when to start emitting particles.
  14553. */
  14554. preventAutoStart: boolean;
  14555. private _noiseTexture;
  14556. /**
  14557. * Gets or sets a texture used to add random noise to particle positions
  14558. */
  14559. noiseTexture: Nullable<ProceduralTexture>;
  14560. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14561. noiseStrength: Vector3;
  14562. /**
  14563. * Callback triggered when the particle animation is ending.
  14564. */
  14565. onAnimationEnd: Nullable<() => void>;
  14566. /**
  14567. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14568. */
  14569. blendMode: number;
  14570. /**
  14571. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14572. * to override the particles.
  14573. */
  14574. forceDepthWrite: boolean;
  14575. /** 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 */
  14576. preWarmCycles: number;
  14577. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14578. preWarmStepOffset: number;
  14579. /**
  14580. * 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)
  14581. */
  14582. spriteCellChangeSpeed: number;
  14583. /**
  14584. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14585. */
  14586. startSpriteCellID: number;
  14587. /**
  14588. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14589. */
  14590. endSpriteCellID: number;
  14591. /**
  14592. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14593. */
  14594. spriteCellWidth: number;
  14595. /**
  14596. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14597. */
  14598. spriteCellHeight: number;
  14599. /**
  14600. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14601. */
  14602. spriteRandomStartCell: boolean;
  14603. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14604. translationPivot: Vector2;
  14605. /** @hidden */
  14606. protected _isAnimationSheetEnabled: boolean;
  14607. /**
  14608. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14609. */
  14610. beginAnimationOnStart: boolean;
  14611. /**
  14612. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14613. */
  14614. beginAnimationFrom: number;
  14615. /**
  14616. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14617. */
  14618. beginAnimationTo: number;
  14619. /**
  14620. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14621. */
  14622. beginAnimationLoop: boolean;
  14623. /**
  14624. * Gets or sets a world offset applied to all particles
  14625. */
  14626. worldOffset: Vector3;
  14627. /**
  14628. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14629. */
  14630. isAnimationSheetEnabled: boolean;
  14631. /**
  14632. * Get hosting scene
  14633. * @returns the scene
  14634. */
  14635. getScene(): Scene;
  14636. /**
  14637. * You can use gravity if you want to give an orientation to your particles.
  14638. */
  14639. gravity: Vector3;
  14640. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14641. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14642. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14643. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14644. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14645. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14646. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14647. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14648. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14649. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14650. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14651. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14652. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14653. /**
  14654. * Defines the delay in milliseconds before starting the system (0 by default)
  14655. */
  14656. startDelay: number;
  14657. /**
  14658. * Gets the current list of drag gradients.
  14659. * You must use addDragGradient and removeDragGradient to udpate this list
  14660. * @returns the list of drag gradients
  14661. */
  14662. getDragGradients(): Nullable<Array<FactorGradient>>;
  14663. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14664. limitVelocityDamping: number;
  14665. /**
  14666. * Gets the current list of limit velocity gradients.
  14667. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14668. * @returns the list of limit velocity gradients
  14669. */
  14670. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14671. /**
  14672. * Gets the current list of color gradients.
  14673. * You must use addColorGradient and removeColorGradient to udpate this list
  14674. * @returns the list of color gradients
  14675. */
  14676. getColorGradients(): Nullable<Array<ColorGradient>>;
  14677. /**
  14678. * Gets the current list of size gradients.
  14679. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14680. * @returns the list of size gradients
  14681. */
  14682. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14683. /**
  14684. * Gets the current list of color remap gradients.
  14685. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14686. * @returns the list of color remap gradients
  14687. */
  14688. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14689. /**
  14690. * Gets the current list of alpha remap gradients.
  14691. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14692. * @returns the list of alpha remap gradients
  14693. */
  14694. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14695. /**
  14696. * Gets the current list of life time gradients.
  14697. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14698. * @returns the list of life time gradients
  14699. */
  14700. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14701. /**
  14702. * Gets the current list of angular speed gradients.
  14703. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14704. * @returns the list of angular speed gradients
  14705. */
  14706. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14707. /**
  14708. * Gets the current list of velocity gradients.
  14709. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14710. * @returns the list of velocity gradients
  14711. */
  14712. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14713. /**
  14714. * Gets the current list of start size gradients.
  14715. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14716. * @returns the list of start size gradients
  14717. */
  14718. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14719. /**
  14720. * Gets the current list of emit rate gradients.
  14721. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14722. * @returns the list of emit rate gradients
  14723. */
  14724. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14725. /**
  14726. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14727. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14728. */
  14729. direction1: Vector3;
  14730. /**
  14731. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14732. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14733. */
  14734. direction2: Vector3;
  14735. /**
  14736. * 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.
  14737. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14738. */
  14739. minEmitBox: Vector3;
  14740. /**
  14741. * 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.
  14742. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14743. */
  14744. maxEmitBox: Vector3;
  14745. /**
  14746. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14747. */
  14748. color1: Color4;
  14749. /**
  14750. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14751. */
  14752. color2: Color4;
  14753. /**
  14754. * Color the particle will have at the end of its lifetime
  14755. */
  14756. colorDead: Color4;
  14757. /**
  14758. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14759. */
  14760. textureMask: Color4;
  14761. /**
  14762. * The particle emitter type defines the emitter used by the particle system.
  14763. * It can be for example box, sphere, or cone...
  14764. */
  14765. particleEmitterType: IParticleEmitterType;
  14766. /** @hidden */
  14767. _isSubEmitter: boolean;
  14768. /**
  14769. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14770. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14771. */
  14772. billboardMode: number;
  14773. protected _isBillboardBased: boolean;
  14774. /**
  14775. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14776. */
  14777. isBillboardBased: boolean;
  14778. /**
  14779. * The scene the particle system belongs to.
  14780. */
  14781. protected _scene: Scene;
  14782. /**
  14783. * Local cache of defines for image processing.
  14784. */
  14785. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14786. /**
  14787. * Default configuration related to image processing available in the standard Material.
  14788. */
  14789. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14790. /**
  14791. * Gets the image processing configuration used either in this material.
  14792. */
  14793. /**
  14794. * Sets the Default image processing configuration used either in the this material.
  14795. *
  14796. * If sets to null, the scene one is in use.
  14797. */
  14798. imageProcessingConfiguration: ImageProcessingConfiguration;
  14799. /**
  14800. * Attaches a new image processing configuration to the Standard Material.
  14801. * @param configuration
  14802. */
  14803. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14804. /** @hidden */
  14805. protected _reset(): void;
  14806. /** @hidden */
  14807. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14808. /**
  14809. * Instantiates a particle system.
  14810. * 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.
  14811. * @param name The name of the particle system
  14812. */
  14813. constructor(name: string);
  14814. /**
  14815. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14816. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14817. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14818. * @returns the emitter
  14819. */
  14820. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14821. /**
  14822. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14823. * @param radius The radius of the hemisphere to emit from
  14824. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14825. * @returns the emitter
  14826. */
  14827. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14828. /**
  14829. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14830. * @param radius The radius of the sphere to emit from
  14831. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14832. * @returns the emitter
  14833. */
  14834. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14835. /**
  14836. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14837. * @param radius The radius of the sphere to emit from
  14838. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14839. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14840. * @returns the emitter
  14841. */
  14842. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14843. /**
  14844. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14845. * @param radius The radius of the emission cylinder
  14846. * @param height The height of the emission cylinder
  14847. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14848. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14849. * @returns the emitter
  14850. */
  14851. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14852. /**
  14853. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14854. * @param radius The radius of the cylinder to emit from
  14855. * @param height The height of the emission cylinder
  14856. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14857. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14858. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14859. * @returns the emitter
  14860. */
  14861. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14862. /**
  14863. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14864. * @param radius The radius of the cone to emit from
  14865. * @param angle The base angle of the cone
  14866. * @returns the emitter
  14867. */
  14868. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14869. /**
  14870. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14871. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14872. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14873. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14874. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14875. * @returns the emitter
  14876. */
  14877. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14878. }
  14879. }
  14880. declare module "babylonjs/Particles/subEmitter" {
  14881. import { Scene } from "babylonjs/scene";
  14882. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14883. /**
  14884. * Type of sub emitter
  14885. */
  14886. export enum SubEmitterType {
  14887. /**
  14888. * Attached to the particle over it's lifetime
  14889. */
  14890. ATTACHED = 0,
  14891. /**
  14892. * Created when the particle dies
  14893. */
  14894. END = 1
  14895. }
  14896. /**
  14897. * Sub emitter class used to emit particles from an existing particle
  14898. */
  14899. export class SubEmitter {
  14900. /**
  14901. * the particle system to be used by the sub emitter
  14902. */
  14903. particleSystem: ParticleSystem;
  14904. /**
  14905. * Type of the submitter (Default: END)
  14906. */
  14907. type: SubEmitterType;
  14908. /**
  14909. * 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)
  14910. * Note: This only is supported when using an emitter of type Mesh
  14911. */
  14912. inheritDirection: boolean;
  14913. /**
  14914. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14915. */
  14916. inheritedVelocityAmount: number;
  14917. /**
  14918. * Creates a sub emitter
  14919. * @param particleSystem the particle system to be used by the sub emitter
  14920. */
  14921. constructor(
  14922. /**
  14923. * the particle system to be used by the sub emitter
  14924. */
  14925. particleSystem: ParticleSystem);
  14926. /**
  14927. * Clones the sub emitter
  14928. * @returns the cloned sub emitter
  14929. */
  14930. clone(): SubEmitter;
  14931. /**
  14932. * Serialize current object to a JSON object
  14933. * @returns the serialized object
  14934. */
  14935. serialize(): any;
  14936. /** @hidden */
  14937. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14938. /**
  14939. * Creates a new SubEmitter from a serialized JSON version
  14940. * @param serializationObject defines the JSON object to read from
  14941. * @param scene defines the hosting scene
  14942. * @param rootUrl defines the rootUrl for data loading
  14943. * @returns a new SubEmitter
  14944. */
  14945. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14946. /** Release associated resources */
  14947. dispose(): void;
  14948. }
  14949. }
  14950. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14951. /** @hidden */
  14952. export var clipPlaneFragmentDeclaration: {
  14953. name: string;
  14954. shader: string;
  14955. };
  14956. }
  14957. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14958. /** @hidden */
  14959. export var imageProcessingDeclaration: {
  14960. name: string;
  14961. shader: string;
  14962. };
  14963. }
  14964. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14965. /** @hidden */
  14966. export var imageProcessingFunctions: {
  14967. name: string;
  14968. shader: string;
  14969. };
  14970. }
  14971. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14972. /** @hidden */
  14973. export var clipPlaneFragment: {
  14974. name: string;
  14975. shader: string;
  14976. };
  14977. }
  14978. declare module "babylonjs/Shaders/particles.fragment" {
  14979. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14980. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14981. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14982. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14983. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14984. /** @hidden */
  14985. export var particlesPixelShader: {
  14986. name: string;
  14987. shader: string;
  14988. };
  14989. }
  14990. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14991. /** @hidden */
  14992. export var clipPlaneVertexDeclaration: {
  14993. name: string;
  14994. shader: string;
  14995. };
  14996. }
  14997. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14998. /** @hidden */
  14999. export var clipPlaneVertex: {
  15000. name: string;
  15001. shader: string;
  15002. };
  15003. }
  15004. declare module "babylonjs/Shaders/particles.vertex" {
  15005. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15006. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15007. /** @hidden */
  15008. export var particlesVertexShader: {
  15009. name: string;
  15010. shader: string;
  15011. };
  15012. }
  15013. declare module "babylonjs/Particles/particleSystem" {
  15014. import { Nullable } from "babylonjs/types";
  15015. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15016. import { Observable } from "babylonjs/Misc/observable";
  15017. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15018. import { Effect } from "babylonjs/Materials/effect";
  15019. import { Scene, IDisposable } from "babylonjs/scene";
  15020. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15021. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15022. import { Particle } from "babylonjs/Particles/particle";
  15023. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15024. import "babylonjs/Shaders/particles.fragment";
  15025. import "babylonjs/Shaders/particles.vertex";
  15026. /**
  15027. * This represents a particle system in Babylon.
  15028. * 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.
  15029. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15030. * @example https://doc.babylonjs.com/babylon101/particles
  15031. */
  15032. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15033. /**
  15034. * Billboard mode will only apply to Y axis
  15035. */
  15036. static readonly BILLBOARDMODE_Y: number;
  15037. /**
  15038. * Billboard mode will apply to all axes
  15039. */
  15040. static readonly BILLBOARDMODE_ALL: number;
  15041. /**
  15042. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15043. */
  15044. static readonly BILLBOARDMODE_STRETCHED: number;
  15045. /**
  15046. * This function can be defined to provide custom update for active particles.
  15047. * This function will be called instead of regular update (age, position, color, etc.).
  15048. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15049. */
  15050. updateFunction: (particles: Particle[]) => void;
  15051. private _emitterWorldMatrix;
  15052. /**
  15053. * This function can be defined to specify initial direction for every new particle.
  15054. * It by default use the emitterType defined function
  15055. */
  15056. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15057. /**
  15058. * This function can be defined to specify initial position for every new particle.
  15059. * It by default use the emitterType defined function
  15060. */
  15061. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15062. /**
  15063. * @hidden
  15064. */
  15065. _inheritedVelocityOffset: Vector3;
  15066. /**
  15067. * An event triggered when the system is disposed
  15068. */
  15069. onDisposeObservable: Observable<ParticleSystem>;
  15070. private _onDisposeObserver;
  15071. /**
  15072. * Sets a callback that will be triggered when the system is disposed
  15073. */
  15074. onDispose: () => void;
  15075. private _particles;
  15076. private _epsilon;
  15077. private _capacity;
  15078. private _stockParticles;
  15079. private _newPartsExcess;
  15080. private _vertexData;
  15081. private _vertexBuffer;
  15082. private _vertexBuffers;
  15083. private _spriteBuffer;
  15084. private _indexBuffer;
  15085. private _effect;
  15086. private _customEffect;
  15087. private _cachedDefines;
  15088. private _scaledColorStep;
  15089. private _colorDiff;
  15090. private _scaledDirection;
  15091. private _scaledGravity;
  15092. private _currentRenderId;
  15093. private _alive;
  15094. private _useInstancing;
  15095. private _started;
  15096. private _stopped;
  15097. private _actualFrame;
  15098. private _scaledUpdateSpeed;
  15099. private _vertexBufferSize;
  15100. /** @hidden */
  15101. _currentEmitRateGradient: Nullable<FactorGradient>;
  15102. /** @hidden */
  15103. _currentEmitRate1: number;
  15104. /** @hidden */
  15105. _currentEmitRate2: number;
  15106. /** @hidden */
  15107. _currentStartSizeGradient: Nullable<FactorGradient>;
  15108. /** @hidden */
  15109. _currentStartSize1: number;
  15110. /** @hidden */
  15111. _currentStartSize2: number;
  15112. private readonly _rawTextureWidth;
  15113. private _rampGradientsTexture;
  15114. private _useRampGradients;
  15115. /** Gets or sets a boolean indicating that ramp gradients must be used
  15116. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15117. */
  15118. useRampGradients: boolean;
  15119. /**
  15120. * 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.
  15121. * 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: [])
  15122. */
  15123. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15124. private _subEmitters;
  15125. /**
  15126. * @hidden
  15127. * If the particle systems emitter should be disposed when the particle system is disposed
  15128. */
  15129. _disposeEmitterOnDispose: boolean;
  15130. /**
  15131. * The current active Sub-systems, this property is used by the root particle system only.
  15132. */
  15133. activeSubSystems: Array<ParticleSystem>;
  15134. private _rootParticleSystem;
  15135. /**
  15136. * Gets the current list of active particles
  15137. */
  15138. readonly particles: Particle[];
  15139. /**
  15140. * Returns the string "ParticleSystem"
  15141. * @returns a string containing the class name
  15142. */
  15143. getClassName(): string;
  15144. /**
  15145. * Instantiates a particle system.
  15146. * 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.
  15147. * @param name The name of the particle system
  15148. * @param capacity The max number of particles alive at the same time
  15149. * @param scene The scene the particle system belongs to
  15150. * @param customEffect a custom effect used to change the way particles are rendered by default
  15151. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15152. * @param epsilon Offset used to render the particles
  15153. */
  15154. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15155. private _addFactorGradient;
  15156. private _removeFactorGradient;
  15157. /**
  15158. * Adds a new life time gradient
  15159. * @param gradient defines the gradient to use (between 0 and 1)
  15160. * @param factor defines the life time factor to affect to the specified gradient
  15161. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15162. * @returns the current particle system
  15163. */
  15164. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15165. /**
  15166. * Remove a specific life time gradient
  15167. * @param gradient defines the gradient to remove
  15168. * @returns the current particle system
  15169. */
  15170. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15171. /**
  15172. * Adds a new size gradient
  15173. * @param gradient defines the gradient to use (between 0 and 1)
  15174. * @param factor defines the size factor to affect to the specified gradient
  15175. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15176. * @returns the current particle system
  15177. */
  15178. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15179. /**
  15180. * Remove a specific size gradient
  15181. * @param gradient defines the gradient to remove
  15182. * @returns the current particle system
  15183. */
  15184. removeSizeGradient(gradient: number): IParticleSystem;
  15185. /**
  15186. * Adds a new color remap gradient
  15187. * @param gradient defines the gradient to use (between 0 and 1)
  15188. * @param min defines the color remap minimal range
  15189. * @param max defines the color remap maximal range
  15190. * @returns the current particle system
  15191. */
  15192. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15193. /**
  15194. * Remove a specific color remap gradient
  15195. * @param gradient defines the gradient to remove
  15196. * @returns the current particle system
  15197. */
  15198. removeColorRemapGradient(gradient: number): IParticleSystem;
  15199. /**
  15200. * Adds a new alpha remap gradient
  15201. * @param gradient defines the gradient to use (between 0 and 1)
  15202. * @param min defines the alpha remap minimal range
  15203. * @param max defines the alpha remap maximal range
  15204. * @returns the current particle system
  15205. */
  15206. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15207. /**
  15208. * Remove a specific alpha remap gradient
  15209. * @param gradient defines the gradient to remove
  15210. * @returns the current particle system
  15211. */
  15212. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15213. /**
  15214. * Adds a new angular speed gradient
  15215. * @param gradient defines the gradient to use (between 0 and 1)
  15216. * @param factor defines the angular speed to affect to the specified gradient
  15217. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15218. * @returns the current particle system
  15219. */
  15220. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15221. /**
  15222. * Remove a specific angular speed gradient
  15223. * @param gradient defines the gradient to remove
  15224. * @returns the current particle system
  15225. */
  15226. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15227. /**
  15228. * Adds a new velocity gradient
  15229. * @param gradient defines the gradient to use (between 0 and 1)
  15230. * @param factor defines the velocity to affect to the specified gradient
  15231. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15232. * @returns the current particle system
  15233. */
  15234. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15235. /**
  15236. * Remove a specific velocity gradient
  15237. * @param gradient defines the gradient to remove
  15238. * @returns the current particle system
  15239. */
  15240. removeVelocityGradient(gradient: number): IParticleSystem;
  15241. /**
  15242. * Adds a new limit velocity gradient
  15243. * @param gradient defines the gradient to use (between 0 and 1)
  15244. * @param factor defines the limit velocity value to affect to the specified gradient
  15245. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15246. * @returns the current particle system
  15247. */
  15248. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15249. /**
  15250. * Remove a specific limit velocity gradient
  15251. * @param gradient defines the gradient to remove
  15252. * @returns the current particle system
  15253. */
  15254. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15255. /**
  15256. * Adds a new drag gradient
  15257. * @param gradient defines the gradient to use (between 0 and 1)
  15258. * @param factor defines the drag value to affect to the specified gradient
  15259. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15260. * @returns the current particle system
  15261. */
  15262. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15263. /**
  15264. * Remove a specific drag gradient
  15265. * @param gradient defines the gradient to remove
  15266. * @returns the current particle system
  15267. */
  15268. removeDragGradient(gradient: number): IParticleSystem;
  15269. /**
  15270. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15271. * @param gradient defines the gradient to use (between 0 and 1)
  15272. * @param factor defines the emit rate value to affect to the specified gradient
  15273. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15274. * @returns the current particle system
  15275. */
  15276. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15277. /**
  15278. * Remove a specific emit rate gradient
  15279. * @param gradient defines the gradient to remove
  15280. * @returns the current particle system
  15281. */
  15282. removeEmitRateGradient(gradient: number): IParticleSystem;
  15283. /**
  15284. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15285. * @param gradient defines the gradient to use (between 0 and 1)
  15286. * @param factor defines the start size value to affect to the specified gradient
  15287. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15288. * @returns the current particle system
  15289. */
  15290. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15291. /**
  15292. * Remove a specific start size gradient
  15293. * @param gradient defines the gradient to remove
  15294. * @returns the current particle system
  15295. */
  15296. removeStartSizeGradient(gradient: number): IParticleSystem;
  15297. private _createRampGradientTexture;
  15298. /**
  15299. * Gets the current list of ramp gradients.
  15300. * You must use addRampGradient and removeRampGradient to udpate this list
  15301. * @returns the list of ramp gradients
  15302. */
  15303. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15304. /**
  15305. * Adds a new ramp gradient used to remap particle colors
  15306. * @param gradient defines the gradient to use (between 0 and 1)
  15307. * @param color defines the color to affect to the specified gradient
  15308. * @returns the current particle system
  15309. */
  15310. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15311. /**
  15312. * Remove a specific ramp gradient
  15313. * @param gradient defines the gradient to remove
  15314. * @returns the current particle system
  15315. */
  15316. removeRampGradient(gradient: number): ParticleSystem;
  15317. /**
  15318. * Adds a new color gradient
  15319. * @param gradient defines the gradient to use (between 0 and 1)
  15320. * @param color1 defines the color to affect to the specified gradient
  15321. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15322. * @returns this particle system
  15323. */
  15324. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15325. /**
  15326. * Remove a specific color gradient
  15327. * @param gradient defines the gradient to remove
  15328. * @returns this particle system
  15329. */
  15330. removeColorGradient(gradient: number): IParticleSystem;
  15331. private _fetchR;
  15332. protected _reset(): void;
  15333. private _resetEffect;
  15334. private _createVertexBuffers;
  15335. private _createIndexBuffer;
  15336. /**
  15337. * Gets the maximum number of particles active at the same time.
  15338. * @returns The max number of active particles.
  15339. */
  15340. getCapacity(): number;
  15341. /**
  15342. * Gets whether there are still active particles in the system.
  15343. * @returns True if it is alive, otherwise false.
  15344. */
  15345. isAlive(): boolean;
  15346. /**
  15347. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15348. * @returns True if it has been started, otherwise false.
  15349. */
  15350. isStarted(): boolean;
  15351. private _prepareSubEmitterInternalArray;
  15352. /**
  15353. * Starts the particle system and begins to emit
  15354. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15355. */
  15356. start(delay?: number): void;
  15357. /**
  15358. * Stops the particle system.
  15359. * @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.
  15360. */
  15361. stop(stopSubEmitters?: boolean): void;
  15362. /**
  15363. * Remove all active particles
  15364. */
  15365. reset(): void;
  15366. /**
  15367. * @hidden (for internal use only)
  15368. */
  15369. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15370. /**
  15371. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15372. * Its lifetime will start back at 0.
  15373. */
  15374. recycleParticle: (particle: Particle) => void;
  15375. private _stopSubEmitters;
  15376. private _createParticle;
  15377. private _removeFromRoot;
  15378. private _emitFromParticle;
  15379. private _update;
  15380. /** @hidden */
  15381. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15382. /** @hidden */
  15383. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15384. /** @hidden */
  15385. private _getEffect;
  15386. /**
  15387. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15388. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15389. */
  15390. animate(preWarmOnly?: boolean): void;
  15391. private _appendParticleVertices;
  15392. /**
  15393. * Rebuilds the particle system.
  15394. */
  15395. rebuild(): void;
  15396. /**
  15397. * Is this system ready to be used/rendered
  15398. * @return true if the system is ready
  15399. */
  15400. isReady(): boolean;
  15401. private _render;
  15402. /**
  15403. * Renders the particle system in its current state.
  15404. * @returns the current number of particles
  15405. */
  15406. render(): number;
  15407. /**
  15408. * Disposes the particle system and free the associated resources
  15409. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15410. */
  15411. dispose(disposeTexture?: boolean): void;
  15412. /**
  15413. * Clones the particle system.
  15414. * @param name The name of the cloned object
  15415. * @param newEmitter The new emitter to use
  15416. * @returns the cloned particle system
  15417. */
  15418. clone(name: string, newEmitter: any): ParticleSystem;
  15419. /**
  15420. * Serializes the particle system to a JSON object.
  15421. * @returns the JSON object
  15422. */
  15423. serialize(): any;
  15424. /** @hidden */
  15425. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15426. /** @hidden */
  15427. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15428. /**
  15429. * Parses a JSON object to create a particle system.
  15430. * @param parsedParticleSystem The JSON object to parse
  15431. * @param scene The scene to create the particle system in
  15432. * @param rootUrl The root url to use to load external dependencies like texture
  15433. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15434. * @returns the Parsed particle system
  15435. */
  15436. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15437. }
  15438. }
  15439. declare module "babylonjs/Particles/particle" {
  15440. import { Nullable } from "babylonjs/types";
  15441. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15442. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15443. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15444. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15445. /**
  15446. * A particle represents one of the element emitted by a particle system.
  15447. * This is mainly define by its coordinates, direction, velocity and age.
  15448. */
  15449. export class Particle {
  15450. /**
  15451. * The particle system the particle belongs to.
  15452. */
  15453. particleSystem: ParticleSystem;
  15454. private static _Count;
  15455. /**
  15456. * Unique ID of the particle
  15457. */
  15458. id: number;
  15459. /**
  15460. * The world position of the particle in the scene.
  15461. */
  15462. position: Vector3;
  15463. /**
  15464. * The world direction of the particle in the scene.
  15465. */
  15466. direction: Vector3;
  15467. /**
  15468. * The color of the particle.
  15469. */
  15470. color: Color4;
  15471. /**
  15472. * The color change of the particle per step.
  15473. */
  15474. colorStep: Color4;
  15475. /**
  15476. * Defines how long will the life of the particle be.
  15477. */
  15478. lifeTime: number;
  15479. /**
  15480. * The current age of the particle.
  15481. */
  15482. age: number;
  15483. /**
  15484. * The current size of the particle.
  15485. */
  15486. size: number;
  15487. /**
  15488. * The current scale of the particle.
  15489. */
  15490. scale: Vector2;
  15491. /**
  15492. * The current angle of the particle.
  15493. */
  15494. angle: number;
  15495. /**
  15496. * Defines how fast is the angle changing.
  15497. */
  15498. angularSpeed: number;
  15499. /**
  15500. * Defines the cell index used by the particle to be rendered from a sprite.
  15501. */
  15502. cellIndex: number;
  15503. /**
  15504. * The information required to support color remapping
  15505. */
  15506. remapData: Vector4;
  15507. /** @hidden */
  15508. _randomCellOffset?: number;
  15509. /** @hidden */
  15510. _initialDirection: Nullable<Vector3>;
  15511. /** @hidden */
  15512. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15513. /** @hidden */
  15514. _initialStartSpriteCellID: number;
  15515. /** @hidden */
  15516. _initialEndSpriteCellID: number;
  15517. /** @hidden */
  15518. _currentColorGradient: Nullable<ColorGradient>;
  15519. /** @hidden */
  15520. _currentColor1: Color4;
  15521. /** @hidden */
  15522. _currentColor2: Color4;
  15523. /** @hidden */
  15524. _currentSizeGradient: Nullable<FactorGradient>;
  15525. /** @hidden */
  15526. _currentSize1: number;
  15527. /** @hidden */
  15528. _currentSize2: number;
  15529. /** @hidden */
  15530. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15531. /** @hidden */
  15532. _currentAngularSpeed1: number;
  15533. /** @hidden */
  15534. _currentAngularSpeed2: number;
  15535. /** @hidden */
  15536. _currentVelocityGradient: Nullable<FactorGradient>;
  15537. /** @hidden */
  15538. _currentVelocity1: number;
  15539. /** @hidden */
  15540. _currentVelocity2: number;
  15541. /** @hidden */
  15542. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15543. /** @hidden */
  15544. _currentLimitVelocity1: number;
  15545. /** @hidden */
  15546. _currentLimitVelocity2: number;
  15547. /** @hidden */
  15548. _currentDragGradient: Nullable<FactorGradient>;
  15549. /** @hidden */
  15550. _currentDrag1: number;
  15551. /** @hidden */
  15552. _currentDrag2: number;
  15553. /** @hidden */
  15554. _randomNoiseCoordinates1: Vector3;
  15555. /** @hidden */
  15556. _randomNoiseCoordinates2: Vector3;
  15557. /**
  15558. * Creates a new instance Particle
  15559. * @param particleSystem the particle system the particle belongs to
  15560. */
  15561. constructor(
  15562. /**
  15563. * The particle system the particle belongs to.
  15564. */
  15565. particleSystem: ParticleSystem);
  15566. private updateCellInfoFromSystem;
  15567. /**
  15568. * Defines how the sprite cell index is updated for the particle
  15569. */
  15570. updateCellIndex(): void;
  15571. /** @hidden */
  15572. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15573. /** @hidden */
  15574. _inheritParticleInfoToSubEmitters(): void;
  15575. /** @hidden */
  15576. _reset(): void;
  15577. /**
  15578. * Copy the properties of particle to another one.
  15579. * @param other the particle to copy the information to.
  15580. */
  15581. copyTo(other: Particle): void;
  15582. }
  15583. }
  15584. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15585. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15586. import { Effect } from "babylonjs/Materials/effect";
  15587. import { Particle } from "babylonjs/Particles/particle";
  15588. /**
  15589. * Particle emitter represents a volume emitting particles.
  15590. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15591. */
  15592. export interface IParticleEmitterType {
  15593. /**
  15594. * Called by the particle System when the direction is computed for the created particle.
  15595. * @param worldMatrix is the world matrix of the particle system
  15596. * @param directionToUpdate is the direction vector to update with the result
  15597. * @param particle is the particle we are computed the direction for
  15598. */
  15599. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15600. /**
  15601. * Called by the particle System when the position is computed for the created particle.
  15602. * @param worldMatrix is the world matrix of the particle system
  15603. * @param positionToUpdate is the position vector to update with the result
  15604. * @param particle is the particle we are computed the position for
  15605. */
  15606. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15607. /**
  15608. * Clones the current emitter and returns a copy of it
  15609. * @returns the new emitter
  15610. */
  15611. clone(): IParticleEmitterType;
  15612. /**
  15613. * Called by the GPUParticleSystem to setup the update shader
  15614. * @param effect defines the update shader
  15615. */
  15616. applyToShader(effect: Effect): void;
  15617. /**
  15618. * Returns a string to use to update the GPU particles update shader
  15619. * @returns the effect defines string
  15620. */
  15621. getEffectDefines(): string;
  15622. /**
  15623. * Returns a string representing the class name
  15624. * @returns a string containing the class name
  15625. */
  15626. getClassName(): string;
  15627. /**
  15628. * Serializes the particle system to a JSON object.
  15629. * @returns the JSON object
  15630. */
  15631. serialize(): any;
  15632. /**
  15633. * Parse properties from a JSON object
  15634. * @param serializationObject defines the JSON object
  15635. */
  15636. parse(serializationObject: any): void;
  15637. }
  15638. }
  15639. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15640. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15641. import { Effect } from "babylonjs/Materials/effect";
  15642. import { Particle } from "babylonjs/Particles/particle";
  15643. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15644. /**
  15645. * Particle emitter emitting particles from the inside of a box.
  15646. * It emits the particles randomly between 2 given directions.
  15647. */
  15648. export class BoxParticleEmitter implements IParticleEmitterType {
  15649. /**
  15650. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15651. */
  15652. direction1: Vector3;
  15653. /**
  15654. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15655. */
  15656. direction2: Vector3;
  15657. /**
  15658. * 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.
  15659. */
  15660. minEmitBox: Vector3;
  15661. /**
  15662. * 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.
  15663. */
  15664. maxEmitBox: Vector3;
  15665. /**
  15666. * Creates a new instance BoxParticleEmitter
  15667. */
  15668. constructor();
  15669. /**
  15670. * Called by the particle System when the direction is computed for the created particle.
  15671. * @param worldMatrix is the world matrix of the particle system
  15672. * @param directionToUpdate is the direction vector to update with the result
  15673. * @param particle is the particle we are computed the direction for
  15674. */
  15675. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15676. /**
  15677. * Called by the particle System when the position is computed for the created particle.
  15678. * @param worldMatrix is the world matrix of the particle system
  15679. * @param positionToUpdate is the position vector to update with the result
  15680. * @param particle is the particle we are computed the position for
  15681. */
  15682. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15683. /**
  15684. * Clones the current emitter and returns a copy of it
  15685. * @returns the new emitter
  15686. */
  15687. clone(): BoxParticleEmitter;
  15688. /**
  15689. * Called by the GPUParticleSystem to setup the update shader
  15690. * @param effect defines the update shader
  15691. */
  15692. applyToShader(effect: Effect): void;
  15693. /**
  15694. * Returns a string to use to update the GPU particles update shader
  15695. * @returns a string containng the defines string
  15696. */
  15697. getEffectDefines(): string;
  15698. /**
  15699. * Returns the string "BoxParticleEmitter"
  15700. * @returns a string containing the class name
  15701. */
  15702. getClassName(): string;
  15703. /**
  15704. * Serializes the particle system to a JSON object.
  15705. * @returns the JSON object
  15706. */
  15707. serialize(): any;
  15708. /**
  15709. * Parse properties from a JSON object
  15710. * @param serializationObject defines the JSON object
  15711. */
  15712. parse(serializationObject: any): void;
  15713. }
  15714. }
  15715. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15716. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15717. import { Effect } from "babylonjs/Materials/effect";
  15718. import { Particle } from "babylonjs/Particles/particle";
  15719. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15720. /**
  15721. * Particle emitter emitting particles from the inside of a cone.
  15722. * It emits the particles alongside the cone volume from the base to the particle.
  15723. * The emission direction might be randomized.
  15724. */
  15725. export class ConeParticleEmitter implements IParticleEmitterType {
  15726. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15727. directionRandomizer: number;
  15728. private _radius;
  15729. private _angle;
  15730. private _height;
  15731. /**
  15732. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15733. */
  15734. radiusRange: number;
  15735. /**
  15736. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15737. */
  15738. heightRange: number;
  15739. /**
  15740. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15741. */
  15742. emitFromSpawnPointOnly: boolean;
  15743. /**
  15744. * Gets or sets the radius of the emission cone
  15745. */
  15746. radius: number;
  15747. /**
  15748. * Gets or sets the angle of the emission cone
  15749. */
  15750. angle: number;
  15751. private _buildHeight;
  15752. /**
  15753. * Creates a new instance ConeParticleEmitter
  15754. * @param radius the radius of the emission cone (1 by default)
  15755. * @param angle the cone base angle (PI by default)
  15756. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15757. */
  15758. constructor(radius?: number, angle?: number,
  15759. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15760. directionRandomizer?: number);
  15761. /**
  15762. * Called by the particle System when the direction is computed for the created particle.
  15763. * @param worldMatrix is the world matrix of the particle system
  15764. * @param directionToUpdate is the direction vector to update with the result
  15765. * @param particle is the particle we are computed the direction for
  15766. */
  15767. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15768. /**
  15769. * Called by the particle System when the position is computed for the created particle.
  15770. * @param worldMatrix is the world matrix of the particle system
  15771. * @param positionToUpdate is the position vector to update with the result
  15772. * @param particle is the particle we are computed the position for
  15773. */
  15774. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15775. /**
  15776. * Clones the current emitter and returns a copy of it
  15777. * @returns the new emitter
  15778. */
  15779. clone(): ConeParticleEmitter;
  15780. /**
  15781. * Called by the GPUParticleSystem to setup the update shader
  15782. * @param effect defines the update shader
  15783. */
  15784. applyToShader(effect: Effect): void;
  15785. /**
  15786. * Returns a string to use to update the GPU particles update shader
  15787. * @returns a string containng the defines string
  15788. */
  15789. getEffectDefines(): string;
  15790. /**
  15791. * Returns the string "ConeParticleEmitter"
  15792. * @returns a string containing the class name
  15793. */
  15794. getClassName(): string;
  15795. /**
  15796. * Serializes the particle system to a JSON object.
  15797. * @returns the JSON object
  15798. */
  15799. serialize(): any;
  15800. /**
  15801. * Parse properties from a JSON object
  15802. * @param serializationObject defines the JSON object
  15803. */
  15804. parse(serializationObject: any): void;
  15805. }
  15806. }
  15807. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15808. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15809. import { Effect } from "babylonjs/Materials/effect";
  15810. import { Particle } from "babylonjs/Particles/particle";
  15811. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15812. /**
  15813. * Particle emitter emitting particles from the inside of a cylinder.
  15814. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15815. */
  15816. export class CylinderParticleEmitter implements IParticleEmitterType {
  15817. /**
  15818. * The radius of the emission cylinder.
  15819. */
  15820. radius: number;
  15821. /**
  15822. * The height of the emission cylinder.
  15823. */
  15824. height: number;
  15825. /**
  15826. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15827. */
  15828. radiusRange: number;
  15829. /**
  15830. * How much to randomize the particle direction [0-1].
  15831. */
  15832. directionRandomizer: number;
  15833. /**
  15834. * Creates a new instance CylinderParticleEmitter
  15835. * @param radius the radius of the emission cylinder (1 by default)
  15836. * @param height the height of the emission cylinder (1 by default)
  15837. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15838. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15839. */
  15840. constructor(
  15841. /**
  15842. * The radius of the emission cylinder.
  15843. */
  15844. radius?: number,
  15845. /**
  15846. * The height of the emission cylinder.
  15847. */
  15848. height?: number,
  15849. /**
  15850. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15851. */
  15852. radiusRange?: number,
  15853. /**
  15854. * How much to randomize the particle direction [0-1].
  15855. */
  15856. directionRandomizer?: number);
  15857. /**
  15858. * Called by the particle System when the direction is computed for the created particle.
  15859. * @param worldMatrix is the world matrix of the particle system
  15860. * @param directionToUpdate is the direction vector to update with the result
  15861. * @param particle is the particle we are computed the direction for
  15862. */
  15863. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15864. /**
  15865. * Called by the particle System when the position is computed for the created particle.
  15866. * @param worldMatrix is the world matrix of the particle system
  15867. * @param positionToUpdate is the position vector to update with the result
  15868. * @param particle is the particle we are computed the position for
  15869. */
  15870. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15871. /**
  15872. * Clones the current emitter and returns a copy of it
  15873. * @returns the new emitter
  15874. */
  15875. clone(): CylinderParticleEmitter;
  15876. /**
  15877. * Called by the GPUParticleSystem to setup the update shader
  15878. * @param effect defines the update shader
  15879. */
  15880. applyToShader(effect: Effect): void;
  15881. /**
  15882. * Returns a string to use to update the GPU particles update shader
  15883. * @returns a string containng the defines string
  15884. */
  15885. getEffectDefines(): string;
  15886. /**
  15887. * Returns the string "CylinderParticleEmitter"
  15888. * @returns a string containing the class name
  15889. */
  15890. getClassName(): string;
  15891. /**
  15892. * Serializes the particle system to a JSON object.
  15893. * @returns the JSON object
  15894. */
  15895. serialize(): any;
  15896. /**
  15897. * Parse properties from a JSON object
  15898. * @param serializationObject defines the JSON object
  15899. */
  15900. parse(serializationObject: any): void;
  15901. }
  15902. /**
  15903. * Particle emitter emitting particles from the inside of a cylinder.
  15904. * It emits the particles randomly between two vectors.
  15905. */
  15906. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15907. /**
  15908. * The min limit of the emission direction.
  15909. */
  15910. direction1: Vector3;
  15911. /**
  15912. * The max limit of the emission direction.
  15913. */
  15914. direction2: Vector3;
  15915. /**
  15916. * Creates a new instance CylinderDirectedParticleEmitter
  15917. * @param radius the radius of the emission cylinder (1 by default)
  15918. * @param height the height of the emission cylinder (1 by default)
  15919. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15920. * @param direction1 the min limit of the emission direction (up vector by default)
  15921. * @param direction2 the max limit of the emission direction (up vector by default)
  15922. */
  15923. constructor(radius?: number, height?: number, radiusRange?: number,
  15924. /**
  15925. * The min limit of the emission direction.
  15926. */
  15927. direction1?: Vector3,
  15928. /**
  15929. * The max limit of the emission direction.
  15930. */
  15931. direction2?: Vector3);
  15932. /**
  15933. * Called by the particle System when the direction is computed for the created particle.
  15934. * @param worldMatrix is the world matrix of the particle system
  15935. * @param directionToUpdate is the direction vector to update with the result
  15936. * @param particle is the particle we are computed the direction for
  15937. */
  15938. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15939. /**
  15940. * Clones the current emitter and returns a copy of it
  15941. * @returns the new emitter
  15942. */
  15943. clone(): CylinderDirectedParticleEmitter;
  15944. /**
  15945. * Called by the GPUParticleSystem to setup the update shader
  15946. * @param effect defines the update shader
  15947. */
  15948. applyToShader(effect: Effect): void;
  15949. /**
  15950. * Returns a string to use to update the GPU particles update shader
  15951. * @returns a string containng the defines string
  15952. */
  15953. getEffectDefines(): string;
  15954. /**
  15955. * Returns the string "CylinderDirectedParticleEmitter"
  15956. * @returns a string containing the class name
  15957. */
  15958. getClassName(): string;
  15959. /**
  15960. * Serializes the particle system to a JSON object.
  15961. * @returns the JSON object
  15962. */
  15963. serialize(): any;
  15964. /**
  15965. * Parse properties from a JSON object
  15966. * @param serializationObject defines the JSON object
  15967. */
  15968. parse(serializationObject: any): void;
  15969. }
  15970. }
  15971. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15972. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15973. import { Effect } from "babylonjs/Materials/effect";
  15974. import { Particle } from "babylonjs/Particles/particle";
  15975. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15976. /**
  15977. * Particle emitter emitting particles from the inside of a hemisphere.
  15978. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15979. */
  15980. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15981. /**
  15982. * The radius of the emission hemisphere.
  15983. */
  15984. radius: number;
  15985. /**
  15986. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15987. */
  15988. radiusRange: number;
  15989. /**
  15990. * How much to randomize the particle direction [0-1].
  15991. */
  15992. directionRandomizer: number;
  15993. /**
  15994. * Creates a new instance HemisphericParticleEmitter
  15995. * @param radius the radius of the emission hemisphere (1 by default)
  15996. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15997. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15998. */
  15999. constructor(
  16000. /**
  16001. * The radius of the emission hemisphere.
  16002. */
  16003. radius?: number,
  16004. /**
  16005. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16006. */
  16007. radiusRange?: number,
  16008. /**
  16009. * How much to randomize the particle direction [0-1].
  16010. */
  16011. directionRandomizer?: number);
  16012. /**
  16013. * Called by the particle System when the direction is computed for the created particle.
  16014. * @param worldMatrix is the world matrix of the particle system
  16015. * @param directionToUpdate is the direction vector to update with the result
  16016. * @param particle is the particle we are computed the direction for
  16017. */
  16018. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16019. /**
  16020. * Called by the particle System when the position is computed for the created particle.
  16021. * @param worldMatrix is the world matrix of the particle system
  16022. * @param positionToUpdate is the position vector to update with the result
  16023. * @param particle is the particle we are computed the position for
  16024. */
  16025. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16026. /**
  16027. * Clones the current emitter and returns a copy of it
  16028. * @returns the new emitter
  16029. */
  16030. clone(): HemisphericParticleEmitter;
  16031. /**
  16032. * Called by the GPUParticleSystem to setup the update shader
  16033. * @param effect defines the update shader
  16034. */
  16035. applyToShader(effect: Effect): void;
  16036. /**
  16037. * Returns a string to use to update the GPU particles update shader
  16038. * @returns a string containng the defines string
  16039. */
  16040. getEffectDefines(): string;
  16041. /**
  16042. * Returns the string "HemisphericParticleEmitter"
  16043. * @returns a string containing the class name
  16044. */
  16045. getClassName(): string;
  16046. /**
  16047. * Serializes the particle system to a JSON object.
  16048. * @returns the JSON object
  16049. */
  16050. serialize(): any;
  16051. /**
  16052. * Parse properties from a JSON object
  16053. * @param serializationObject defines the JSON object
  16054. */
  16055. parse(serializationObject: any): void;
  16056. }
  16057. }
  16058. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16059. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16060. import { Effect } from "babylonjs/Materials/effect";
  16061. import { Particle } from "babylonjs/Particles/particle";
  16062. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16063. /**
  16064. * Particle emitter emitting particles from a point.
  16065. * It emits the particles randomly between 2 given directions.
  16066. */
  16067. export class PointParticleEmitter implements IParticleEmitterType {
  16068. /**
  16069. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16070. */
  16071. direction1: Vector3;
  16072. /**
  16073. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16074. */
  16075. direction2: Vector3;
  16076. /**
  16077. * Creates a new instance PointParticleEmitter
  16078. */
  16079. constructor();
  16080. /**
  16081. * Called by the particle System when the direction is computed for the created particle.
  16082. * @param worldMatrix is the world matrix of the particle system
  16083. * @param directionToUpdate is the direction vector to update with the result
  16084. * @param particle is the particle we are computed the direction for
  16085. */
  16086. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16087. /**
  16088. * Called by the particle System when the position is computed for the created particle.
  16089. * @param worldMatrix is the world matrix of the particle system
  16090. * @param positionToUpdate is the position vector to update with the result
  16091. * @param particle is the particle we are computed the position for
  16092. */
  16093. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16094. /**
  16095. * Clones the current emitter and returns a copy of it
  16096. * @returns the new emitter
  16097. */
  16098. clone(): PointParticleEmitter;
  16099. /**
  16100. * Called by the GPUParticleSystem to setup the update shader
  16101. * @param effect defines the update shader
  16102. */
  16103. applyToShader(effect: Effect): void;
  16104. /**
  16105. * Returns a string to use to update the GPU particles update shader
  16106. * @returns a string containng the defines string
  16107. */
  16108. getEffectDefines(): string;
  16109. /**
  16110. * Returns the string "PointParticleEmitter"
  16111. * @returns a string containing the class name
  16112. */
  16113. getClassName(): string;
  16114. /**
  16115. * Serializes the particle system to a JSON object.
  16116. * @returns the JSON object
  16117. */
  16118. serialize(): any;
  16119. /**
  16120. * Parse properties from a JSON object
  16121. * @param serializationObject defines the JSON object
  16122. */
  16123. parse(serializationObject: any): void;
  16124. }
  16125. }
  16126. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16127. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16128. import { Effect } from "babylonjs/Materials/effect";
  16129. import { Particle } from "babylonjs/Particles/particle";
  16130. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16131. /**
  16132. * Particle emitter emitting particles from the inside of a sphere.
  16133. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16134. */
  16135. export class SphereParticleEmitter implements IParticleEmitterType {
  16136. /**
  16137. * The radius of the emission sphere.
  16138. */
  16139. radius: number;
  16140. /**
  16141. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16142. */
  16143. radiusRange: number;
  16144. /**
  16145. * How much to randomize the particle direction [0-1].
  16146. */
  16147. directionRandomizer: number;
  16148. /**
  16149. * Creates a new instance SphereParticleEmitter
  16150. * @param radius the radius of the emission sphere (1 by default)
  16151. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16152. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16153. */
  16154. constructor(
  16155. /**
  16156. * The radius of the emission sphere.
  16157. */
  16158. radius?: number,
  16159. /**
  16160. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16161. */
  16162. radiusRange?: number,
  16163. /**
  16164. * How much to randomize the particle direction [0-1].
  16165. */
  16166. directionRandomizer?: number);
  16167. /**
  16168. * Called by the particle System when the direction is computed for the created particle.
  16169. * @param worldMatrix is the world matrix of the particle system
  16170. * @param directionToUpdate is the direction vector to update with the result
  16171. * @param particle is the particle we are computed the direction for
  16172. */
  16173. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16174. /**
  16175. * Called by the particle System when the position is computed for the created particle.
  16176. * @param worldMatrix is the world matrix of the particle system
  16177. * @param positionToUpdate is the position vector to update with the result
  16178. * @param particle is the particle we are computed the position for
  16179. */
  16180. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16181. /**
  16182. * Clones the current emitter and returns a copy of it
  16183. * @returns the new emitter
  16184. */
  16185. clone(): SphereParticleEmitter;
  16186. /**
  16187. * Called by the GPUParticleSystem to setup the update shader
  16188. * @param effect defines the update shader
  16189. */
  16190. applyToShader(effect: Effect): void;
  16191. /**
  16192. * Returns a string to use to update the GPU particles update shader
  16193. * @returns a string containng the defines string
  16194. */
  16195. getEffectDefines(): string;
  16196. /**
  16197. * Returns the string "SphereParticleEmitter"
  16198. * @returns a string containing the class name
  16199. */
  16200. getClassName(): string;
  16201. /**
  16202. * Serializes the particle system to a JSON object.
  16203. * @returns the JSON object
  16204. */
  16205. serialize(): any;
  16206. /**
  16207. * Parse properties from a JSON object
  16208. * @param serializationObject defines the JSON object
  16209. */
  16210. parse(serializationObject: any): void;
  16211. }
  16212. /**
  16213. * Particle emitter emitting particles from the inside of a sphere.
  16214. * It emits the particles randomly between two vectors.
  16215. */
  16216. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16217. /**
  16218. * The min limit of the emission direction.
  16219. */
  16220. direction1: Vector3;
  16221. /**
  16222. * The max limit of the emission direction.
  16223. */
  16224. direction2: Vector3;
  16225. /**
  16226. * Creates a new instance SphereDirectedParticleEmitter
  16227. * @param radius the radius of the emission sphere (1 by default)
  16228. * @param direction1 the min limit of the emission direction (up vector by default)
  16229. * @param direction2 the max limit of the emission direction (up vector by default)
  16230. */
  16231. constructor(radius?: number,
  16232. /**
  16233. * The min limit of the emission direction.
  16234. */
  16235. direction1?: Vector3,
  16236. /**
  16237. * The max limit of the emission direction.
  16238. */
  16239. direction2?: Vector3);
  16240. /**
  16241. * Called by the particle System when the direction is computed for the created particle.
  16242. * @param worldMatrix is the world matrix of the particle system
  16243. * @param directionToUpdate is the direction vector to update with the result
  16244. * @param particle is the particle we are computed the direction for
  16245. */
  16246. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16247. /**
  16248. * Clones the current emitter and returns a copy of it
  16249. * @returns the new emitter
  16250. */
  16251. clone(): SphereDirectedParticleEmitter;
  16252. /**
  16253. * Called by the GPUParticleSystem to setup the update shader
  16254. * @param effect defines the update shader
  16255. */
  16256. applyToShader(effect: Effect): void;
  16257. /**
  16258. * Returns a string to use to update the GPU particles update shader
  16259. * @returns a string containng the defines string
  16260. */
  16261. getEffectDefines(): string;
  16262. /**
  16263. * Returns the string "SphereDirectedParticleEmitter"
  16264. * @returns a string containing the class name
  16265. */
  16266. getClassName(): string;
  16267. /**
  16268. * Serializes the particle system to a JSON object.
  16269. * @returns the JSON object
  16270. */
  16271. serialize(): any;
  16272. /**
  16273. * Parse properties from a JSON object
  16274. * @param serializationObject defines the JSON object
  16275. */
  16276. parse(serializationObject: any): void;
  16277. }
  16278. }
  16279. declare module "babylonjs/Particles/EmitterTypes/index" {
  16280. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16281. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16282. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16283. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16284. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16285. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16286. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16287. }
  16288. declare module "babylonjs/Particles/IParticleSystem" {
  16289. import { Nullable } from "babylonjs/types";
  16290. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16292. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16293. import { Texture } from "babylonjs/Materials/Textures/texture";
  16294. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16295. import { Scene } from "babylonjs/scene";
  16296. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16297. import { Animation } from "babylonjs/Animations/animation";
  16298. /**
  16299. * Interface representing a particle system in Babylon.js.
  16300. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16301. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16302. */
  16303. export interface IParticleSystem {
  16304. /**
  16305. * List of animations used by the particle system.
  16306. */
  16307. animations: Animation[];
  16308. /**
  16309. * The id of the Particle system.
  16310. */
  16311. id: string;
  16312. /**
  16313. * The name of the Particle system.
  16314. */
  16315. name: string;
  16316. /**
  16317. * The emitter represents the Mesh or position we are attaching the particle system to.
  16318. */
  16319. emitter: Nullable<AbstractMesh | Vector3>;
  16320. /**
  16321. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16322. */
  16323. isBillboardBased: boolean;
  16324. /**
  16325. * The rendering group used by the Particle system to chose when to render.
  16326. */
  16327. renderingGroupId: number;
  16328. /**
  16329. * The layer mask we are rendering the particles through.
  16330. */
  16331. layerMask: number;
  16332. /**
  16333. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16334. */
  16335. updateSpeed: number;
  16336. /**
  16337. * The amount of time the particle system is running (depends of the overall update speed).
  16338. */
  16339. targetStopDuration: number;
  16340. /**
  16341. * The texture used to render each particle. (this can be a spritesheet)
  16342. */
  16343. particleTexture: Nullable<Texture>;
  16344. /**
  16345. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16346. */
  16347. blendMode: number;
  16348. /**
  16349. * Minimum life time of emitting particles.
  16350. */
  16351. minLifeTime: number;
  16352. /**
  16353. * Maximum life time of emitting particles.
  16354. */
  16355. maxLifeTime: number;
  16356. /**
  16357. * Minimum Size of emitting particles.
  16358. */
  16359. minSize: number;
  16360. /**
  16361. * Maximum Size of emitting particles.
  16362. */
  16363. maxSize: number;
  16364. /**
  16365. * Minimum scale of emitting particles on X axis.
  16366. */
  16367. minScaleX: number;
  16368. /**
  16369. * Maximum scale of emitting particles on X axis.
  16370. */
  16371. maxScaleX: number;
  16372. /**
  16373. * Minimum scale of emitting particles on Y axis.
  16374. */
  16375. minScaleY: number;
  16376. /**
  16377. * Maximum scale of emitting particles on Y axis.
  16378. */
  16379. maxScaleY: number;
  16380. /**
  16381. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16382. */
  16383. color1: Color4;
  16384. /**
  16385. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16386. */
  16387. color2: Color4;
  16388. /**
  16389. * Color the particle will have at the end of its lifetime.
  16390. */
  16391. colorDead: Color4;
  16392. /**
  16393. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16394. */
  16395. emitRate: number;
  16396. /**
  16397. * You can use gravity if you want to give an orientation to your particles.
  16398. */
  16399. gravity: Vector3;
  16400. /**
  16401. * Minimum power of emitting particles.
  16402. */
  16403. minEmitPower: number;
  16404. /**
  16405. * Maximum power of emitting particles.
  16406. */
  16407. maxEmitPower: number;
  16408. /**
  16409. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16410. */
  16411. minAngularSpeed: number;
  16412. /**
  16413. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16414. */
  16415. maxAngularSpeed: number;
  16416. /**
  16417. * Gets or sets the minimal initial rotation in radians.
  16418. */
  16419. minInitialRotation: number;
  16420. /**
  16421. * Gets or sets the maximal initial rotation in radians.
  16422. */
  16423. maxInitialRotation: number;
  16424. /**
  16425. * The particle emitter type defines the emitter used by the particle system.
  16426. * It can be for example box, sphere, or cone...
  16427. */
  16428. particleEmitterType: Nullable<IParticleEmitterType>;
  16429. /**
  16430. * Defines the delay in milliseconds before starting the system (0 by default)
  16431. */
  16432. startDelay: number;
  16433. /**
  16434. * 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
  16435. */
  16436. preWarmCycles: number;
  16437. /**
  16438. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16439. */
  16440. preWarmStepOffset: number;
  16441. /**
  16442. * 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)
  16443. */
  16444. spriteCellChangeSpeed: number;
  16445. /**
  16446. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16447. */
  16448. startSpriteCellID: number;
  16449. /**
  16450. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16451. */
  16452. endSpriteCellID: number;
  16453. /**
  16454. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16455. */
  16456. spriteCellWidth: number;
  16457. /**
  16458. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16459. */
  16460. spriteCellHeight: number;
  16461. /**
  16462. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16463. */
  16464. spriteRandomStartCell: boolean;
  16465. /**
  16466. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16467. */
  16468. isAnimationSheetEnabled: boolean;
  16469. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16470. translationPivot: Vector2;
  16471. /**
  16472. * Gets or sets a texture used to add random noise to particle positions
  16473. */
  16474. noiseTexture: Nullable<BaseTexture>;
  16475. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16476. noiseStrength: Vector3;
  16477. /**
  16478. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16479. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16480. */
  16481. billboardMode: number;
  16482. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16483. limitVelocityDamping: number;
  16484. /**
  16485. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16486. */
  16487. beginAnimationOnStart: boolean;
  16488. /**
  16489. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16490. */
  16491. beginAnimationFrom: number;
  16492. /**
  16493. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16494. */
  16495. beginAnimationTo: number;
  16496. /**
  16497. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16498. */
  16499. beginAnimationLoop: boolean;
  16500. /**
  16501. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16502. */
  16503. disposeOnStop: boolean;
  16504. /**
  16505. * Gets the maximum number of particles active at the same time.
  16506. * @returns The max number of active particles.
  16507. */
  16508. getCapacity(): number;
  16509. /**
  16510. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16511. * @returns True if it has been started, otherwise false.
  16512. */
  16513. isStarted(): boolean;
  16514. /**
  16515. * Animates the particle system for this frame.
  16516. */
  16517. animate(): void;
  16518. /**
  16519. * Renders the particle system in its current state.
  16520. * @returns the current number of particles
  16521. */
  16522. render(): number;
  16523. /**
  16524. * Dispose the particle system and frees its associated resources.
  16525. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16526. */
  16527. dispose(disposeTexture?: boolean): void;
  16528. /**
  16529. * Clones the particle system.
  16530. * @param name The name of the cloned object
  16531. * @param newEmitter The new emitter to use
  16532. * @returns the cloned particle system
  16533. */
  16534. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16535. /**
  16536. * Serializes the particle system to a JSON object.
  16537. * @returns the JSON object
  16538. */
  16539. serialize(): any;
  16540. /**
  16541. * Rebuild the particle system
  16542. */
  16543. rebuild(): void;
  16544. /**
  16545. * Starts the particle system and begins to emit
  16546. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16547. */
  16548. start(delay?: number): void;
  16549. /**
  16550. * Stops the particle system.
  16551. */
  16552. stop(): void;
  16553. /**
  16554. * Remove all active particles
  16555. */
  16556. reset(): void;
  16557. /**
  16558. * Is this system ready to be used/rendered
  16559. * @return true if the system is ready
  16560. */
  16561. isReady(): boolean;
  16562. /**
  16563. * Adds a new color gradient
  16564. * @param gradient defines the gradient to use (between 0 and 1)
  16565. * @param color1 defines the color to affect to the specified gradient
  16566. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16567. * @returns the current particle system
  16568. */
  16569. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16570. /**
  16571. * Remove a specific color gradient
  16572. * @param gradient defines the gradient to remove
  16573. * @returns the current particle system
  16574. */
  16575. removeColorGradient(gradient: number): IParticleSystem;
  16576. /**
  16577. * Adds a new size gradient
  16578. * @param gradient defines the gradient to use (between 0 and 1)
  16579. * @param factor defines the size factor to affect to the specified gradient
  16580. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16581. * @returns the current particle system
  16582. */
  16583. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16584. /**
  16585. * Remove a specific size gradient
  16586. * @param gradient defines the gradient to remove
  16587. * @returns the current particle system
  16588. */
  16589. removeSizeGradient(gradient: number): IParticleSystem;
  16590. /**
  16591. * Gets the current list of color gradients.
  16592. * You must use addColorGradient and removeColorGradient to udpate this list
  16593. * @returns the list of color gradients
  16594. */
  16595. getColorGradients(): Nullable<Array<ColorGradient>>;
  16596. /**
  16597. * Gets the current list of size gradients.
  16598. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16599. * @returns the list of size gradients
  16600. */
  16601. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16602. /**
  16603. * Gets the current list of angular speed gradients.
  16604. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16605. * @returns the list of angular speed gradients
  16606. */
  16607. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16608. /**
  16609. * Adds a new angular speed gradient
  16610. * @param gradient defines the gradient to use (between 0 and 1)
  16611. * @param factor defines the angular speed to affect to the specified gradient
  16612. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16613. * @returns the current particle system
  16614. */
  16615. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16616. /**
  16617. * Remove a specific angular speed gradient
  16618. * @param gradient defines the gradient to remove
  16619. * @returns the current particle system
  16620. */
  16621. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16622. /**
  16623. * Gets the current list of velocity gradients.
  16624. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16625. * @returns the list of velocity gradients
  16626. */
  16627. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16628. /**
  16629. * Adds a new velocity gradient
  16630. * @param gradient defines the gradient to use (between 0 and 1)
  16631. * @param factor defines the velocity to affect to the specified gradient
  16632. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16633. * @returns the current particle system
  16634. */
  16635. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16636. /**
  16637. * Remove a specific velocity gradient
  16638. * @param gradient defines the gradient to remove
  16639. * @returns the current particle system
  16640. */
  16641. removeVelocityGradient(gradient: number): IParticleSystem;
  16642. /**
  16643. * Gets the current list of limit velocity gradients.
  16644. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16645. * @returns the list of limit velocity gradients
  16646. */
  16647. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16648. /**
  16649. * Adds a new limit velocity gradient
  16650. * @param gradient defines the gradient to use (between 0 and 1)
  16651. * @param factor defines the limit velocity to affect to the specified gradient
  16652. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16653. * @returns the current particle system
  16654. */
  16655. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16656. /**
  16657. * Remove a specific limit velocity gradient
  16658. * @param gradient defines the gradient to remove
  16659. * @returns the current particle system
  16660. */
  16661. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16662. /**
  16663. * Adds a new drag gradient
  16664. * @param gradient defines the gradient to use (between 0 and 1)
  16665. * @param factor defines the drag to affect to the specified gradient
  16666. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16667. * @returns the current particle system
  16668. */
  16669. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16670. /**
  16671. * Remove a specific drag gradient
  16672. * @param gradient defines the gradient to remove
  16673. * @returns the current particle system
  16674. */
  16675. removeDragGradient(gradient: number): IParticleSystem;
  16676. /**
  16677. * Gets the current list of drag gradients.
  16678. * You must use addDragGradient and removeDragGradient to udpate this list
  16679. * @returns the list of drag gradients
  16680. */
  16681. getDragGradients(): Nullable<Array<FactorGradient>>;
  16682. /**
  16683. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16684. * @param gradient defines the gradient to use (between 0 and 1)
  16685. * @param factor defines the emit rate to affect to the specified gradient
  16686. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16687. * @returns the current particle system
  16688. */
  16689. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16690. /**
  16691. * Remove a specific emit rate gradient
  16692. * @param gradient defines the gradient to remove
  16693. * @returns the current particle system
  16694. */
  16695. removeEmitRateGradient(gradient: number): IParticleSystem;
  16696. /**
  16697. * Gets the current list of emit rate gradients.
  16698. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16699. * @returns the list of emit rate gradients
  16700. */
  16701. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16702. /**
  16703. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16704. * @param gradient defines the gradient to use (between 0 and 1)
  16705. * @param factor defines the start size to affect to the specified gradient
  16706. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16707. * @returns the current particle system
  16708. */
  16709. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16710. /**
  16711. * Remove a specific start size gradient
  16712. * @param gradient defines the gradient to remove
  16713. * @returns the current particle system
  16714. */
  16715. removeStartSizeGradient(gradient: number): IParticleSystem;
  16716. /**
  16717. * Gets the current list of start size gradients.
  16718. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16719. * @returns the list of start size gradients
  16720. */
  16721. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16722. /**
  16723. * Adds a new life time gradient
  16724. * @param gradient defines the gradient to use (between 0 and 1)
  16725. * @param factor defines the life time factor to affect to the specified gradient
  16726. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16727. * @returns the current particle system
  16728. */
  16729. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16730. /**
  16731. * Remove a specific life time gradient
  16732. * @param gradient defines the gradient to remove
  16733. * @returns the current particle system
  16734. */
  16735. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16736. /**
  16737. * Gets the current list of life time gradients.
  16738. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16739. * @returns the list of life time gradients
  16740. */
  16741. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16742. /**
  16743. * Gets the current list of color gradients.
  16744. * You must use addColorGradient and removeColorGradient to udpate this list
  16745. * @returns the list of color gradients
  16746. */
  16747. getColorGradients(): Nullable<Array<ColorGradient>>;
  16748. /**
  16749. * Adds a new ramp gradient used to remap particle colors
  16750. * @param gradient defines the gradient to use (between 0 and 1)
  16751. * @param color defines the color to affect to the specified gradient
  16752. * @returns the current particle system
  16753. */
  16754. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16755. /**
  16756. * Gets the current list of ramp gradients.
  16757. * You must use addRampGradient and removeRampGradient to udpate this list
  16758. * @returns the list of ramp gradients
  16759. */
  16760. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16761. /** Gets or sets a boolean indicating that ramp gradients must be used
  16762. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16763. */
  16764. useRampGradients: boolean;
  16765. /**
  16766. * Adds a new color remap gradient
  16767. * @param gradient defines the gradient to use (between 0 and 1)
  16768. * @param min defines the color remap minimal range
  16769. * @param max defines the color remap maximal range
  16770. * @returns the current particle system
  16771. */
  16772. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16773. /**
  16774. * Gets the current list of color remap gradients.
  16775. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16776. * @returns the list of color remap gradients
  16777. */
  16778. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16779. /**
  16780. * Adds a new alpha remap gradient
  16781. * @param gradient defines the gradient to use (between 0 and 1)
  16782. * @param min defines the alpha remap minimal range
  16783. * @param max defines the alpha remap maximal range
  16784. * @returns the current particle system
  16785. */
  16786. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16787. /**
  16788. * Gets the current list of alpha remap gradients.
  16789. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16790. * @returns the list of alpha remap gradients
  16791. */
  16792. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16793. /**
  16794. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16795. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16796. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16797. * @returns the emitter
  16798. */
  16799. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16800. /**
  16801. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16802. * @param radius The radius of the hemisphere to emit from
  16803. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16804. * @returns the emitter
  16805. */
  16806. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16807. /**
  16808. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16809. * @param radius The radius of the sphere to emit from
  16810. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16811. * @returns the emitter
  16812. */
  16813. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16814. /**
  16815. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16816. * @param radius The radius of the sphere to emit from
  16817. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16818. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16819. * @returns the emitter
  16820. */
  16821. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16822. /**
  16823. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16824. * @param radius The radius of the emission cylinder
  16825. * @param height The height of the emission cylinder
  16826. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16827. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16828. * @returns the emitter
  16829. */
  16830. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16831. /**
  16832. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16833. * @param radius The radius of the cylinder to emit from
  16834. * @param height The height of the emission cylinder
  16835. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16836. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16837. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16838. * @returns the emitter
  16839. */
  16840. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16841. /**
  16842. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16843. * @param radius The radius of the cone to emit from
  16844. * @param angle The base angle of the cone
  16845. * @returns the emitter
  16846. */
  16847. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16848. /**
  16849. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16850. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16851. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16852. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16853. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16854. * @returns the emitter
  16855. */
  16856. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16857. /**
  16858. * Get hosting scene
  16859. * @returns the scene
  16860. */
  16861. getScene(): Scene;
  16862. }
  16863. }
  16864. declare module "babylonjs/Meshes/instancedMesh" {
  16865. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16866. import { Vector3 } from "babylonjs/Maths/math";
  16867. import { Camera } from "babylonjs/Cameras/camera";
  16868. import { Node } from "babylonjs/node";
  16869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16870. import { Mesh } from "babylonjs/Meshes/mesh";
  16871. import { Material } from "babylonjs/Materials/material";
  16872. import { Skeleton } from "babylonjs/Bones/skeleton";
  16873. /**
  16874. * Creates an instance based on a source mesh.
  16875. */
  16876. export class InstancedMesh extends AbstractMesh {
  16877. private _sourceMesh;
  16878. private _currentLOD;
  16879. /** @hidden */
  16880. _indexInSourceMeshInstanceArray: number;
  16881. constructor(name: string, source: Mesh);
  16882. /**
  16883. * Returns the string "InstancedMesh".
  16884. */
  16885. getClassName(): string;
  16886. /**
  16887. * If the source mesh receives shadows
  16888. */
  16889. readonly receiveShadows: boolean;
  16890. /**
  16891. * The material of the source mesh
  16892. */
  16893. readonly material: Nullable<Material>;
  16894. /**
  16895. * Visibility of the source mesh
  16896. */
  16897. readonly visibility: number;
  16898. /**
  16899. * Skeleton of the source mesh
  16900. */
  16901. readonly skeleton: Nullable<Skeleton>;
  16902. /**
  16903. * Rendering ground id of the source mesh
  16904. */
  16905. renderingGroupId: number;
  16906. /**
  16907. * Returns the total number of vertices (integer).
  16908. */
  16909. getTotalVertices(): number;
  16910. /**
  16911. * Returns a positive integer : the total number of indices in this mesh geometry.
  16912. * @returns the numner of indices or zero if the mesh has no geometry.
  16913. */
  16914. getTotalIndices(): number;
  16915. /**
  16916. * The source mesh of the instance
  16917. */
  16918. readonly sourceMesh: Mesh;
  16919. /**
  16920. * Is this node ready to be used/rendered
  16921. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16922. * @return {boolean} is it ready
  16923. */
  16924. isReady(completeCheck?: boolean): boolean;
  16925. /**
  16926. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16927. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16928. * @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.
  16929. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16930. */
  16931. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16932. /**
  16933. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16934. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16935. * The `data` are either a numeric array either a Float32Array.
  16936. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16937. * 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).
  16938. * Note that a new underlying VertexBuffer object is created each call.
  16939. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16940. *
  16941. * Possible `kind` values :
  16942. * - VertexBuffer.PositionKind
  16943. * - VertexBuffer.UVKind
  16944. * - VertexBuffer.UV2Kind
  16945. * - VertexBuffer.UV3Kind
  16946. * - VertexBuffer.UV4Kind
  16947. * - VertexBuffer.UV5Kind
  16948. * - VertexBuffer.UV6Kind
  16949. * - VertexBuffer.ColorKind
  16950. * - VertexBuffer.MatricesIndicesKind
  16951. * - VertexBuffer.MatricesIndicesExtraKind
  16952. * - VertexBuffer.MatricesWeightsKind
  16953. * - VertexBuffer.MatricesWeightsExtraKind
  16954. *
  16955. * Returns the Mesh.
  16956. */
  16957. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16958. /**
  16959. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16960. * If the mesh has no geometry, it is simply returned as it is.
  16961. * The `data` are either a numeric array either a Float32Array.
  16962. * No new underlying VertexBuffer object is created.
  16963. * 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.
  16964. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16965. *
  16966. * Possible `kind` values :
  16967. * - VertexBuffer.PositionKind
  16968. * - VertexBuffer.UVKind
  16969. * - VertexBuffer.UV2Kind
  16970. * - VertexBuffer.UV3Kind
  16971. * - VertexBuffer.UV4Kind
  16972. * - VertexBuffer.UV5Kind
  16973. * - VertexBuffer.UV6Kind
  16974. * - VertexBuffer.ColorKind
  16975. * - VertexBuffer.MatricesIndicesKind
  16976. * - VertexBuffer.MatricesIndicesExtraKind
  16977. * - VertexBuffer.MatricesWeightsKind
  16978. * - VertexBuffer.MatricesWeightsExtraKind
  16979. *
  16980. * Returns the Mesh.
  16981. */
  16982. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16983. /**
  16984. * Sets the mesh indices.
  16985. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16986. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16987. * This method creates a new index buffer each call.
  16988. * Returns the Mesh.
  16989. */
  16990. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16991. /**
  16992. * Boolean : True if the mesh owns the requested kind of data.
  16993. */
  16994. isVerticesDataPresent(kind: string): boolean;
  16995. /**
  16996. * Returns an array of indices (IndicesArray).
  16997. */
  16998. getIndices(): Nullable<IndicesArray>;
  16999. readonly _positions: Nullable<Vector3[]>;
  17000. /**
  17001. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17002. * This means the mesh underlying bounding box and sphere are recomputed.
  17003. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17004. * @returns the current mesh
  17005. */
  17006. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17007. /** @hidden */
  17008. _preActivate(): InstancedMesh;
  17009. /** @hidden */
  17010. _activate(renderId: number): InstancedMesh;
  17011. /**
  17012. * Returns the current associated LOD AbstractMesh.
  17013. */
  17014. getLOD(camera: Camera): AbstractMesh;
  17015. /** @hidden */
  17016. _syncSubMeshes(): InstancedMesh;
  17017. /** @hidden */
  17018. _generatePointsArray(): boolean;
  17019. /**
  17020. * Creates a new InstancedMesh from the current mesh.
  17021. * - name (string) : the cloned mesh name
  17022. * - newParent (optional Node) : the optional Node to parent the clone to.
  17023. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17024. *
  17025. * Returns the clone.
  17026. */
  17027. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17028. /**
  17029. * Disposes the InstancedMesh.
  17030. * Returns nothing.
  17031. */
  17032. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17033. }
  17034. }
  17035. declare module "babylonjs/Materials/shaderMaterial" {
  17036. import { Scene } from "babylonjs/scene";
  17037. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17039. import { Mesh } from "babylonjs/Meshes/mesh";
  17040. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17041. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17042. import { Texture } from "babylonjs/Materials/Textures/texture";
  17043. import { Material } from "babylonjs/Materials/material";
  17044. /**
  17045. * Defines the options associated with the creation of a shader material.
  17046. */
  17047. export interface IShaderMaterialOptions {
  17048. /**
  17049. * Does the material work in alpha blend mode
  17050. */
  17051. needAlphaBlending: boolean;
  17052. /**
  17053. * Does the material work in alpha test mode
  17054. */
  17055. needAlphaTesting: boolean;
  17056. /**
  17057. * The list of attribute names used in the shader
  17058. */
  17059. attributes: string[];
  17060. /**
  17061. * The list of unifrom names used in the shader
  17062. */
  17063. uniforms: string[];
  17064. /**
  17065. * The list of UBO names used in the shader
  17066. */
  17067. uniformBuffers: string[];
  17068. /**
  17069. * The list of sampler names used in the shader
  17070. */
  17071. samplers: string[];
  17072. /**
  17073. * The list of defines used in the shader
  17074. */
  17075. defines: string[];
  17076. }
  17077. /**
  17078. * 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.
  17079. *
  17080. * This returned material effects how the mesh will look based on the code in the shaders.
  17081. *
  17082. * @see http://doc.babylonjs.com/how_to/shader_material
  17083. */
  17084. export class ShaderMaterial extends Material {
  17085. private _shaderPath;
  17086. private _options;
  17087. private _textures;
  17088. private _textureArrays;
  17089. private _floats;
  17090. private _ints;
  17091. private _floatsArrays;
  17092. private _colors3;
  17093. private _colors3Arrays;
  17094. private _colors4;
  17095. private _vectors2;
  17096. private _vectors3;
  17097. private _vectors4;
  17098. private _matrices;
  17099. private _matrices3x3;
  17100. private _matrices2x2;
  17101. private _vectors2Arrays;
  17102. private _vectors3Arrays;
  17103. private _cachedWorldViewMatrix;
  17104. private _renderId;
  17105. /**
  17106. * Instantiate a new shader material.
  17107. * 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.
  17108. * This returned material effects how the mesh will look based on the code in the shaders.
  17109. * @see http://doc.babylonjs.com/how_to/shader_material
  17110. * @param name Define the name of the material in the scene
  17111. * @param scene Define the scene the material belongs to
  17112. * @param shaderPath Defines the route to the shader code in one of three ways:
  17113. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17114. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17115. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17116. * @param options Define the options used to create the shader
  17117. */
  17118. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17119. /**
  17120. * Gets the options used to compile the shader.
  17121. * They can be modified to trigger a new compilation
  17122. */
  17123. readonly options: IShaderMaterialOptions;
  17124. /**
  17125. * Gets the current class name of the material e.g. "ShaderMaterial"
  17126. * Mainly use in serialization.
  17127. * @returns the class name
  17128. */
  17129. getClassName(): string;
  17130. /**
  17131. * Specifies if the material will require alpha blending
  17132. * @returns a boolean specifying if alpha blending is needed
  17133. */
  17134. needAlphaBlending(): boolean;
  17135. /**
  17136. * Specifies if this material should be rendered in alpha test mode
  17137. * @returns a boolean specifying if an alpha test is needed.
  17138. */
  17139. needAlphaTesting(): boolean;
  17140. private _checkUniform;
  17141. /**
  17142. * Set a texture in the shader.
  17143. * @param name Define the name of the uniform samplers as defined in the shader
  17144. * @param texture Define the texture to bind to this sampler
  17145. * @return the material itself allowing "fluent" like uniform updates
  17146. */
  17147. setTexture(name: string, texture: Texture): ShaderMaterial;
  17148. /**
  17149. * Set a texture array in the shader.
  17150. * @param name Define the name of the uniform sampler array as defined in the shader
  17151. * @param textures Define the list of textures to bind to this sampler
  17152. * @return the material itself allowing "fluent" like uniform updates
  17153. */
  17154. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17155. /**
  17156. * Set a float in the shader.
  17157. * @param name Define the name of the uniform as defined in the shader
  17158. * @param value Define the value to give to the uniform
  17159. * @return the material itself allowing "fluent" like uniform updates
  17160. */
  17161. setFloat(name: string, value: number): ShaderMaterial;
  17162. /**
  17163. * Set a int in the shader.
  17164. * @param name Define the name of the uniform as defined in the shader
  17165. * @param value Define the value to give to the uniform
  17166. * @return the material itself allowing "fluent" like uniform updates
  17167. */
  17168. setInt(name: string, value: number): ShaderMaterial;
  17169. /**
  17170. * Set an array of floats in the shader.
  17171. * @param name Define the name of the uniform as defined in the shader
  17172. * @param value Define the value to give to the uniform
  17173. * @return the material itself allowing "fluent" like uniform updates
  17174. */
  17175. setFloats(name: string, value: number[]): ShaderMaterial;
  17176. /**
  17177. * Set a vec3 in the shader from a Color3.
  17178. * @param name Define the name of the uniform as defined in the shader
  17179. * @param value Define the value to give to the uniform
  17180. * @return the material itself allowing "fluent" like uniform updates
  17181. */
  17182. setColor3(name: string, value: Color3): ShaderMaterial;
  17183. /**
  17184. * Set a vec3 array in the shader from a Color3 array.
  17185. * @param name Define the name of the uniform as defined in the shader
  17186. * @param value Define the value to give to the uniform
  17187. * @return the material itself allowing "fluent" like uniform updates
  17188. */
  17189. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17190. /**
  17191. * Set a vec4 in the shader from a Color4.
  17192. * @param name Define the name of the uniform as defined in the shader
  17193. * @param value Define the value to give to the uniform
  17194. * @return the material itself allowing "fluent" like uniform updates
  17195. */
  17196. setColor4(name: string, value: Color4): ShaderMaterial;
  17197. /**
  17198. * Set a vec2 in the shader from a Vector2.
  17199. * @param name Define the name of the uniform as defined in the shader
  17200. * @param value Define the value to give to the uniform
  17201. * @return the material itself allowing "fluent" like uniform updates
  17202. */
  17203. setVector2(name: string, value: Vector2): ShaderMaterial;
  17204. /**
  17205. * Set a vec3 in the shader from a Vector3.
  17206. * @param name Define the name of the uniform as defined in the shader
  17207. * @param value Define the value to give to the uniform
  17208. * @return the material itself allowing "fluent" like uniform updates
  17209. */
  17210. setVector3(name: string, value: Vector3): ShaderMaterial;
  17211. /**
  17212. * Set a vec4 in the shader from a Vector4.
  17213. * @param name Define the name of the uniform as defined in the shader
  17214. * @param value Define the value to give to the uniform
  17215. * @return the material itself allowing "fluent" like uniform updates
  17216. */
  17217. setVector4(name: string, value: Vector4): ShaderMaterial;
  17218. /**
  17219. * Set a mat4 in the shader from a Matrix.
  17220. * @param name Define the name of the uniform as defined in the shader
  17221. * @param value Define the value to give to the uniform
  17222. * @return the material itself allowing "fluent" like uniform updates
  17223. */
  17224. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17225. /**
  17226. * Set a mat3 in the shader from a Float32Array.
  17227. * @param name Define the name of the uniform as defined in the shader
  17228. * @param value Define the value to give to the uniform
  17229. * @return the material itself allowing "fluent" like uniform updates
  17230. */
  17231. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17232. /**
  17233. * Set a mat2 in the shader from a Float32Array.
  17234. * @param name Define the name of the uniform as defined in the shader
  17235. * @param value Define the value to give to the uniform
  17236. * @return the material itself allowing "fluent" like uniform updates
  17237. */
  17238. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17239. /**
  17240. * Set a vec2 array in the shader from a number array.
  17241. * @param name Define the name of the uniform as defined in the shader
  17242. * @param value Define the value to give to the uniform
  17243. * @return the material itself allowing "fluent" like uniform updates
  17244. */
  17245. setArray2(name: string, value: number[]): ShaderMaterial;
  17246. /**
  17247. * Set a vec3 array in the shader from a number array.
  17248. * @param name Define the name of the uniform as defined in the shader
  17249. * @param value Define the value to give to the uniform
  17250. * @return the material itself allowing "fluent" like uniform updates
  17251. */
  17252. setArray3(name: string, value: number[]): ShaderMaterial;
  17253. private _checkCache;
  17254. /**
  17255. * Specifies that the submesh is ready to be used
  17256. * @param mesh defines the mesh to check
  17257. * @param subMesh defines which submesh to check
  17258. * @param useInstances specifies that instances should be used
  17259. * @returns a boolean indicating that the submesh is ready or not
  17260. */
  17261. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17262. /**
  17263. * Checks if the material is ready to render the requested mesh
  17264. * @param mesh Define the mesh to render
  17265. * @param useInstances Define whether or not the material is used with instances
  17266. * @returns true if ready, otherwise false
  17267. */
  17268. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17269. /**
  17270. * Binds the world matrix to the material
  17271. * @param world defines the world transformation matrix
  17272. */
  17273. bindOnlyWorldMatrix(world: Matrix): void;
  17274. /**
  17275. * Binds the material to the mesh
  17276. * @param world defines the world transformation matrix
  17277. * @param mesh defines the mesh to bind the material to
  17278. */
  17279. bind(world: Matrix, mesh?: Mesh): void;
  17280. /**
  17281. * Gets the active textures from the material
  17282. * @returns an array of textures
  17283. */
  17284. getActiveTextures(): BaseTexture[];
  17285. /**
  17286. * Specifies if the material uses a texture
  17287. * @param texture defines the texture to check against the material
  17288. * @returns a boolean specifying if the material uses the texture
  17289. */
  17290. hasTexture(texture: BaseTexture): boolean;
  17291. /**
  17292. * Makes a duplicate of the material, and gives it a new name
  17293. * @param name defines the new name for the duplicated material
  17294. * @returns the cloned material
  17295. */
  17296. clone(name: string): ShaderMaterial;
  17297. /**
  17298. * Disposes the material
  17299. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17300. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17301. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17302. */
  17303. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17304. /**
  17305. * Serializes this material in a JSON representation
  17306. * @returns the serialized material object
  17307. */
  17308. serialize(): any;
  17309. /**
  17310. * Creates a shader material from parsed shader material data
  17311. * @param source defines the JSON represnetation of the material
  17312. * @param scene defines the hosting scene
  17313. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17314. * @returns a new material
  17315. */
  17316. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17317. }
  17318. }
  17319. declare module "babylonjs/Shaders/color.fragment" {
  17320. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17321. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17322. /** @hidden */
  17323. export var colorPixelShader: {
  17324. name: string;
  17325. shader: string;
  17326. };
  17327. }
  17328. declare module "babylonjs/Shaders/color.vertex" {
  17329. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17330. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17331. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17332. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17333. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17334. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17335. /** @hidden */
  17336. export var colorVertexShader: {
  17337. name: string;
  17338. shader: string;
  17339. };
  17340. }
  17341. declare module "babylonjs/Meshes/linesMesh" {
  17342. import { Nullable } from "babylonjs/types";
  17343. import { Scene } from "babylonjs/scene";
  17344. import { Color3 } from "babylonjs/Maths/math";
  17345. import { Node } from "babylonjs/node";
  17346. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17347. import { Mesh } from "babylonjs/Meshes/mesh";
  17348. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17349. import { Effect } from "babylonjs/Materials/effect";
  17350. import { Material } from "babylonjs/Materials/material";
  17351. import "babylonjs/Shaders/color.fragment";
  17352. import "babylonjs/Shaders/color.vertex";
  17353. /**
  17354. * Line mesh
  17355. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17356. */
  17357. export class LinesMesh extends Mesh {
  17358. /**
  17359. * If vertex color should be applied to the mesh
  17360. */
  17361. useVertexColor?: boolean | undefined;
  17362. /**
  17363. * If vertex alpha should be applied to the mesh
  17364. */
  17365. useVertexAlpha?: boolean | undefined;
  17366. /**
  17367. * Color of the line (Default: White)
  17368. */
  17369. color: Color3;
  17370. /**
  17371. * Alpha of the line (Default: 1)
  17372. */
  17373. alpha: number;
  17374. /**
  17375. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17376. * This margin is expressed in world space coordinates, so its value may vary.
  17377. * Default value is 0.1
  17378. */
  17379. intersectionThreshold: number;
  17380. private _colorShader;
  17381. /**
  17382. * Creates a new LinesMesh
  17383. * @param name defines the name
  17384. * @param scene defines the hosting scene
  17385. * @param parent defines the parent mesh if any
  17386. * @param source defines the optional source LinesMesh used to clone data from
  17387. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17388. * When false, achieved by calling a clone(), also passing False.
  17389. * This will make creation of children, recursive.
  17390. * @param useVertexColor defines if this LinesMesh supports vertex color
  17391. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17392. */
  17393. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17394. /**
  17395. * If vertex color should be applied to the mesh
  17396. */
  17397. useVertexColor?: boolean | undefined,
  17398. /**
  17399. * If vertex alpha should be applied to the mesh
  17400. */
  17401. useVertexAlpha?: boolean | undefined);
  17402. private _addClipPlaneDefine;
  17403. private _removeClipPlaneDefine;
  17404. isReady(): boolean;
  17405. /**
  17406. * Returns the string "LineMesh"
  17407. */
  17408. getClassName(): string;
  17409. /**
  17410. * @hidden
  17411. */
  17412. /**
  17413. * @hidden
  17414. */
  17415. material: Material;
  17416. /**
  17417. * @hidden
  17418. */
  17419. readonly checkCollisions: boolean;
  17420. /** @hidden */
  17421. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17422. /** @hidden */
  17423. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17424. /**
  17425. * Disposes of the line mesh
  17426. * @param doNotRecurse If children should be disposed
  17427. */
  17428. dispose(doNotRecurse?: boolean): void;
  17429. /**
  17430. * Returns a new LineMesh object cloned from the current one.
  17431. */
  17432. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17433. /**
  17434. * Creates a new InstancedLinesMesh object from the mesh model.
  17435. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17436. * @param name defines the name of the new instance
  17437. * @returns a new InstancedLinesMesh
  17438. */
  17439. createInstance(name: string): InstancedLinesMesh;
  17440. }
  17441. /**
  17442. * Creates an instance based on a source LinesMesh
  17443. */
  17444. export class InstancedLinesMesh extends InstancedMesh {
  17445. /**
  17446. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17447. * This margin is expressed in world space coordinates, so its value may vary.
  17448. * Initilized with the intersectionThreshold value of the source LinesMesh
  17449. */
  17450. intersectionThreshold: number;
  17451. constructor(name: string, source: LinesMesh);
  17452. /**
  17453. * Returns the string "InstancedLinesMesh".
  17454. */
  17455. getClassName(): string;
  17456. }
  17457. }
  17458. declare module "babylonjs/Shaders/line.fragment" {
  17459. /** @hidden */
  17460. export var linePixelShader: {
  17461. name: string;
  17462. shader: string;
  17463. };
  17464. }
  17465. declare module "babylonjs/Shaders/line.vertex" {
  17466. /** @hidden */
  17467. export var lineVertexShader: {
  17468. name: string;
  17469. shader: string;
  17470. };
  17471. }
  17472. declare module "babylonjs/Rendering/edgesRenderer" {
  17473. import { Nullable } from "babylonjs/types";
  17474. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17476. import { Vector3 } from "babylonjs/Maths/math";
  17477. import { IDisposable } from "babylonjs/scene";
  17478. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17479. import "babylonjs/Shaders/line.fragment";
  17480. import "babylonjs/Shaders/line.vertex";
  17481. module "babylonjs/Meshes/abstractMesh" {
  17482. interface AbstractMesh {
  17483. /**
  17484. * Disables the mesh edge rendering mode
  17485. * @returns the currentAbstractMesh
  17486. */
  17487. disableEdgesRendering(): AbstractMesh;
  17488. /**
  17489. * Enables the edge rendering mode on the mesh.
  17490. * This mode makes the mesh edges visible
  17491. * @param epsilon defines the maximal distance between two angles to detect a face
  17492. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17493. * @returns the currentAbstractMesh
  17494. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17495. */
  17496. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17497. /**
  17498. * Gets the edgesRenderer associated with the mesh
  17499. */
  17500. edgesRenderer: Nullable<EdgesRenderer>;
  17501. }
  17502. }
  17503. module "babylonjs/Meshes/linesMesh" {
  17504. interface LinesMesh {
  17505. /**
  17506. * Enables the edge rendering mode on the mesh.
  17507. * This mode makes the mesh edges visible
  17508. * @param epsilon defines the maximal distance between two angles to detect a face
  17509. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17510. * @returns the currentAbstractMesh
  17511. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17512. */
  17513. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17514. }
  17515. }
  17516. module "babylonjs/Meshes/linesMesh" {
  17517. interface InstancedLinesMesh {
  17518. /**
  17519. * Enables the edge rendering mode on the mesh.
  17520. * This mode makes the mesh edges visible
  17521. * @param epsilon defines the maximal distance between two angles to detect a face
  17522. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17523. * @returns the current InstancedLinesMesh
  17524. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17525. */
  17526. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17527. }
  17528. }
  17529. /**
  17530. * Defines the minimum contract an Edges renderer should follow.
  17531. */
  17532. export interface IEdgesRenderer extends IDisposable {
  17533. /**
  17534. * Gets or sets a boolean indicating if the edgesRenderer is active
  17535. */
  17536. isEnabled: boolean;
  17537. /**
  17538. * Renders the edges of the attached mesh,
  17539. */
  17540. render(): void;
  17541. /**
  17542. * Checks wether or not the edges renderer is ready to render.
  17543. * @return true if ready, otherwise false.
  17544. */
  17545. isReady(): boolean;
  17546. }
  17547. /**
  17548. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17549. */
  17550. export class EdgesRenderer implements IEdgesRenderer {
  17551. /**
  17552. * Define the size of the edges with an orthographic camera
  17553. */
  17554. edgesWidthScalerForOrthographic: number;
  17555. /**
  17556. * Define the size of the edges with a perspective camera
  17557. */
  17558. edgesWidthScalerForPerspective: number;
  17559. protected _source: AbstractMesh;
  17560. protected _linesPositions: number[];
  17561. protected _linesNormals: number[];
  17562. protected _linesIndices: number[];
  17563. protected _epsilon: number;
  17564. protected _indicesCount: number;
  17565. protected _lineShader: ShaderMaterial;
  17566. protected _ib: WebGLBuffer;
  17567. protected _buffers: {
  17568. [key: string]: Nullable<VertexBuffer>;
  17569. };
  17570. protected _checkVerticesInsteadOfIndices: boolean;
  17571. private _meshRebuildObserver;
  17572. private _meshDisposeObserver;
  17573. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17574. isEnabled: boolean;
  17575. /**
  17576. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17577. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17578. * @param source Mesh used to create edges
  17579. * @param epsilon sum of angles in adjacency to check for edge
  17580. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17581. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17582. */
  17583. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17584. protected _prepareRessources(): void;
  17585. /** @hidden */
  17586. _rebuild(): void;
  17587. /**
  17588. * Releases the required resources for the edges renderer
  17589. */
  17590. dispose(): void;
  17591. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17592. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17593. /**
  17594. * Checks if the pair of p0 and p1 is en edge
  17595. * @param faceIndex
  17596. * @param edge
  17597. * @param faceNormals
  17598. * @param p0
  17599. * @param p1
  17600. * @private
  17601. */
  17602. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17603. /**
  17604. * push line into the position, normal and index buffer
  17605. * @protected
  17606. */
  17607. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17608. /**
  17609. * Generates lines edges from adjacencjes
  17610. * @private
  17611. */
  17612. _generateEdgesLines(): void;
  17613. /**
  17614. * Checks wether or not the edges renderer is ready to render.
  17615. * @return true if ready, otherwise false.
  17616. */
  17617. isReady(): boolean;
  17618. /**
  17619. * Renders the edges of the attached mesh,
  17620. */
  17621. render(): void;
  17622. }
  17623. /**
  17624. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17625. */
  17626. export class LineEdgesRenderer extends EdgesRenderer {
  17627. /**
  17628. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17629. * @param source LineMesh used to generate edges
  17630. * @param epsilon not important (specified angle for edge detection)
  17631. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17632. */
  17633. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17634. /**
  17635. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17636. */
  17637. _generateEdgesLines(): void;
  17638. }
  17639. }
  17640. declare module "babylonjs/Rendering/renderingGroup" {
  17641. import { SmartArray } from "babylonjs/Misc/smartArray";
  17642. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17644. import { Nullable } from "babylonjs/types";
  17645. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17646. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17647. import { Material } from "babylonjs/Materials/material";
  17648. import { Scene } from "babylonjs/scene";
  17649. /**
  17650. * This represents the object necessary to create a rendering group.
  17651. * This is exclusively used and created by the rendering manager.
  17652. * To modify the behavior, you use the available helpers in your scene or meshes.
  17653. * @hidden
  17654. */
  17655. export class RenderingGroup {
  17656. index: number;
  17657. private _scene;
  17658. private _opaqueSubMeshes;
  17659. private _transparentSubMeshes;
  17660. private _alphaTestSubMeshes;
  17661. private _depthOnlySubMeshes;
  17662. private _particleSystems;
  17663. private _spriteManagers;
  17664. private _opaqueSortCompareFn;
  17665. private _alphaTestSortCompareFn;
  17666. private _transparentSortCompareFn;
  17667. private _renderOpaque;
  17668. private _renderAlphaTest;
  17669. private _renderTransparent;
  17670. private _edgesRenderers;
  17671. onBeforeTransparentRendering: () => void;
  17672. /**
  17673. * Set the opaque sort comparison function.
  17674. * If null the sub meshes will be render in the order they were created
  17675. */
  17676. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17677. /**
  17678. * Set the alpha test sort comparison function.
  17679. * If null the sub meshes will be render in the order they were created
  17680. */
  17681. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17682. /**
  17683. * Set the transparent sort comparison function.
  17684. * If null the sub meshes will be render in the order they were created
  17685. */
  17686. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17687. /**
  17688. * Creates a new rendering group.
  17689. * @param index The rendering group index
  17690. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17691. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17692. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17693. */
  17694. 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>);
  17695. /**
  17696. * Render all the sub meshes contained in the group.
  17697. * @param customRenderFunction Used to override the default render behaviour of the group.
  17698. * @returns true if rendered some submeshes.
  17699. */
  17700. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17701. /**
  17702. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17703. * @param subMeshes The submeshes to render
  17704. */
  17705. private renderOpaqueSorted;
  17706. /**
  17707. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17708. * @param subMeshes The submeshes to render
  17709. */
  17710. private renderAlphaTestSorted;
  17711. /**
  17712. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17713. * @param subMeshes The submeshes to render
  17714. */
  17715. private renderTransparentSorted;
  17716. /**
  17717. * Renders the submeshes in a specified order.
  17718. * @param subMeshes The submeshes to sort before render
  17719. * @param sortCompareFn The comparison function use to sort
  17720. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17721. * @param transparent Specifies to activate blending if true
  17722. */
  17723. private static renderSorted;
  17724. /**
  17725. * Renders the submeshes in the order they were dispatched (no sort applied).
  17726. * @param subMeshes The submeshes to render
  17727. */
  17728. private static renderUnsorted;
  17729. /**
  17730. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17731. * are rendered back to front if in the same alpha index.
  17732. *
  17733. * @param a The first submesh
  17734. * @param b The second submesh
  17735. * @returns The result of the comparison
  17736. */
  17737. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17738. /**
  17739. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17740. * are rendered back to front.
  17741. *
  17742. * @param a The first submesh
  17743. * @param b The second submesh
  17744. * @returns The result of the comparison
  17745. */
  17746. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17747. /**
  17748. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17749. * are rendered front to back (prevent overdraw).
  17750. *
  17751. * @param a The first submesh
  17752. * @param b The second submesh
  17753. * @returns The result of the comparison
  17754. */
  17755. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17756. /**
  17757. * Resets the different lists of submeshes to prepare a new frame.
  17758. */
  17759. prepare(): void;
  17760. dispose(): void;
  17761. /**
  17762. * Inserts the submesh in its correct queue depending on its material.
  17763. * @param subMesh The submesh to dispatch
  17764. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17765. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17766. */
  17767. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17768. dispatchSprites(spriteManager: ISpriteManager): void;
  17769. dispatchParticles(particleSystem: IParticleSystem): void;
  17770. private _renderParticles;
  17771. private _renderSprites;
  17772. }
  17773. }
  17774. declare module "babylonjs/Rendering/renderingManager" {
  17775. import { Nullable } from "babylonjs/types";
  17776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17777. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17778. import { SmartArray } from "babylonjs/Misc/smartArray";
  17779. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17780. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17781. import { Material } from "babylonjs/Materials/material";
  17782. import { Scene } from "babylonjs/scene";
  17783. import { Camera } from "babylonjs/Cameras/camera";
  17784. /**
  17785. * Interface describing the different options available in the rendering manager
  17786. * regarding Auto Clear between groups.
  17787. */
  17788. export interface IRenderingManagerAutoClearSetup {
  17789. /**
  17790. * Defines whether or not autoclear is enable.
  17791. */
  17792. autoClear: boolean;
  17793. /**
  17794. * Defines whether or not to autoclear the depth buffer.
  17795. */
  17796. depth: boolean;
  17797. /**
  17798. * Defines whether or not to autoclear the stencil buffer.
  17799. */
  17800. stencil: boolean;
  17801. }
  17802. /**
  17803. * This class is used by the onRenderingGroupObservable
  17804. */
  17805. export class RenderingGroupInfo {
  17806. /**
  17807. * The Scene that being rendered
  17808. */
  17809. scene: Scene;
  17810. /**
  17811. * The camera currently used for the rendering pass
  17812. */
  17813. camera: Nullable<Camera>;
  17814. /**
  17815. * The ID of the renderingGroup being processed
  17816. */
  17817. renderingGroupId: number;
  17818. }
  17819. /**
  17820. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17821. * It is enable to manage the different groups as well as the different necessary sort functions.
  17822. * This should not be used directly aside of the few static configurations
  17823. */
  17824. export class RenderingManager {
  17825. /**
  17826. * The max id used for rendering groups (not included)
  17827. */
  17828. static MAX_RENDERINGGROUPS: number;
  17829. /**
  17830. * The min id used for rendering groups (included)
  17831. */
  17832. static MIN_RENDERINGGROUPS: number;
  17833. /**
  17834. * Used to globally prevent autoclearing scenes.
  17835. */
  17836. static AUTOCLEAR: boolean;
  17837. /**
  17838. * @hidden
  17839. */
  17840. _useSceneAutoClearSetup: boolean;
  17841. private _scene;
  17842. private _renderingGroups;
  17843. private _depthStencilBufferAlreadyCleaned;
  17844. private _autoClearDepthStencil;
  17845. private _customOpaqueSortCompareFn;
  17846. private _customAlphaTestSortCompareFn;
  17847. private _customTransparentSortCompareFn;
  17848. private _renderingGroupInfo;
  17849. /**
  17850. * Instantiates a new rendering group for a particular scene
  17851. * @param scene Defines the scene the groups belongs to
  17852. */
  17853. constructor(scene: Scene);
  17854. private _clearDepthStencilBuffer;
  17855. /**
  17856. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17857. * @hidden
  17858. */
  17859. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17860. /**
  17861. * Resets the different information of the group to prepare a new frame
  17862. * @hidden
  17863. */
  17864. reset(): void;
  17865. /**
  17866. * Dispose and release the group and its associated resources.
  17867. * @hidden
  17868. */
  17869. dispose(): void;
  17870. /**
  17871. * Clear the info related to rendering groups preventing retention points during dispose.
  17872. */
  17873. freeRenderingGroups(): void;
  17874. private _prepareRenderingGroup;
  17875. /**
  17876. * Add a sprite manager to the rendering manager in order to render it this frame.
  17877. * @param spriteManager Define the sprite manager to render
  17878. */
  17879. dispatchSprites(spriteManager: ISpriteManager): void;
  17880. /**
  17881. * Add a particle system to the rendering manager in order to render it this frame.
  17882. * @param particleSystem Define the particle system to render
  17883. */
  17884. dispatchParticles(particleSystem: IParticleSystem): void;
  17885. /**
  17886. * Add a submesh to the manager in order to render it this frame
  17887. * @param subMesh The submesh to dispatch
  17888. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17889. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17890. */
  17891. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17892. /**
  17893. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17894. * This allowed control for front to back rendering or reversly depending of the special needs.
  17895. *
  17896. * @param renderingGroupId The rendering group id corresponding to its index
  17897. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17898. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17899. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17900. */
  17901. 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;
  17902. /**
  17903. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17904. *
  17905. * @param renderingGroupId The rendering group id corresponding to its index
  17906. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17907. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17908. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17909. */
  17910. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17911. /**
  17912. * Gets the current auto clear configuration for one rendering group of the rendering
  17913. * manager.
  17914. * @param index the rendering group index to get the information for
  17915. * @returns The auto clear setup for the requested rendering group
  17916. */
  17917. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17918. }
  17919. }
  17920. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17921. import { Observable } from "babylonjs/Misc/observable";
  17922. import { SmartArray } from "babylonjs/Misc/smartArray";
  17923. import { Nullable } from "babylonjs/types";
  17924. import { Camera } from "babylonjs/Cameras/camera";
  17925. import { Scene } from "babylonjs/scene";
  17926. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17927. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17929. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17930. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17931. import { Texture } from "babylonjs/Materials/Textures/texture";
  17932. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17933. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17934. import { Engine } from "babylonjs/Engines/engine";
  17935. /**
  17936. * This Helps creating a texture that will be created from a camera in your scene.
  17937. * It is basically a dynamic texture that could be used to create special effects for instance.
  17938. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17939. */
  17940. export class RenderTargetTexture extends Texture {
  17941. isCube: boolean;
  17942. /**
  17943. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17944. */
  17945. static readonly REFRESHRATE_RENDER_ONCE: number;
  17946. /**
  17947. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17948. */
  17949. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17950. /**
  17951. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17952. * the central point of your effect and can save a lot of performances.
  17953. */
  17954. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17955. /**
  17956. * Use this predicate to dynamically define the list of mesh you want to render.
  17957. * If set, the renderList property will be overwritten.
  17958. */
  17959. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17960. private _renderList;
  17961. /**
  17962. * Use this list to define the list of mesh you want to render.
  17963. */
  17964. renderList: Nullable<Array<AbstractMesh>>;
  17965. private _hookArray;
  17966. /**
  17967. * Define if particles should be rendered in your texture.
  17968. */
  17969. renderParticles: boolean;
  17970. /**
  17971. * Define if sprites should be rendered in your texture.
  17972. */
  17973. renderSprites: boolean;
  17974. /**
  17975. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17976. */
  17977. coordinatesMode: number;
  17978. /**
  17979. * Define the camera used to render the texture.
  17980. */
  17981. activeCamera: Nullable<Camera>;
  17982. /**
  17983. * Override the render function of the texture with your own one.
  17984. */
  17985. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17986. /**
  17987. * Define if camera post processes should be use while rendering the texture.
  17988. */
  17989. useCameraPostProcesses: boolean;
  17990. /**
  17991. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17992. */
  17993. ignoreCameraViewport: boolean;
  17994. private _postProcessManager;
  17995. private _postProcesses;
  17996. private _resizeObserver;
  17997. /**
  17998. * An event triggered when the texture is unbind.
  17999. */
  18000. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18001. /**
  18002. * An event triggered when the texture is unbind.
  18003. */
  18004. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18005. private _onAfterUnbindObserver;
  18006. /**
  18007. * Set a after unbind callback in the texture.
  18008. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18009. */
  18010. onAfterUnbind: () => void;
  18011. /**
  18012. * An event triggered before rendering the texture
  18013. */
  18014. onBeforeRenderObservable: Observable<number>;
  18015. private _onBeforeRenderObserver;
  18016. /**
  18017. * Set a before render callback in the texture.
  18018. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18019. */
  18020. onBeforeRender: (faceIndex: number) => void;
  18021. /**
  18022. * An event triggered after rendering the texture
  18023. */
  18024. onAfterRenderObservable: Observable<number>;
  18025. private _onAfterRenderObserver;
  18026. /**
  18027. * Set a after render callback in the texture.
  18028. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18029. */
  18030. onAfterRender: (faceIndex: number) => void;
  18031. /**
  18032. * An event triggered after the texture clear
  18033. */
  18034. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18035. private _onClearObserver;
  18036. /**
  18037. * Set a clear callback in the texture.
  18038. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18039. */
  18040. onClear: (Engine: Engine) => void;
  18041. /**
  18042. * Define the clear color of the Render Target if it should be different from the scene.
  18043. */
  18044. clearColor: Color4;
  18045. protected _size: number | {
  18046. width: number;
  18047. height: number;
  18048. };
  18049. protected _initialSizeParameter: number | {
  18050. width: number;
  18051. height: number;
  18052. } | {
  18053. ratio: number;
  18054. };
  18055. protected _sizeRatio: Nullable<number>;
  18056. /** @hidden */
  18057. _generateMipMaps: boolean;
  18058. protected _renderingManager: RenderingManager;
  18059. /** @hidden */
  18060. _waitingRenderList: string[];
  18061. protected _doNotChangeAspectRatio: boolean;
  18062. protected _currentRefreshId: number;
  18063. protected _refreshRate: number;
  18064. protected _textureMatrix: Matrix;
  18065. protected _samples: number;
  18066. protected _renderTargetOptions: RenderTargetCreationOptions;
  18067. /**
  18068. * Gets render target creation options that were used.
  18069. */
  18070. readonly renderTargetOptions: RenderTargetCreationOptions;
  18071. protected _engine: Engine;
  18072. protected _onRatioRescale(): void;
  18073. /**
  18074. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18075. * It must define where the camera used to render the texture is set
  18076. */
  18077. boundingBoxPosition: Vector3;
  18078. private _boundingBoxSize;
  18079. /**
  18080. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18081. * When defined, the cubemap will switch to local mode
  18082. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18083. * @example https://www.babylonjs-playground.com/#RNASML
  18084. */
  18085. boundingBoxSize: Vector3;
  18086. /**
  18087. * In case the RTT has been created with a depth texture, get the associated
  18088. * depth texture.
  18089. * Otherwise, return null.
  18090. */
  18091. depthStencilTexture: Nullable<InternalTexture>;
  18092. /**
  18093. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18094. * or used a shadow, depth texture...
  18095. * @param name The friendly name of the texture
  18096. * @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)
  18097. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18098. * @param generateMipMaps True if mip maps need to be generated after render.
  18099. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18100. * @param type The type of the buffer in the RTT (int, half float, float...)
  18101. * @param isCube True if a cube texture needs to be created
  18102. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18103. * @param generateDepthBuffer True to generate a depth buffer
  18104. * @param generateStencilBuffer True to generate a stencil buffer
  18105. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18106. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18107. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18108. */
  18109. constructor(name: string, size: number | {
  18110. width: number;
  18111. height: number;
  18112. } | {
  18113. ratio: number;
  18114. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18115. /**
  18116. * Creates a depth stencil texture.
  18117. * This is only available in WebGL 2 or with the depth texture extension available.
  18118. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18119. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18120. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18121. */
  18122. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18123. private _processSizeParameter;
  18124. /**
  18125. * Define the number of samples to use in case of MSAA.
  18126. * It defaults to one meaning no MSAA has been enabled.
  18127. */
  18128. samples: number;
  18129. /**
  18130. * Resets the refresh counter of the texture and start bak from scratch.
  18131. * Could be useful to regenerate the texture if it is setup to render only once.
  18132. */
  18133. resetRefreshCounter(): void;
  18134. /**
  18135. * Define the refresh rate of the texture or the rendering frequency.
  18136. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18137. */
  18138. refreshRate: number;
  18139. /**
  18140. * Adds a post process to the render target rendering passes.
  18141. * @param postProcess define the post process to add
  18142. */
  18143. addPostProcess(postProcess: PostProcess): void;
  18144. /**
  18145. * Clear all the post processes attached to the render target
  18146. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18147. */
  18148. clearPostProcesses(dispose?: boolean): void;
  18149. /**
  18150. * Remove one of the post process from the list of attached post processes to the texture
  18151. * @param postProcess define the post process to remove from the list
  18152. */
  18153. removePostProcess(postProcess: PostProcess): void;
  18154. /** @hidden */
  18155. _shouldRender(): boolean;
  18156. /**
  18157. * Gets the actual render size of the texture.
  18158. * @returns the width of the render size
  18159. */
  18160. getRenderSize(): number;
  18161. /**
  18162. * Gets the actual render width of the texture.
  18163. * @returns the width of the render size
  18164. */
  18165. getRenderWidth(): number;
  18166. /**
  18167. * Gets the actual render height of the texture.
  18168. * @returns the height of the render size
  18169. */
  18170. getRenderHeight(): number;
  18171. /**
  18172. * Get if the texture can be rescaled or not.
  18173. */
  18174. readonly canRescale: boolean;
  18175. /**
  18176. * Resize the texture using a ratio.
  18177. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18178. */
  18179. scale(ratio: number): void;
  18180. /**
  18181. * Get the texture reflection matrix used to rotate/transform the reflection.
  18182. * @returns the reflection matrix
  18183. */
  18184. getReflectionTextureMatrix(): Matrix;
  18185. /**
  18186. * Resize the texture to a new desired size.
  18187. * Be carrefull as it will recreate all the data in the new texture.
  18188. * @param size Define the new size. It can be:
  18189. * - a number for squared texture,
  18190. * - an object containing { width: number, height: number }
  18191. * - or an object containing a ratio { ratio: number }
  18192. */
  18193. resize(size: number | {
  18194. width: number;
  18195. height: number;
  18196. } | {
  18197. ratio: number;
  18198. }): void;
  18199. /**
  18200. * Renders all the objects from the render list into the texture.
  18201. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18202. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18203. */
  18204. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18205. private _bestReflectionRenderTargetDimension;
  18206. /**
  18207. * @hidden
  18208. * @param faceIndex face index to bind to if this is a cubetexture
  18209. */
  18210. _bindFrameBuffer(faceIndex?: number): void;
  18211. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18212. private renderToTarget;
  18213. /**
  18214. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18215. * This allowed control for front to back rendering or reversly depending of the special needs.
  18216. *
  18217. * @param renderingGroupId The rendering group id corresponding to its index
  18218. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18219. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18220. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18221. */
  18222. 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;
  18223. /**
  18224. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18225. *
  18226. * @param renderingGroupId The rendering group id corresponding to its index
  18227. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18228. */
  18229. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18230. /**
  18231. * Clones the texture.
  18232. * @returns the cloned texture
  18233. */
  18234. clone(): RenderTargetTexture;
  18235. /**
  18236. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18237. * @returns The JSON representation of the texture
  18238. */
  18239. serialize(): any;
  18240. /**
  18241. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18242. */
  18243. disposeFramebufferObjects(): void;
  18244. /**
  18245. * Dispose the texture and release its associated resources.
  18246. */
  18247. dispose(): void;
  18248. /** @hidden */
  18249. _rebuild(): void;
  18250. /**
  18251. * Clear the info related to rendering groups preventing retention point in material dispose.
  18252. */
  18253. freeRenderingGroups(): void;
  18254. /**
  18255. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18256. * @returns the view count
  18257. */
  18258. getViewCount(): number;
  18259. }
  18260. }
  18261. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18262. import { Scene } from "babylonjs/scene";
  18263. import { Plane } from "babylonjs/Maths/math";
  18264. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18265. /**
  18266. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18267. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18268. * You can then easily use it as a reflectionTexture on a flat surface.
  18269. * In case the surface is not a plane, please consider relying on reflection probes.
  18270. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18271. */
  18272. export class MirrorTexture extends RenderTargetTexture {
  18273. private scene;
  18274. /**
  18275. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18276. * 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.
  18277. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18278. */
  18279. mirrorPlane: Plane;
  18280. /**
  18281. * Define the blur ratio used to blur the reflection if needed.
  18282. */
  18283. blurRatio: number;
  18284. /**
  18285. * Define the adaptive blur kernel used to blur the reflection if needed.
  18286. * This will autocompute the closest best match for the `blurKernel`
  18287. */
  18288. adaptiveBlurKernel: number;
  18289. /**
  18290. * Define the blur kernel used to blur the reflection if needed.
  18291. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18292. */
  18293. blurKernel: number;
  18294. /**
  18295. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18296. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18297. */
  18298. blurKernelX: number;
  18299. /**
  18300. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18301. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18302. */
  18303. blurKernelY: number;
  18304. private _autoComputeBlurKernel;
  18305. protected _onRatioRescale(): void;
  18306. private _updateGammaSpace;
  18307. private _imageProcessingConfigChangeObserver;
  18308. private _transformMatrix;
  18309. private _mirrorMatrix;
  18310. private _savedViewMatrix;
  18311. private _blurX;
  18312. private _blurY;
  18313. private _adaptiveBlurKernel;
  18314. private _blurKernelX;
  18315. private _blurKernelY;
  18316. private _blurRatio;
  18317. /**
  18318. * Instantiates a Mirror Texture.
  18319. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18320. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18321. * You can then easily use it as a reflectionTexture on a flat surface.
  18322. * In case the surface is not a plane, please consider relying on reflection probes.
  18323. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18324. * @param name
  18325. * @param size
  18326. * @param scene
  18327. * @param generateMipMaps
  18328. * @param type
  18329. * @param samplingMode
  18330. * @param generateDepthBuffer
  18331. */
  18332. constructor(name: string, size: number | {
  18333. width: number;
  18334. height: number;
  18335. } | {
  18336. ratio: number;
  18337. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18338. private _preparePostProcesses;
  18339. /**
  18340. * Clone the mirror texture.
  18341. * @returns the cloned texture
  18342. */
  18343. clone(): MirrorTexture;
  18344. /**
  18345. * Serialize the texture to a JSON representation you could use in Parse later on
  18346. * @returns the serialized JSON representation
  18347. */
  18348. serialize(): any;
  18349. /**
  18350. * Dispose the texture and release its associated resources.
  18351. */
  18352. dispose(): void;
  18353. }
  18354. }
  18355. declare module "babylonjs/Materials/Textures/texture" {
  18356. import { Observable } from "babylonjs/Misc/observable";
  18357. import { Nullable } from "babylonjs/types";
  18358. import { Scene } from "babylonjs/scene";
  18359. import { Matrix } from "babylonjs/Maths/math";
  18360. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18361. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18362. /**
  18363. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18364. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18365. */
  18366. export class Texture extends BaseTexture {
  18367. /** @hidden */
  18368. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18369. /** @hidden */
  18370. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18371. /** @hidden */
  18372. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18373. /** nearest is mag = nearest and min = nearest and mip = linear */
  18374. static readonly NEAREST_SAMPLINGMODE: number;
  18375. /** nearest is mag = nearest and min = nearest and mip = linear */
  18376. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18377. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18378. static readonly BILINEAR_SAMPLINGMODE: number;
  18379. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18380. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18381. /** Trilinear is mag = linear and min = linear and mip = linear */
  18382. static readonly TRILINEAR_SAMPLINGMODE: number;
  18383. /** Trilinear is mag = linear and min = linear and mip = linear */
  18384. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18385. /** mag = nearest and min = nearest and mip = nearest */
  18386. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18387. /** mag = nearest and min = linear and mip = nearest */
  18388. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18389. /** mag = nearest and min = linear and mip = linear */
  18390. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18391. /** mag = nearest and min = linear and mip = none */
  18392. static readonly NEAREST_LINEAR: number;
  18393. /** mag = nearest and min = nearest and mip = none */
  18394. static readonly NEAREST_NEAREST: number;
  18395. /** mag = linear and min = nearest and mip = nearest */
  18396. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18397. /** mag = linear and min = nearest and mip = linear */
  18398. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18399. /** mag = linear and min = linear and mip = none */
  18400. static readonly LINEAR_LINEAR: number;
  18401. /** mag = linear and min = nearest and mip = none */
  18402. static readonly LINEAR_NEAREST: number;
  18403. /** Explicit coordinates mode */
  18404. static readonly EXPLICIT_MODE: number;
  18405. /** Spherical coordinates mode */
  18406. static readonly SPHERICAL_MODE: number;
  18407. /** Planar coordinates mode */
  18408. static readonly PLANAR_MODE: number;
  18409. /** Cubic coordinates mode */
  18410. static readonly CUBIC_MODE: number;
  18411. /** Projection coordinates mode */
  18412. static readonly PROJECTION_MODE: number;
  18413. /** Inverse Cubic coordinates mode */
  18414. static readonly SKYBOX_MODE: number;
  18415. /** Inverse Cubic coordinates mode */
  18416. static readonly INVCUBIC_MODE: number;
  18417. /** Equirectangular coordinates mode */
  18418. static readonly EQUIRECTANGULAR_MODE: number;
  18419. /** Equirectangular Fixed coordinates mode */
  18420. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18421. /** Equirectangular Fixed Mirrored coordinates mode */
  18422. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18423. /** Texture is not repeating outside of 0..1 UVs */
  18424. static readonly CLAMP_ADDRESSMODE: number;
  18425. /** Texture is repeating outside of 0..1 UVs */
  18426. static readonly WRAP_ADDRESSMODE: number;
  18427. /** Texture is repeating and mirrored */
  18428. static readonly MIRROR_ADDRESSMODE: number;
  18429. /**
  18430. * 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
  18431. */
  18432. static UseSerializedUrlIfAny: boolean;
  18433. /**
  18434. * Define the url of the texture.
  18435. */
  18436. url: Nullable<string>;
  18437. /**
  18438. * Define an offset on the texture to offset the u coordinates of the UVs
  18439. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18440. */
  18441. uOffset: number;
  18442. /**
  18443. * Define an offset on the texture to offset the v coordinates of the UVs
  18444. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18445. */
  18446. vOffset: number;
  18447. /**
  18448. * Define an offset on the texture to scale the u coordinates of the UVs
  18449. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18450. */
  18451. uScale: number;
  18452. /**
  18453. * Define an offset on the texture to scale the v coordinates of the UVs
  18454. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18455. */
  18456. vScale: number;
  18457. /**
  18458. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18459. * @see http://doc.babylonjs.com/how_to/more_materials
  18460. */
  18461. uAng: number;
  18462. /**
  18463. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18464. * @see http://doc.babylonjs.com/how_to/more_materials
  18465. */
  18466. vAng: number;
  18467. /**
  18468. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18469. * @see http://doc.babylonjs.com/how_to/more_materials
  18470. */
  18471. wAng: number;
  18472. /**
  18473. * Defines the center of rotation (U)
  18474. */
  18475. uRotationCenter: number;
  18476. /**
  18477. * Defines the center of rotation (V)
  18478. */
  18479. vRotationCenter: number;
  18480. /**
  18481. * Defines the center of rotation (W)
  18482. */
  18483. wRotationCenter: number;
  18484. /**
  18485. * Are mip maps generated for this texture or not.
  18486. */
  18487. readonly noMipmap: boolean;
  18488. /**
  18489. * List of inspectable custom properties (used by the Inspector)
  18490. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18491. */
  18492. inspectableCustomProperties: IInspectable[];
  18493. private _noMipmap;
  18494. /** @hidden */
  18495. _invertY: boolean;
  18496. private _rowGenerationMatrix;
  18497. private _cachedTextureMatrix;
  18498. private _projectionModeMatrix;
  18499. private _t0;
  18500. private _t1;
  18501. private _t2;
  18502. private _cachedUOffset;
  18503. private _cachedVOffset;
  18504. private _cachedUScale;
  18505. private _cachedVScale;
  18506. private _cachedUAng;
  18507. private _cachedVAng;
  18508. private _cachedWAng;
  18509. private _cachedProjectionMatrixId;
  18510. private _cachedCoordinatesMode;
  18511. /** @hidden */
  18512. protected _initialSamplingMode: number;
  18513. /** @hidden */
  18514. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18515. private _deleteBuffer;
  18516. protected _format: Nullable<number>;
  18517. private _delayedOnLoad;
  18518. private _delayedOnError;
  18519. /**
  18520. * Observable triggered once the texture has been loaded.
  18521. */
  18522. onLoadObservable: Observable<Texture>;
  18523. protected _isBlocking: boolean;
  18524. /**
  18525. * Is the texture preventing material to render while loading.
  18526. * If false, a default texture will be used instead of the loading one during the preparation step.
  18527. */
  18528. isBlocking: boolean;
  18529. /**
  18530. * Get the current sampling mode associated with the texture.
  18531. */
  18532. readonly samplingMode: number;
  18533. /**
  18534. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18535. */
  18536. readonly invertY: boolean;
  18537. /**
  18538. * Instantiates a new texture.
  18539. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18540. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18541. * @param url define the url of the picture to load as a texture
  18542. * @param scene define the scene the texture will belong to
  18543. * @param noMipmap define if the texture will require mip maps or not
  18544. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18545. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18546. * @param onLoad define a callback triggered when the texture has been loaded
  18547. * @param onError define a callback triggered when an error occurred during the loading session
  18548. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18549. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18550. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18551. */
  18552. 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);
  18553. /**
  18554. * Update the url (and optional buffer) of this texture if url was null during construction.
  18555. * @param url the url of the texture
  18556. * @param buffer the buffer of the texture (defaults to null)
  18557. * @param onLoad callback called when the texture is loaded (defaults to null)
  18558. */
  18559. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18560. /**
  18561. * Finish the loading sequence of a texture flagged as delayed load.
  18562. * @hidden
  18563. */
  18564. delayLoad(): void;
  18565. private _prepareRowForTextureGeneration;
  18566. /**
  18567. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18568. * @returns the transform matrix of the texture.
  18569. */
  18570. getTextureMatrix(): Matrix;
  18571. /**
  18572. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18573. * @returns The reflection texture transform
  18574. */
  18575. getReflectionTextureMatrix(): Matrix;
  18576. /**
  18577. * Clones the texture.
  18578. * @returns the cloned texture
  18579. */
  18580. clone(): Texture;
  18581. /**
  18582. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18583. * @returns The JSON representation of the texture
  18584. */
  18585. serialize(): any;
  18586. /**
  18587. * Get the current class name of the texture useful for serialization or dynamic coding.
  18588. * @returns "Texture"
  18589. */
  18590. getClassName(): string;
  18591. /**
  18592. * Dispose the texture and release its associated resources.
  18593. */
  18594. dispose(): void;
  18595. /**
  18596. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18597. * @param parsedTexture Define the JSON representation of the texture
  18598. * @param scene Define the scene the parsed texture should be instantiated in
  18599. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18600. * @returns The parsed texture if successful
  18601. */
  18602. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18603. /**
  18604. * Creates a texture from its base 64 representation.
  18605. * @param data Define the base64 payload without the data: prefix
  18606. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18607. * @param scene Define the scene the texture should belong to
  18608. * @param noMipmap Forces the texture to not create mip map information if true
  18609. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18610. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18611. * @param onLoad define a callback triggered when the texture has been loaded
  18612. * @param onError define a callback triggered when an error occurred during the loading session
  18613. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18614. * @returns the created texture
  18615. */
  18616. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18617. /**
  18618. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18619. * @param data Define the base64 payload without the data: prefix
  18620. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18621. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18622. * @param scene Define the scene the texture should belong to
  18623. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18624. * @param noMipmap Forces the texture to not create mip map information if true
  18625. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18626. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18627. * @param onLoad define a callback triggered when the texture has been loaded
  18628. * @param onError define a callback triggered when an error occurred during the loading session
  18629. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18630. * @returns the created texture
  18631. */
  18632. 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;
  18633. }
  18634. }
  18635. declare module "babylonjs/Materials/Textures/rawTexture" {
  18636. import { Scene } from "babylonjs/scene";
  18637. import { Texture } from "babylonjs/Materials/Textures/texture";
  18638. /**
  18639. * Raw texture can help creating a texture directly from an array of data.
  18640. * This can be super useful if you either get the data from an uncompressed source or
  18641. * if you wish to create your texture pixel by pixel.
  18642. */
  18643. export class RawTexture extends Texture {
  18644. /**
  18645. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18646. */
  18647. format: number;
  18648. private _engine;
  18649. /**
  18650. * Instantiates a new RawTexture.
  18651. * Raw texture can help creating a texture directly from an array of data.
  18652. * This can be super useful if you either get the data from an uncompressed source or
  18653. * if you wish to create your texture pixel by pixel.
  18654. * @param data define the array of data to use to create the texture
  18655. * @param width define the width of the texture
  18656. * @param height define the height of the texture
  18657. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18658. * @param scene define the scene the texture belongs to
  18659. * @param generateMipMaps define whether mip maps should be generated or not
  18660. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18661. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18662. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18663. */
  18664. constructor(data: ArrayBufferView, width: number, height: number,
  18665. /**
  18666. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18667. */
  18668. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18669. /**
  18670. * Updates the texture underlying data.
  18671. * @param data Define the new data of the texture
  18672. */
  18673. update(data: ArrayBufferView): void;
  18674. /**
  18675. * Creates a luminance texture from some data.
  18676. * @param data Define the texture data
  18677. * @param width Define the width of the texture
  18678. * @param height Define the height of the texture
  18679. * @param scene Define the scene the texture belongs to
  18680. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18681. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18682. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18683. * @returns the luminance texture
  18684. */
  18685. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18686. /**
  18687. * Creates a luminance alpha texture from some data.
  18688. * @param data Define the texture data
  18689. * @param width Define the width of the texture
  18690. * @param height Define the height of the texture
  18691. * @param scene Define the scene the texture belongs to
  18692. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18693. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18694. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18695. * @returns the luminance alpha texture
  18696. */
  18697. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18698. /**
  18699. * Creates an alpha texture from some data.
  18700. * @param data Define the texture data
  18701. * @param width Define the width of the texture
  18702. * @param height Define the height of the texture
  18703. * @param scene Define the scene the texture belongs to
  18704. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18705. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18706. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18707. * @returns the alpha texture
  18708. */
  18709. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18710. /**
  18711. * Creates a RGB texture from some data.
  18712. * @param data Define the texture data
  18713. * @param width Define the width of the texture
  18714. * @param height Define the height of the texture
  18715. * @param scene Define the scene the texture belongs to
  18716. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18717. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18718. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18719. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18720. * @returns the RGB alpha texture
  18721. */
  18722. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18723. /**
  18724. * Creates a RGBA texture from some data.
  18725. * @param data Define the texture data
  18726. * @param width Define the width of the texture
  18727. * @param height Define the height of the texture
  18728. * @param scene Define the scene the texture belongs to
  18729. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18730. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18731. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18732. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18733. * @returns the RGBA texture
  18734. */
  18735. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18736. /**
  18737. * Creates a R texture from some data.
  18738. * @param data Define the texture data
  18739. * @param width Define the width of the texture
  18740. * @param height Define the height of the texture
  18741. * @param scene Define the scene the texture belongs to
  18742. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18743. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18744. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18745. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18746. * @returns the R texture
  18747. */
  18748. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18749. }
  18750. }
  18751. declare module "babylonjs/Animations/runtimeAnimation" {
  18752. import { Animation } from "babylonjs/Animations/animation";
  18753. import { Animatable } from "babylonjs/Animations/animatable";
  18754. import { Scene } from "babylonjs/scene";
  18755. /**
  18756. * Defines a runtime animation
  18757. */
  18758. export class RuntimeAnimation {
  18759. private _events;
  18760. /**
  18761. * The current frame of the runtime animation
  18762. */
  18763. private _currentFrame;
  18764. /**
  18765. * The animation used by the runtime animation
  18766. */
  18767. private _animation;
  18768. /**
  18769. * The target of the runtime animation
  18770. */
  18771. private _target;
  18772. /**
  18773. * The initiating animatable
  18774. */
  18775. private _host;
  18776. /**
  18777. * The original value of the runtime animation
  18778. */
  18779. private _originalValue;
  18780. /**
  18781. * The original blend value of the runtime animation
  18782. */
  18783. private _originalBlendValue;
  18784. /**
  18785. * The offsets cache of the runtime animation
  18786. */
  18787. private _offsetsCache;
  18788. /**
  18789. * The high limits cache of the runtime animation
  18790. */
  18791. private _highLimitsCache;
  18792. /**
  18793. * Specifies if the runtime animation has been stopped
  18794. */
  18795. private _stopped;
  18796. /**
  18797. * The blending factor of the runtime animation
  18798. */
  18799. private _blendingFactor;
  18800. /**
  18801. * The BabylonJS scene
  18802. */
  18803. private _scene;
  18804. /**
  18805. * The current value of the runtime animation
  18806. */
  18807. private _currentValue;
  18808. /** @hidden */
  18809. _workValue: any;
  18810. /**
  18811. * The active target of the runtime animation
  18812. */
  18813. private _activeTargets;
  18814. private _currentActiveTarget;
  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. private _enableBlending;
  18836. private _correctLoopMode;
  18837. /**
  18838. * Gets the current frame of the runtime animation
  18839. */
  18840. readonly currentFrame: number;
  18841. /**
  18842. * Gets the weight of the runtime animation
  18843. */
  18844. readonly weight: number;
  18845. /**
  18846. * Gets the current value of the runtime animation
  18847. */
  18848. readonly currentValue: any;
  18849. /**
  18850. * Gets the target path of the runtime animation
  18851. */
  18852. readonly targetPath: string;
  18853. /**
  18854. * Gets the actual target of the runtime animation
  18855. */
  18856. readonly target: any;
  18857. /**
  18858. * Create a new RuntimeAnimation object
  18859. * @param target defines the target of the animation
  18860. * @param animation defines the source animation object
  18861. * @param scene defines the hosting scene
  18862. * @param host defines the initiating Animatable
  18863. */
  18864. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18865. private _preparePath;
  18866. /**
  18867. * Gets the animation from the runtime animation
  18868. */
  18869. readonly animation: Animation;
  18870. /**
  18871. * Resets the runtime animation to the beginning
  18872. * @param restoreOriginal defines whether to restore the target property to the original value
  18873. */
  18874. reset(restoreOriginal?: boolean): void;
  18875. /**
  18876. * Specifies if the runtime animation is stopped
  18877. * @returns Boolean specifying if the runtime animation is stopped
  18878. */
  18879. isStopped(): boolean;
  18880. /**
  18881. * Disposes of the runtime animation
  18882. */
  18883. dispose(): void;
  18884. /**
  18885. * Interpolates the animation from the current frame
  18886. * @param currentFrame The frame to interpolate the animation to
  18887. * @param repeatCount The number of times that the animation should loop
  18888. * @param loopMode The type of looping mode to use
  18889. * @param offsetValue Animation offset value
  18890. * @param highLimitValue The high limit value
  18891. * @returns The interpolated value
  18892. */
  18893. private _interpolate;
  18894. /**
  18895. * Apply the interpolated value to the target
  18896. * @param currentValue defines the value computed by the animation
  18897. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18898. */
  18899. setValue(currentValue: any, weight?: number): void;
  18900. private _getOriginalValues;
  18901. private _activeBlendingProcessor;
  18902. private _noBlendingProcessor;
  18903. private _blendingProcessor;
  18904. private _setValue;
  18905. /**
  18906. * Gets the loop pmode of the runtime animation
  18907. * @returns Loop Mode
  18908. */
  18909. private _getCorrectLoopMode;
  18910. /**
  18911. * Move the current animation to a given frame
  18912. * @param frame defines the frame to move to
  18913. */
  18914. goToFrame(frame: number): void;
  18915. /**
  18916. * @hidden Internal use only
  18917. */
  18918. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18919. /**
  18920. * Execute the current animation
  18921. * @param delay defines the delay to add to the current frame
  18922. * @param from defines the lower bound of the animation range
  18923. * @param to defines the upper bound of the animation range
  18924. * @param loop defines if the current animation must loop
  18925. * @param speedRatio defines the current speed ratio
  18926. * @param weight defines the weight of the animation (default is -1 so no weight)
  18927. * @param onLoop optional callback called when animation loops
  18928. * @returns a boolean indicating if the animation is running
  18929. */
  18930. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18931. }
  18932. }
  18933. declare module "babylonjs/Animations/animatable" {
  18934. import { Animation } from "babylonjs/Animations/animation";
  18935. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18936. import { Nullable } from "babylonjs/types";
  18937. import { Observable } from "babylonjs/Misc/observable";
  18938. import { Scene } from "babylonjs/scene";
  18939. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18940. import { Node } from "babylonjs/node";
  18941. /**
  18942. * Class used to store an actual running animation
  18943. */
  18944. export class Animatable {
  18945. /** defines the target object */
  18946. target: any;
  18947. /** defines the starting frame number (default is 0) */
  18948. fromFrame: number;
  18949. /** defines the ending frame number (default is 100) */
  18950. toFrame: number;
  18951. /** defines if the animation must loop (default is false) */
  18952. loopAnimation: boolean;
  18953. /** defines a callback to call when animation ends if it is not looping */
  18954. onAnimationEnd?: (() => void) | null | undefined;
  18955. /** defines a callback to call when animation loops */
  18956. onAnimationLoop?: (() => void) | null | undefined;
  18957. private _localDelayOffset;
  18958. private _pausedDelay;
  18959. private _runtimeAnimations;
  18960. private _paused;
  18961. private _scene;
  18962. private _speedRatio;
  18963. private _weight;
  18964. private _syncRoot;
  18965. /**
  18966. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18967. * This will only apply for non looping animation (default is true)
  18968. */
  18969. disposeOnEnd: boolean;
  18970. /**
  18971. * Gets a boolean indicating if the animation has started
  18972. */
  18973. animationStarted: boolean;
  18974. /**
  18975. * Observer raised when the animation ends
  18976. */
  18977. onAnimationEndObservable: Observable<Animatable>;
  18978. /**
  18979. * Observer raised when the animation loops
  18980. */
  18981. onAnimationLoopObservable: Observable<Animatable>;
  18982. /**
  18983. * Gets the root Animatable used to synchronize and normalize animations
  18984. */
  18985. readonly syncRoot: Animatable;
  18986. /**
  18987. * Gets the current frame of the first RuntimeAnimation
  18988. * Used to synchronize Animatables
  18989. */
  18990. readonly masterFrame: number;
  18991. /**
  18992. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18993. */
  18994. weight: number;
  18995. /**
  18996. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18997. */
  18998. speedRatio: number;
  18999. /**
  19000. * Creates a new Animatable
  19001. * @param scene defines the hosting scene
  19002. * @param target defines the target object
  19003. * @param fromFrame defines the starting frame number (default is 0)
  19004. * @param toFrame defines the ending frame number (default is 100)
  19005. * @param loopAnimation defines if the animation must loop (default is false)
  19006. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19007. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19008. * @param animations defines a group of animation to add to the new Animatable
  19009. * @param onAnimationLoop defines a callback to call when animation loops
  19010. */
  19011. constructor(scene: Scene,
  19012. /** defines the target object */
  19013. target: any,
  19014. /** defines the starting frame number (default is 0) */
  19015. fromFrame?: number,
  19016. /** defines the ending frame number (default is 100) */
  19017. toFrame?: number,
  19018. /** defines if the animation must loop (default is false) */
  19019. loopAnimation?: boolean, speedRatio?: number,
  19020. /** defines a callback to call when animation ends if it is not looping */
  19021. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19022. /** defines a callback to call when animation loops */
  19023. onAnimationLoop?: (() => void) | null | undefined);
  19024. /**
  19025. * Synchronize and normalize current Animatable with a source Animatable
  19026. * This is useful when using animation weights and when animations are not of the same length
  19027. * @param root defines the root Animatable to synchronize with
  19028. * @returns the current Animatable
  19029. */
  19030. syncWith(root: Animatable): Animatable;
  19031. /**
  19032. * Gets the list of runtime animations
  19033. * @returns an array of RuntimeAnimation
  19034. */
  19035. getAnimations(): RuntimeAnimation[];
  19036. /**
  19037. * Adds more animations to the current animatable
  19038. * @param target defines the target of the animations
  19039. * @param animations defines the new animations to add
  19040. */
  19041. appendAnimations(target: any, animations: Animation[]): void;
  19042. /**
  19043. * Gets the source animation for a specific property
  19044. * @param property defines the propertyu to look for
  19045. * @returns null or the source animation for the given property
  19046. */
  19047. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19048. /**
  19049. * Gets the runtime animation for a specific property
  19050. * @param property defines the propertyu to look for
  19051. * @returns null or the runtime animation for the given property
  19052. */
  19053. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19054. /**
  19055. * Resets the animatable to its original state
  19056. */
  19057. reset(): void;
  19058. /**
  19059. * Allows the animatable to blend with current running animations
  19060. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19061. * @param blendingSpeed defines the blending speed to use
  19062. */
  19063. enableBlending(blendingSpeed: number): void;
  19064. /**
  19065. * Disable animation blending
  19066. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19067. */
  19068. disableBlending(): void;
  19069. /**
  19070. * Jump directly to a given frame
  19071. * @param frame defines the frame to jump to
  19072. */
  19073. goToFrame(frame: number): void;
  19074. /**
  19075. * Pause the animation
  19076. */
  19077. pause(): void;
  19078. /**
  19079. * Restart the animation
  19080. */
  19081. restart(): void;
  19082. private _raiseOnAnimationEnd;
  19083. /**
  19084. * Stop and delete the current animation
  19085. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19086. * @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)
  19087. */
  19088. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19089. /**
  19090. * Wait asynchronously for the animation to end
  19091. * @returns a promise which will be fullfilled when the animation ends
  19092. */
  19093. waitAsync(): Promise<Animatable>;
  19094. /** @hidden */
  19095. _animate(delay: number): boolean;
  19096. }
  19097. module "babylonjs/scene" {
  19098. interface Scene {
  19099. /** @hidden */
  19100. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19101. /** @hidden */
  19102. _processLateAnimationBindingsForMatrices(holder: {
  19103. totalWeight: number;
  19104. animations: RuntimeAnimation[];
  19105. originalValue: Matrix;
  19106. }): any;
  19107. /** @hidden */
  19108. _processLateAnimationBindingsForQuaternions(holder: {
  19109. totalWeight: number;
  19110. animations: RuntimeAnimation[];
  19111. originalValue: Quaternion;
  19112. }, refQuaternion: Quaternion): Quaternion;
  19113. /** @hidden */
  19114. _processLateAnimationBindings(): void;
  19115. /**
  19116. * Will start the animation sequence of a given target
  19117. * @param target defines the target
  19118. * @param from defines from which frame should animation start
  19119. * @param to defines until which frame should animation run.
  19120. * @param weight defines the weight to apply to the animation (1.0 by default)
  19121. * @param loop defines if the animation loops
  19122. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19123. * @param onAnimationEnd defines the function to be executed when the animation ends
  19124. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19125. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19126. * @param onAnimationLoop defines the callback to call when an animation loops
  19127. * @returns the animatable object created for this animation
  19128. */
  19129. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19130. /**
  19131. * Will start the animation sequence of a given target
  19132. * @param target defines the target
  19133. * @param from defines from which frame should animation start
  19134. * @param to defines until which frame should animation run.
  19135. * @param loop defines if the animation loops
  19136. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19137. * @param onAnimationEnd defines the function to be executed when the animation ends
  19138. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19139. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19140. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19141. * @param onAnimationLoop defines the callback to call when an animation loops
  19142. * @returns the animatable object created for this animation
  19143. */
  19144. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19145. /**
  19146. * Will start the animation sequence of a given target and its hierarchy
  19147. * @param target defines the target
  19148. * @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.
  19149. * @param from defines from which frame should animation start
  19150. * @param to defines until which frame should animation run.
  19151. * @param loop defines if the animation loops
  19152. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19153. * @param onAnimationEnd defines the function to be executed when the animation ends
  19154. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19155. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19156. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19157. * @param onAnimationLoop defines the callback to call when an animation loops
  19158. * @returns the list of created animatables
  19159. */
  19160. 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[];
  19161. /**
  19162. * Begin a new animation on a given node
  19163. * @param target defines the target where the animation will take place
  19164. * @param animations defines the list of animations to start
  19165. * @param from defines the initial value
  19166. * @param to defines the final value
  19167. * @param loop defines if you want animation to loop (off by default)
  19168. * @param speedRatio defines the speed ratio to apply to all animations
  19169. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19170. * @param onAnimationLoop defines the callback to call when an animation loops
  19171. * @returns the list of created animatables
  19172. */
  19173. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19174. /**
  19175. * Begin a new animation on a given node and its hierarchy
  19176. * @param target defines the root node where the animation will take place
  19177. * @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.
  19178. * @param animations defines the list of animations to start
  19179. * @param from defines the initial value
  19180. * @param to defines the final value
  19181. * @param loop defines if you want animation to loop (off by default)
  19182. * @param speedRatio defines the speed ratio to apply to all animations
  19183. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19184. * @param onAnimationLoop defines the callback to call when an animation loops
  19185. * @returns the list of animatables created for all nodes
  19186. */
  19187. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19188. /**
  19189. * Gets the animatable associated with a specific target
  19190. * @param target defines the target of the animatable
  19191. * @returns the required animatable if found
  19192. */
  19193. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19194. /**
  19195. * Gets all animatables associated with a given target
  19196. * @param target defines the target to look animatables for
  19197. * @returns an array of Animatables
  19198. */
  19199. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19200. /**
  19201. * Will stop the animation of the given target
  19202. * @param target - the target
  19203. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  19204. * @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)
  19205. */
  19206. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  19207. /**
  19208. * Stops and removes all animations that have been applied to the scene
  19209. */
  19210. stopAllAnimations(): void;
  19211. }
  19212. }
  19213. module "babylonjs/Bones/bone" {
  19214. interface Bone {
  19215. /**
  19216. * Copy an animation range from another bone
  19217. * @param source defines the source bone
  19218. * @param rangeName defines the range name to copy
  19219. * @param frameOffset defines the frame offset
  19220. * @param rescaleAsRequired defines if rescaling must be applied if required
  19221. * @param skelDimensionsRatio defines the scaling ratio
  19222. * @returns true if operation was successful
  19223. */
  19224. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19225. }
  19226. }
  19227. }
  19228. declare module "babylonjs/Bones/skeleton" {
  19229. import { Bone } from "babylonjs/Bones/bone";
  19230. import { IAnimatable } from "babylonjs/Misc/tools";
  19231. import { Observable } from "babylonjs/Misc/observable";
  19232. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19233. import { Scene } from "babylonjs/scene";
  19234. import { Nullable } from "babylonjs/types";
  19235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19236. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19237. import { Animatable } from "babylonjs/Animations/animatable";
  19238. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19239. import { Animation } from "babylonjs/Animations/animation";
  19240. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19241. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19242. /**
  19243. * Class used to handle skinning animations
  19244. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19245. */
  19246. export class Skeleton implements IAnimatable {
  19247. /** defines the skeleton name */
  19248. name: string;
  19249. /** defines the skeleton Id */
  19250. id: string;
  19251. /**
  19252. * Defines the list of child bones
  19253. */
  19254. bones: Bone[];
  19255. /**
  19256. * Defines an estimate of the dimension of the skeleton at rest
  19257. */
  19258. dimensionsAtRest: Vector3;
  19259. /**
  19260. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19261. */
  19262. needInitialSkinMatrix: boolean;
  19263. /**
  19264. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19265. */
  19266. overrideMesh: Nullable<AbstractMesh>;
  19267. /**
  19268. * Gets the list of animations attached to this skeleton
  19269. */
  19270. animations: Array<Animation>;
  19271. private _scene;
  19272. private _isDirty;
  19273. private _transformMatrices;
  19274. private _transformMatrixTexture;
  19275. private _meshesWithPoseMatrix;
  19276. private _animatables;
  19277. private _identity;
  19278. private _synchronizedWithMesh;
  19279. private _ranges;
  19280. private _lastAbsoluteTransformsUpdateId;
  19281. private _canUseTextureForBones;
  19282. private _uniqueId;
  19283. /** @hidden */
  19284. _numBonesWithLinkedTransformNode: number;
  19285. /**
  19286. * Specifies if the skeleton should be serialized
  19287. */
  19288. doNotSerialize: boolean;
  19289. private _useTextureToStoreBoneMatrices;
  19290. /**
  19291. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19292. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19293. */
  19294. useTextureToStoreBoneMatrices: boolean;
  19295. private _animationPropertiesOverride;
  19296. /**
  19297. * Gets or sets the animation properties override
  19298. */
  19299. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19300. /**
  19301. * List of inspectable custom properties (used by the Inspector)
  19302. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19303. */
  19304. inspectableCustomProperties: IInspectable[];
  19305. /**
  19306. * An observable triggered before computing the skeleton's matrices
  19307. */
  19308. onBeforeComputeObservable: Observable<Skeleton>;
  19309. /**
  19310. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19311. */
  19312. readonly isUsingTextureForMatrices: boolean;
  19313. /**
  19314. * Gets the unique ID of this skeleton
  19315. */
  19316. readonly uniqueId: number;
  19317. /**
  19318. * Creates a new skeleton
  19319. * @param name defines the skeleton name
  19320. * @param id defines the skeleton Id
  19321. * @param scene defines the hosting scene
  19322. */
  19323. constructor(
  19324. /** defines the skeleton name */
  19325. name: string,
  19326. /** defines the skeleton Id */
  19327. id: string, scene: Scene);
  19328. /**
  19329. * Gets the current object class name.
  19330. * @return the class name
  19331. */
  19332. getClassName(): string;
  19333. /**
  19334. * Returns an array containing the root bones
  19335. * @returns an array containing the root bones
  19336. */
  19337. getChildren(): Array<Bone>;
  19338. /**
  19339. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19340. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19341. * @returns a Float32Array containing matrices data
  19342. */
  19343. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19344. /**
  19345. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19346. * @returns a raw texture containing the data
  19347. */
  19348. getTransformMatrixTexture(): Nullable<RawTexture>;
  19349. /**
  19350. * Gets the current hosting scene
  19351. * @returns a scene object
  19352. */
  19353. getScene(): Scene;
  19354. /**
  19355. * Gets a string representing the current skeleton data
  19356. * @param fullDetails defines a boolean indicating if we want a verbose version
  19357. * @returns a string representing the current skeleton data
  19358. */
  19359. toString(fullDetails?: boolean): string;
  19360. /**
  19361. * Get bone's index searching by name
  19362. * @param name defines bone's name to search for
  19363. * @return the indice of the bone. Returns -1 if not found
  19364. */
  19365. getBoneIndexByName(name: string): number;
  19366. /**
  19367. * Creater a new animation range
  19368. * @param name defines the name of the range
  19369. * @param from defines the start key
  19370. * @param to defines the end key
  19371. */
  19372. createAnimationRange(name: string, from: number, to: number): void;
  19373. /**
  19374. * Delete a specific animation range
  19375. * @param name defines the name of the range
  19376. * @param deleteFrames defines if frames must be removed as well
  19377. */
  19378. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19379. /**
  19380. * Gets a specific animation range
  19381. * @param name defines the name of the range to look for
  19382. * @returns the requested animation range or null if not found
  19383. */
  19384. getAnimationRange(name: string): Nullable<AnimationRange>;
  19385. /**
  19386. * Gets the list of all animation ranges defined on this skeleton
  19387. * @returns an array
  19388. */
  19389. getAnimationRanges(): Nullable<AnimationRange>[];
  19390. /**
  19391. * Copy animation range from a source skeleton.
  19392. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19393. * @param source defines the source skeleton
  19394. * @param name defines the name of the range to copy
  19395. * @param rescaleAsRequired defines if rescaling must be applied if required
  19396. * @returns true if operation was successful
  19397. */
  19398. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19399. /**
  19400. * Forces the skeleton to go to rest pose
  19401. */
  19402. returnToRest(): void;
  19403. private _getHighestAnimationFrame;
  19404. /**
  19405. * Begin a specific animation range
  19406. * @param name defines the name of the range to start
  19407. * @param loop defines if looping must be turned on (false by default)
  19408. * @param speedRatio defines the speed ratio to apply (1 by default)
  19409. * @param onAnimationEnd defines a callback which will be called when animation will end
  19410. * @returns a new animatable
  19411. */
  19412. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19413. /** @hidden */
  19414. _markAsDirty(): void;
  19415. /** @hidden */
  19416. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19417. /** @hidden */
  19418. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19419. private _computeTransformMatrices;
  19420. /**
  19421. * Build all resources required to render a skeleton
  19422. */
  19423. prepare(): void;
  19424. /**
  19425. * Gets the list of animatables currently running for this skeleton
  19426. * @returns an array of animatables
  19427. */
  19428. getAnimatables(): IAnimatable[];
  19429. /**
  19430. * Clone the current skeleton
  19431. * @param name defines the name of the new skeleton
  19432. * @param id defines the id of the enw skeleton
  19433. * @returns the new skeleton
  19434. */
  19435. clone(name: string, id: string): Skeleton;
  19436. /**
  19437. * Enable animation blending for this skeleton
  19438. * @param blendingSpeed defines the blending speed to apply
  19439. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19440. */
  19441. enableBlending(blendingSpeed?: number): void;
  19442. /**
  19443. * Releases all resources associated with the current skeleton
  19444. */
  19445. dispose(): void;
  19446. /**
  19447. * Serialize the skeleton in a JSON object
  19448. * @returns a JSON object
  19449. */
  19450. serialize(): any;
  19451. /**
  19452. * Creates a new skeleton from serialized data
  19453. * @param parsedSkeleton defines the serialized data
  19454. * @param scene defines the hosting scene
  19455. * @returns a new skeleton
  19456. */
  19457. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19458. /**
  19459. * Compute all node absolute transforms
  19460. * @param forceUpdate defines if computation must be done even if cache is up to date
  19461. */
  19462. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19463. /**
  19464. * Gets the root pose matrix
  19465. * @returns a matrix
  19466. */
  19467. getPoseMatrix(): Nullable<Matrix>;
  19468. /**
  19469. * Sorts bones per internal index
  19470. */
  19471. sortBones(): void;
  19472. private _sortBones;
  19473. }
  19474. }
  19475. declare module "babylonjs/Morph/morphTarget" {
  19476. import { IAnimatable } from "babylonjs/Misc/tools";
  19477. import { Observable } from "babylonjs/Misc/observable";
  19478. import { Nullable, FloatArray } from "babylonjs/types";
  19479. import { Scene } from "babylonjs/scene";
  19480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19481. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19482. /**
  19483. * Defines a target to use with MorphTargetManager
  19484. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19485. */
  19486. export class MorphTarget implements IAnimatable {
  19487. /** defines the name of the target */
  19488. name: string;
  19489. /**
  19490. * Gets or sets the list of animations
  19491. */
  19492. animations: import("babylonjs/Animations/animation").Animation[];
  19493. private _scene;
  19494. private _positions;
  19495. private _normals;
  19496. private _tangents;
  19497. private _influence;
  19498. /**
  19499. * Observable raised when the influence changes
  19500. */
  19501. onInfluenceChanged: Observable<boolean>;
  19502. /** @hidden */
  19503. _onDataLayoutChanged: Observable<void>;
  19504. /**
  19505. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19506. */
  19507. influence: number;
  19508. /**
  19509. * Gets or sets the id of the morph Target
  19510. */
  19511. id: string;
  19512. private _animationPropertiesOverride;
  19513. /**
  19514. * Gets or sets the animation properties override
  19515. */
  19516. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19517. /**
  19518. * Creates a new MorphTarget
  19519. * @param name defines the name of the target
  19520. * @param influence defines the influence to use
  19521. * @param scene defines the scene the morphtarget belongs to
  19522. */
  19523. constructor(
  19524. /** defines the name of the target */
  19525. name: string, influence?: number, scene?: Nullable<Scene>);
  19526. /**
  19527. * Gets a boolean defining if the target contains position data
  19528. */
  19529. readonly hasPositions: boolean;
  19530. /**
  19531. * Gets a boolean defining if the target contains normal data
  19532. */
  19533. readonly hasNormals: boolean;
  19534. /**
  19535. * Gets a boolean defining if the target contains tangent data
  19536. */
  19537. readonly hasTangents: boolean;
  19538. /**
  19539. * Affects position data to this target
  19540. * @param data defines the position data to use
  19541. */
  19542. setPositions(data: Nullable<FloatArray>): void;
  19543. /**
  19544. * Gets the position data stored in this target
  19545. * @returns a FloatArray containing the position data (or null if not present)
  19546. */
  19547. getPositions(): Nullable<FloatArray>;
  19548. /**
  19549. * Affects normal data to this target
  19550. * @param data defines the normal data to use
  19551. */
  19552. setNormals(data: Nullable<FloatArray>): void;
  19553. /**
  19554. * Gets the normal data stored in this target
  19555. * @returns a FloatArray containing the normal data (or null if not present)
  19556. */
  19557. getNormals(): Nullable<FloatArray>;
  19558. /**
  19559. * Affects tangent data to this target
  19560. * @param data defines the tangent data to use
  19561. */
  19562. setTangents(data: Nullable<FloatArray>): void;
  19563. /**
  19564. * Gets the tangent data stored in this target
  19565. * @returns a FloatArray containing the tangent data (or null if not present)
  19566. */
  19567. getTangents(): Nullable<FloatArray>;
  19568. /**
  19569. * Serializes the current target into a Serialization object
  19570. * @returns the serialized object
  19571. */
  19572. serialize(): any;
  19573. /**
  19574. * Returns the string "MorphTarget"
  19575. * @returns "MorphTarget"
  19576. */
  19577. getClassName(): string;
  19578. /**
  19579. * Creates a new target from serialized data
  19580. * @param serializationObject defines the serialized data to use
  19581. * @returns a new MorphTarget
  19582. */
  19583. static Parse(serializationObject: any): MorphTarget;
  19584. /**
  19585. * Creates a MorphTarget from mesh data
  19586. * @param mesh defines the source mesh
  19587. * @param name defines the name to use for the new target
  19588. * @param influence defines the influence to attach to the target
  19589. * @returns a new MorphTarget
  19590. */
  19591. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19592. }
  19593. }
  19594. declare module "babylonjs/Morph/morphTargetManager" {
  19595. import { Nullable } from "babylonjs/types";
  19596. import { Scene } from "babylonjs/scene";
  19597. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19598. /**
  19599. * This class is used to deform meshes using morphing between different targets
  19600. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19601. */
  19602. export class MorphTargetManager {
  19603. private _targets;
  19604. private _targetInfluenceChangedObservers;
  19605. private _targetDataLayoutChangedObservers;
  19606. private _activeTargets;
  19607. private _scene;
  19608. private _influences;
  19609. private _supportsNormals;
  19610. private _supportsTangents;
  19611. private _vertexCount;
  19612. private _uniqueId;
  19613. private _tempInfluences;
  19614. /**
  19615. * Creates a new MorphTargetManager
  19616. * @param scene defines the current scene
  19617. */
  19618. constructor(scene?: Nullable<Scene>);
  19619. /**
  19620. * Gets the unique ID of this manager
  19621. */
  19622. readonly uniqueId: number;
  19623. /**
  19624. * Gets the number of vertices handled by this manager
  19625. */
  19626. readonly vertexCount: number;
  19627. /**
  19628. * Gets a boolean indicating if this manager supports morphing of normals
  19629. */
  19630. readonly supportsNormals: boolean;
  19631. /**
  19632. * Gets a boolean indicating if this manager supports morphing of tangents
  19633. */
  19634. readonly supportsTangents: boolean;
  19635. /**
  19636. * Gets the number of targets stored in this manager
  19637. */
  19638. readonly numTargets: number;
  19639. /**
  19640. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19641. */
  19642. readonly numInfluencers: number;
  19643. /**
  19644. * Gets the list of influences (one per target)
  19645. */
  19646. readonly influences: Float32Array;
  19647. /**
  19648. * Gets the active target at specified index. An active target is a target with an influence > 0
  19649. * @param index defines the index to check
  19650. * @returns the requested target
  19651. */
  19652. getActiveTarget(index: number): MorphTarget;
  19653. /**
  19654. * Gets the target at specified index
  19655. * @param index defines the index to check
  19656. * @returns the requested target
  19657. */
  19658. getTarget(index: number): MorphTarget;
  19659. /**
  19660. * Add a new target to this manager
  19661. * @param target defines the target to add
  19662. */
  19663. addTarget(target: MorphTarget): void;
  19664. /**
  19665. * Removes a target from the manager
  19666. * @param target defines the target to remove
  19667. */
  19668. removeTarget(target: MorphTarget): void;
  19669. /**
  19670. * Serializes the current manager into a Serialization object
  19671. * @returns the serialized object
  19672. */
  19673. serialize(): any;
  19674. private _syncActiveTargets;
  19675. /**
  19676. * Syncrhonize the targets with all the meshes using this morph target manager
  19677. */
  19678. synchronize(): void;
  19679. /**
  19680. * Creates a new MorphTargetManager from serialized data
  19681. * @param serializationObject defines the serialized data
  19682. * @param scene defines the hosting scene
  19683. * @returns the new MorphTargetManager
  19684. */
  19685. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19686. }
  19687. }
  19688. declare module "babylonjs/Meshes/groundMesh" {
  19689. import { Scene } from "babylonjs/scene";
  19690. import { Vector3 } from "babylonjs/Maths/math";
  19691. import { Mesh } from "babylonjs/Meshes/mesh";
  19692. /**
  19693. * Mesh representing the gorund
  19694. */
  19695. export class GroundMesh extends Mesh {
  19696. /** If octree should be generated */
  19697. generateOctree: boolean;
  19698. private _heightQuads;
  19699. /** @hidden */
  19700. _subdivisionsX: number;
  19701. /** @hidden */
  19702. _subdivisionsY: number;
  19703. /** @hidden */
  19704. _width: number;
  19705. /** @hidden */
  19706. _height: number;
  19707. /** @hidden */
  19708. _minX: number;
  19709. /** @hidden */
  19710. _maxX: number;
  19711. /** @hidden */
  19712. _minZ: number;
  19713. /** @hidden */
  19714. _maxZ: number;
  19715. constructor(name: string, scene: Scene);
  19716. /**
  19717. * "GroundMesh"
  19718. * @returns "GroundMesh"
  19719. */
  19720. getClassName(): string;
  19721. /**
  19722. * The minimum of x and y subdivisions
  19723. */
  19724. readonly subdivisions: number;
  19725. /**
  19726. * X subdivisions
  19727. */
  19728. readonly subdivisionsX: number;
  19729. /**
  19730. * Y subdivisions
  19731. */
  19732. readonly subdivisionsY: number;
  19733. /**
  19734. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19735. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19736. * @param chunksCount the number of subdivisions for x and y
  19737. * @param octreeBlocksSize (Default: 32)
  19738. */
  19739. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19740. /**
  19741. * Returns a height (y) value in the Worl system :
  19742. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19743. * @param x x coordinate
  19744. * @param z z coordinate
  19745. * @returns the ground y position if (x, z) are outside the ground surface.
  19746. */
  19747. getHeightAtCoordinates(x: number, z: number): number;
  19748. /**
  19749. * Returns a normalized vector (Vector3) orthogonal to the ground
  19750. * at the ground coordinates (x, z) expressed in the World system.
  19751. * @param x x coordinate
  19752. * @param z z coordinate
  19753. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19754. */
  19755. getNormalAtCoordinates(x: number, z: number): Vector3;
  19756. /**
  19757. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19758. * at the ground coordinates (x, z) expressed in the World system.
  19759. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19760. * @param x x coordinate
  19761. * @param z z coordinate
  19762. * @param ref vector to store the result
  19763. * @returns the GroundMesh.
  19764. */
  19765. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19766. /**
  19767. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19768. * if the ground has been updated.
  19769. * This can be used in the render loop.
  19770. * @returns the GroundMesh.
  19771. */
  19772. updateCoordinateHeights(): GroundMesh;
  19773. private _getFacetAt;
  19774. private _initHeightQuads;
  19775. private _computeHeightQuads;
  19776. /**
  19777. * Serializes this ground mesh
  19778. * @param serializationObject object to write serialization to
  19779. */
  19780. serialize(serializationObject: any): void;
  19781. /**
  19782. * Parses a serialized ground mesh
  19783. * @param parsedMesh the serialized mesh
  19784. * @param scene the scene to create the ground mesh in
  19785. * @returns the created ground mesh
  19786. */
  19787. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19788. }
  19789. }
  19790. declare module "babylonjs/Physics/physicsJoint" {
  19791. import { Vector3 } from "babylonjs/Maths/math";
  19792. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19793. /**
  19794. * Interface for Physics-Joint data
  19795. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19796. */
  19797. export interface PhysicsJointData {
  19798. /**
  19799. * The main pivot of the joint
  19800. */
  19801. mainPivot?: Vector3;
  19802. /**
  19803. * The connected pivot of the joint
  19804. */
  19805. connectedPivot?: Vector3;
  19806. /**
  19807. * The main axis of the joint
  19808. */
  19809. mainAxis?: Vector3;
  19810. /**
  19811. * The connected axis of the joint
  19812. */
  19813. connectedAxis?: Vector3;
  19814. /**
  19815. * The collision of the joint
  19816. */
  19817. collision?: boolean;
  19818. /**
  19819. * Native Oimo/Cannon/Energy data
  19820. */
  19821. nativeParams?: any;
  19822. }
  19823. /**
  19824. * This is a holder class for the physics joint created by the physics plugin
  19825. * It holds a set of functions to control the underlying joint
  19826. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19827. */
  19828. export class PhysicsJoint {
  19829. /**
  19830. * The type of the physics joint
  19831. */
  19832. type: number;
  19833. /**
  19834. * The data for the physics joint
  19835. */
  19836. jointData: PhysicsJointData;
  19837. private _physicsJoint;
  19838. protected _physicsPlugin: IPhysicsEnginePlugin;
  19839. /**
  19840. * Initializes the physics joint
  19841. * @param type The type of the physics joint
  19842. * @param jointData The data for the physics joint
  19843. */
  19844. constructor(
  19845. /**
  19846. * The type of the physics joint
  19847. */
  19848. type: number,
  19849. /**
  19850. * The data for the physics joint
  19851. */
  19852. jointData: PhysicsJointData);
  19853. /**
  19854. * Gets the physics joint
  19855. */
  19856. /**
  19857. * Sets the physics joint
  19858. */
  19859. physicsJoint: any;
  19860. /**
  19861. * Sets the physics plugin
  19862. */
  19863. physicsPlugin: IPhysicsEnginePlugin;
  19864. /**
  19865. * Execute a function that is physics-plugin specific.
  19866. * @param {Function} func the function that will be executed.
  19867. * It accepts two parameters: the physics world and the physics joint
  19868. */
  19869. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19870. /**
  19871. * Distance-Joint type
  19872. */
  19873. static DistanceJoint: number;
  19874. /**
  19875. * Hinge-Joint type
  19876. */
  19877. static HingeJoint: number;
  19878. /**
  19879. * Ball-and-Socket joint type
  19880. */
  19881. static BallAndSocketJoint: number;
  19882. /**
  19883. * Wheel-Joint type
  19884. */
  19885. static WheelJoint: number;
  19886. /**
  19887. * Slider-Joint type
  19888. */
  19889. static SliderJoint: number;
  19890. /**
  19891. * Prismatic-Joint type
  19892. */
  19893. static PrismaticJoint: number;
  19894. /**
  19895. * Universal-Joint type
  19896. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19897. */
  19898. static UniversalJoint: number;
  19899. /**
  19900. * Hinge-Joint 2 type
  19901. */
  19902. static Hinge2Joint: number;
  19903. /**
  19904. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19905. */
  19906. static PointToPointJoint: number;
  19907. /**
  19908. * Spring-Joint type
  19909. */
  19910. static SpringJoint: number;
  19911. /**
  19912. * Lock-Joint type
  19913. */
  19914. static LockJoint: number;
  19915. }
  19916. /**
  19917. * A class representing a physics distance joint
  19918. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19919. */
  19920. export class DistanceJoint extends PhysicsJoint {
  19921. /**
  19922. *
  19923. * @param jointData The data for the Distance-Joint
  19924. */
  19925. constructor(jointData: DistanceJointData);
  19926. /**
  19927. * Update the predefined distance.
  19928. * @param maxDistance The maximum preferred distance
  19929. * @param minDistance The minimum preferred distance
  19930. */
  19931. updateDistance(maxDistance: number, minDistance?: number): void;
  19932. }
  19933. /**
  19934. * Represents a Motor-Enabled Joint
  19935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19936. */
  19937. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19938. /**
  19939. * Initializes the Motor-Enabled Joint
  19940. * @param type The type of the joint
  19941. * @param jointData The physica joint data for the joint
  19942. */
  19943. constructor(type: number, jointData: PhysicsJointData);
  19944. /**
  19945. * Set the motor values.
  19946. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19947. * @param force the force to apply
  19948. * @param maxForce max force for this motor.
  19949. */
  19950. setMotor(force?: number, maxForce?: number): void;
  19951. /**
  19952. * Set the motor's limits.
  19953. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19954. * @param upperLimit The upper limit of the motor
  19955. * @param lowerLimit The lower limit of the motor
  19956. */
  19957. setLimit(upperLimit: number, lowerLimit?: number): void;
  19958. }
  19959. /**
  19960. * This class represents a single physics Hinge-Joint
  19961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19962. */
  19963. export class HingeJoint extends MotorEnabledJoint {
  19964. /**
  19965. * Initializes the Hinge-Joint
  19966. * @param jointData The joint data for the Hinge-Joint
  19967. */
  19968. constructor(jointData: PhysicsJointData);
  19969. /**
  19970. * Set the motor values.
  19971. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19972. * @param {number} force the force to apply
  19973. * @param {number} maxForce max force for this motor.
  19974. */
  19975. setMotor(force?: number, maxForce?: number): void;
  19976. /**
  19977. * Set the motor's limits.
  19978. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19979. * @param upperLimit The upper limit of the motor
  19980. * @param lowerLimit The lower limit of the motor
  19981. */
  19982. setLimit(upperLimit: number, lowerLimit?: number): void;
  19983. }
  19984. /**
  19985. * This class represents a dual hinge physics joint (same as wheel joint)
  19986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19987. */
  19988. export class Hinge2Joint extends MotorEnabledJoint {
  19989. /**
  19990. * Initializes the Hinge2-Joint
  19991. * @param jointData The joint data for the Hinge2-Joint
  19992. */
  19993. constructor(jointData: PhysicsJointData);
  19994. /**
  19995. * Set the motor values.
  19996. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19997. * @param {number} targetSpeed the speed the motor is to reach
  19998. * @param {number} maxForce max force for this motor.
  19999. * @param {motorIndex} the motor's index, 0 or 1.
  20000. */
  20001. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  20002. /**
  20003. * Set the motor limits.
  20004. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20005. * @param {number} upperLimit the upper limit
  20006. * @param {number} lowerLimit lower limit
  20007. * @param {motorIndex} the motor's index, 0 or 1.
  20008. */
  20009. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20010. }
  20011. /**
  20012. * Interface for a motor enabled joint
  20013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20014. */
  20015. export interface IMotorEnabledJoint {
  20016. /**
  20017. * Physics joint
  20018. */
  20019. physicsJoint: any;
  20020. /**
  20021. * Sets the motor of the motor-enabled joint
  20022. * @param force The force of the motor
  20023. * @param maxForce The maximum force of the motor
  20024. * @param motorIndex The index of the motor
  20025. */
  20026. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20027. /**
  20028. * Sets the limit of the motor
  20029. * @param upperLimit The upper limit of the motor
  20030. * @param lowerLimit The lower limit of the motor
  20031. * @param motorIndex The index of the motor
  20032. */
  20033. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20034. }
  20035. /**
  20036. * Joint data for a Distance-Joint
  20037. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20038. */
  20039. export interface DistanceJointData extends PhysicsJointData {
  20040. /**
  20041. * Max distance the 2 joint objects can be apart
  20042. */
  20043. maxDistance: number;
  20044. }
  20045. /**
  20046. * Joint data from a spring joint
  20047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20048. */
  20049. export interface SpringJointData extends PhysicsJointData {
  20050. /**
  20051. * Length of the spring
  20052. */
  20053. length: number;
  20054. /**
  20055. * Stiffness of the spring
  20056. */
  20057. stiffness: number;
  20058. /**
  20059. * Damping of the spring
  20060. */
  20061. damping: number;
  20062. /** this callback will be called when applying the force to the impostors. */
  20063. forceApplicationCallback: () => void;
  20064. }
  20065. }
  20066. declare module "babylonjs/Physics/physicsRaycastResult" {
  20067. import { Vector3 } from "babylonjs/Maths/math";
  20068. /**
  20069. * Holds the data for the raycast result
  20070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20071. */
  20072. export class PhysicsRaycastResult {
  20073. private _hasHit;
  20074. private _hitDistance;
  20075. private _hitNormalWorld;
  20076. private _hitPointWorld;
  20077. private _rayFromWorld;
  20078. private _rayToWorld;
  20079. /**
  20080. * Gets if there was a hit
  20081. */
  20082. readonly hasHit: boolean;
  20083. /**
  20084. * Gets the distance from the hit
  20085. */
  20086. readonly hitDistance: number;
  20087. /**
  20088. * Gets the hit normal/direction in the world
  20089. */
  20090. readonly hitNormalWorld: Vector3;
  20091. /**
  20092. * Gets the hit point in the world
  20093. */
  20094. readonly hitPointWorld: Vector3;
  20095. /**
  20096. * Gets the ray "start point" of the ray in the world
  20097. */
  20098. readonly rayFromWorld: Vector3;
  20099. /**
  20100. * Gets the ray "end point" of the ray in the world
  20101. */
  20102. readonly rayToWorld: Vector3;
  20103. /**
  20104. * Sets the hit data (normal & point in world space)
  20105. * @param hitNormalWorld defines the normal in world space
  20106. * @param hitPointWorld defines the point in world space
  20107. */
  20108. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20109. /**
  20110. * Sets the distance from the start point to the hit point
  20111. * @param distance
  20112. */
  20113. setHitDistance(distance: number): void;
  20114. /**
  20115. * Calculates the distance manually
  20116. */
  20117. calculateHitDistance(): void;
  20118. /**
  20119. * Resets all the values to default
  20120. * @param from The from point on world space
  20121. * @param to The to point on world space
  20122. */
  20123. reset(from?: Vector3, to?: Vector3): void;
  20124. }
  20125. /**
  20126. * Interface for the size containing width and height
  20127. */
  20128. interface IXYZ {
  20129. /**
  20130. * X
  20131. */
  20132. x: number;
  20133. /**
  20134. * Y
  20135. */
  20136. y: number;
  20137. /**
  20138. * Z
  20139. */
  20140. z: number;
  20141. }
  20142. }
  20143. declare module "babylonjs/Physics/IPhysicsEngine" {
  20144. import { Nullable } from "babylonjs/types";
  20145. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20147. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20148. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20149. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20150. /**
  20151. * Interface used to describe a physics joint
  20152. */
  20153. export interface PhysicsImpostorJoint {
  20154. /** Defines the main impostor to which the joint is linked */
  20155. mainImpostor: PhysicsImpostor;
  20156. /** Defines the impostor that is connected to the main impostor using this joint */
  20157. connectedImpostor: PhysicsImpostor;
  20158. /** Defines the joint itself */
  20159. joint: PhysicsJoint;
  20160. }
  20161. /** @hidden */
  20162. export interface IPhysicsEnginePlugin {
  20163. world: any;
  20164. name: string;
  20165. setGravity(gravity: Vector3): void;
  20166. setTimeStep(timeStep: number): void;
  20167. getTimeStep(): number;
  20168. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20169. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20170. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20171. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20172. removePhysicsBody(impostor: PhysicsImpostor): void;
  20173. generateJoint(joint: PhysicsImpostorJoint): void;
  20174. removeJoint(joint: PhysicsImpostorJoint): void;
  20175. isSupported(): boolean;
  20176. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20177. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20178. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20179. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20180. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20181. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20182. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20183. getBodyMass(impostor: PhysicsImpostor): number;
  20184. getBodyFriction(impostor: PhysicsImpostor): number;
  20185. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20186. getBodyRestitution(impostor: PhysicsImpostor): number;
  20187. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20188. getBodyPressure?(impostor: PhysicsImpostor): number;
  20189. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20190. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20191. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20192. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20193. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20194. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20195. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20196. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20197. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20198. sleepBody(impostor: PhysicsImpostor): void;
  20199. wakeUpBody(impostor: PhysicsImpostor): void;
  20200. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20201. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20202. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20203. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20204. getRadius(impostor: PhysicsImpostor): number;
  20205. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20206. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20207. dispose(): void;
  20208. }
  20209. /**
  20210. * Interface used to define a physics engine
  20211. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20212. */
  20213. export interface IPhysicsEngine {
  20214. /**
  20215. * Gets the gravity vector used by the simulation
  20216. */
  20217. gravity: Vector3;
  20218. /**
  20219. * Sets the gravity vector used by the simulation
  20220. * @param gravity defines the gravity vector to use
  20221. */
  20222. setGravity(gravity: Vector3): void;
  20223. /**
  20224. * Set the time step of the physics engine.
  20225. * Default is 1/60.
  20226. * To slow it down, enter 1/600 for example.
  20227. * To speed it up, 1/30
  20228. * @param newTimeStep the new timestep to apply to this world.
  20229. */
  20230. setTimeStep(newTimeStep: number): void;
  20231. /**
  20232. * Get the time step of the physics engine.
  20233. * @returns the current time step
  20234. */
  20235. getTimeStep(): number;
  20236. /**
  20237. * Release all resources
  20238. */
  20239. dispose(): void;
  20240. /**
  20241. * Gets the name of the current physics plugin
  20242. * @returns the name of the plugin
  20243. */
  20244. getPhysicsPluginName(): string;
  20245. /**
  20246. * Adding a new impostor for the impostor tracking.
  20247. * This will be done by the impostor itself.
  20248. * @param impostor the impostor to add
  20249. */
  20250. addImpostor(impostor: PhysicsImpostor): void;
  20251. /**
  20252. * Remove an impostor from the engine.
  20253. * This impostor and its mesh will not longer be updated by the physics engine.
  20254. * @param impostor the impostor to remove
  20255. */
  20256. removeImpostor(impostor: PhysicsImpostor): void;
  20257. /**
  20258. * Add a joint to the physics engine
  20259. * @param mainImpostor defines the main impostor to which the joint is added.
  20260. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20261. * @param joint defines the joint that will connect both impostors.
  20262. */
  20263. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20264. /**
  20265. * Removes a joint from the simulation
  20266. * @param mainImpostor defines the impostor used with the joint
  20267. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20268. * @param joint defines the joint to remove
  20269. */
  20270. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20271. /**
  20272. * Gets the current plugin used to run the simulation
  20273. * @returns current plugin
  20274. */
  20275. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20276. /**
  20277. * Gets the list of physic impostors
  20278. * @returns an array of PhysicsImpostor
  20279. */
  20280. getImpostors(): Array<PhysicsImpostor>;
  20281. /**
  20282. * Gets the impostor for a physics enabled object
  20283. * @param object defines the object impersonated by the impostor
  20284. * @returns the PhysicsImpostor or null if not found
  20285. */
  20286. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20287. /**
  20288. * Gets the impostor for a physics body object
  20289. * @param body defines physics body used by the impostor
  20290. * @returns the PhysicsImpostor or null if not found
  20291. */
  20292. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20293. /**
  20294. * Does a raycast in the physics world
  20295. * @param from when should the ray start?
  20296. * @param to when should the ray end?
  20297. * @returns PhysicsRaycastResult
  20298. */
  20299. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20300. /**
  20301. * Called by the scene. No need to call it.
  20302. * @param delta defines the timespam between frames
  20303. */
  20304. _step(delta: number): void;
  20305. }
  20306. }
  20307. declare module "babylonjs/Physics/physicsImpostor" {
  20308. import { Nullable, IndicesArray } from "babylonjs/types";
  20309. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20310. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20312. import { Scene } from "babylonjs/scene";
  20313. import { Bone } from "babylonjs/Bones/bone";
  20314. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20315. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20316. /**
  20317. * The interface for the physics imposter parameters
  20318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20319. */
  20320. export interface PhysicsImpostorParameters {
  20321. /**
  20322. * The mass of the physics imposter
  20323. */
  20324. mass: number;
  20325. /**
  20326. * The friction of the physics imposter
  20327. */
  20328. friction?: number;
  20329. /**
  20330. * The coefficient of restitution of the physics imposter
  20331. */
  20332. restitution?: number;
  20333. /**
  20334. * The native options of the physics imposter
  20335. */
  20336. nativeOptions?: any;
  20337. /**
  20338. * Specifies if the parent should be ignored
  20339. */
  20340. ignoreParent?: boolean;
  20341. /**
  20342. * Specifies if bi-directional transformations should be disabled
  20343. */
  20344. disableBidirectionalTransformation?: boolean;
  20345. /**
  20346. * The pressure inside the physics imposter, soft object only
  20347. */
  20348. pressure?: number;
  20349. /**
  20350. * The stiffness the physics imposter, soft object only
  20351. */
  20352. stiffness?: number;
  20353. /**
  20354. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20355. */
  20356. velocityIterations?: number;
  20357. /**
  20358. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20359. */
  20360. positionIterations?: number;
  20361. /**
  20362. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20363. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20364. * Add to fix multiple points
  20365. */
  20366. fixedPoints?: number;
  20367. /**
  20368. * The collision margin around a soft object
  20369. */
  20370. margin?: number;
  20371. /**
  20372. * The collision margin around a soft object
  20373. */
  20374. damping?: number;
  20375. /**
  20376. * The path for a rope based on an extrusion
  20377. */
  20378. path?: any;
  20379. /**
  20380. * The shape of an extrusion used for a rope based on an extrusion
  20381. */
  20382. shape?: any;
  20383. }
  20384. /**
  20385. * Interface for a physics-enabled object
  20386. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20387. */
  20388. export interface IPhysicsEnabledObject {
  20389. /**
  20390. * The position of the physics-enabled object
  20391. */
  20392. position: Vector3;
  20393. /**
  20394. * The rotation of the physics-enabled object
  20395. */
  20396. rotationQuaternion: Nullable<Quaternion>;
  20397. /**
  20398. * The scale of the physics-enabled object
  20399. */
  20400. scaling: Vector3;
  20401. /**
  20402. * The rotation of the physics-enabled object
  20403. */
  20404. rotation?: Vector3;
  20405. /**
  20406. * The parent of the physics-enabled object
  20407. */
  20408. parent?: any;
  20409. /**
  20410. * The bounding info of the physics-enabled object
  20411. * @returns The bounding info of the physics-enabled object
  20412. */
  20413. getBoundingInfo(): BoundingInfo;
  20414. /**
  20415. * Computes the world matrix
  20416. * @param force Specifies if the world matrix should be computed by force
  20417. * @returns A world matrix
  20418. */
  20419. computeWorldMatrix(force: boolean): Matrix;
  20420. /**
  20421. * Gets the world matrix
  20422. * @returns A world matrix
  20423. */
  20424. getWorldMatrix?(): Matrix;
  20425. /**
  20426. * Gets the child meshes
  20427. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20428. * @returns An array of abstract meshes
  20429. */
  20430. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20431. /**
  20432. * Gets the vertex data
  20433. * @param kind The type of vertex data
  20434. * @returns A nullable array of numbers, or a float32 array
  20435. */
  20436. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20437. /**
  20438. * Gets the indices from the mesh
  20439. * @returns A nullable array of index arrays
  20440. */
  20441. getIndices?(): Nullable<IndicesArray>;
  20442. /**
  20443. * Gets the scene from the mesh
  20444. * @returns the indices array or null
  20445. */
  20446. getScene?(): Scene;
  20447. /**
  20448. * Gets the absolute position from the mesh
  20449. * @returns the absolute position
  20450. */
  20451. getAbsolutePosition(): Vector3;
  20452. /**
  20453. * Gets the absolute pivot point from the mesh
  20454. * @returns the absolute pivot point
  20455. */
  20456. getAbsolutePivotPoint(): Vector3;
  20457. /**
  20458. * Rotates the mesh
  20459. * @param axis The axis of rotation
  20460. * @param amount The amount of rotation
  20461. * @param space The space of the rotation
  20462. * @returns The rotation transform node
  20463. */
  20464. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20465. /**
  20466. * Translates the mesh
  20467. * @param axis The axis of translation
  20468. * @param distance The distance of translation
  20469. * @param space The space of the translation
  20470. * @returns The transform node
  20471. */
  20472. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20473. /**
  20474. * Sets the absolute position of the mesh
  20475. * @param absolutePosition The absolute position of the mesh
  20476. * @returns The transform node
  20477. */
  20478. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20479. /**
  20480. * Gets the class name of the mesh
  20481. * @returns The class name
  20482. */
  20483. getClassName(): string;
  20484. }
  20485. /**
  20486. * Represents a physics imposter
  20487. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20488. */
  20489. export class PhysicsImpostor {
  20490. /**
  20491. * The physics-enabled object used as the physics imposter
  20492. */
  20493. object: IPhysicsEnabledObject;
  20494. /**
  20495. * The type of the physics imposter
  20496. */
  20497. type: number;
  20498. private _options;
  20499. private _scene?;
  20500. /**
  20501. * The default object size of the imposter
  20502. */
  20503. static DEFAULT_OBJECT_SIZE: Vector3;
  20504. /**
  20505. * The identity quaternion of the imposter
  20506. */
  20507. static IDENTITY_QUATERNION: Quaternion;
  20508. /** @hidden */
  20509. _pluginData: any;
  20510. private _physicsEngine;
  20511. private _physicsBody;
  20512. private _bodyUpdateRequired;
  20513. private _onBeforePhysicsStepCallbacks;
  20514. private _onAfterPhysicsStepCallbacks;
  20515. /** @hidden */
  20516. _onPhysicsCollideCallbacks: Array<{
  20517. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20518. otherImpostors: Array<PhysicsImpostor>;
  20519. }>;
  20520. private _deltaPosition;
  20521. private _deltaRotation;
  20522. private _deltaRotationConjugated;
  20523. /** hidden */
  20524. _isFromLine: boolean;
  20525. private _parent;
  20526. private _isDisposed;
  20527. private static _tmpVecs;
  20528. private static _tmpQuat;
  20529. /**
  20530. * Specifies if the physics imposter is disposed
  20531. */
  20532. readonly isDisposed: boolean;
  20533. /**
  20534. * Gets the mass of the physics imposter
  20535. */
  20536. mass: number;
  20537. /**
  20538. * Gets the coefficient of friction
  20539. */
  20540. /**
  20541. * Sets the coefficient of friction
  20542. */
  20543. friction: number;
  20544. /**
  20545. * Gets the coefficient of restitution
  20546. */
  20547. /**
  20548. * Sets the coefficient of restitution
  20549. */
  20550. restitution: number;
  20551. /**
  20552. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20553. */
  20554. /**
  20555. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20556. */
  20557. pressure: number;
  20558. /**
  20559. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20560. */
  20561. /**
  20562. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20563. */
  20564. stiffness: number;
  20565. /**
  20566. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20567. */
  20568. /**
  20569. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20570. */
  20571. velocityIterations: number;
  20572. /**
  20573. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20574. */
  20575. /**
  20576. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20577. */
  20578. positionIterations: number;
  20579. /**
  20580. * The unique id of the physics imposter
  20581. * set by the physics engine when adding this impostor to the array
  20582. */
  20583. uniqueId: number;
  20584. /**
  20585. * @hidden
  20586. */
  20587. soft: boolean;
  20588. /**
  20589. * @hidden
  20590. */
  20591. segments: number;
  20592. private _joints;
  20593. /**
  20594. * Initializes the physics imposter
  20595. * @param object The physics-enabled object used as the physics imposter
  20596. * @param type The type of the physics imposter
  20597. * @param _options The options for the physics imposter
  20598. * @param _scene The Babylon scene
  20599. */
  20600. constructor(
  20601. /**
  20602. * The physics-enabled object used as the physics imposter
  20603. */
  20604. object: IPhysicsEnabledObject,
  20605. /**
  20606. * The type of the physics imposter
  20607. */
  20608. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20609. /**
  20610. * This function will completly initialize this impostor.
  20611. * It will create a new body - but only if this mesh has no parent.
  20612. * If it has, this impostor will not be used other than to define the impostor
  20613. * of the child mesh.
  20614. * @hidden
  20615. */
  20616. _init(): void;
  20617. private _getPhysicsParent;
  20618. /**
  20619. * Should a new body be generated.
  20620. * @returns boolean specifying if body initialization is required
  20621. */
  20622. isBodyInitRequired(): boolean;
  20623. /**
  20624. * Sets the updated scaling
  20625. * @param updated Specifies if the scaling is updated
  20626. */
  20627. setScalingUpdated(): void;
  20628. /**
  20629. * Force a regeneration of this or the parent's impostor's body.
  20630. * Use under cautious - This will remove all joints already implemented.
  20631. */
  20632. forceUpdate(): void;
  20633. /**
  20634. * Gets the body that holds this impostor. Either its own, or its parent.
  20635. */
  20636. /**
  20637. * Set the physics body. Used mainly by the physics engine/plugin
  20638. */
  20639. physicsBody: any;
  20640. /**
  20641. * Get the parent of the physics imposter
  20642. * @returns Physics imposter or null
  20643. */
  20644. /**
  20645. * Sets the parent of the physics imposter
  20646. */
  20647. parent: Nullable<PhysicsImpostor>;
  20648. /**
  20649. * Resets the update flags
  20650. */
  20651. resetUpdateFlags(): void;
  20652. /**
  20653. * Gets the object extend size
  20654. * @returns the object extend size
  20655. */
  20656. getObjectExtendSize(): Vector3;
  20657. /**
  20658. * Gets the object center
  20659. * @returns The object center
  20660. */
  20661. getObjectCenter(): Vector3;
  20662. /**
  20663. * Get a specific parametes from the options parameter
  20664. * @param paramName The object parameter name
  20665. * @returns The object parameter
  20666. */
  20667. getParam(paramName: string): any;
  20668. /**
  20669. * Sets a specific parameter in the options given to the physics plugin
  20670. * @param paramName The parameter name
  20671. * @param value The value of the parameter
  20672. */
  20673. setParam(paramName: string, value: number): void;
  20674. /**
  20675. * Specifically change the body's mass option. Won't recreate the physics body object
  20676. * @param mass The mass of the physics imposter
  20677. */
  20678. setMass(mass: number): void;
  20679. /**
  20680. * Gets the linear velocity
  20681. * @returns linear velocity or null
  20682. */
  20683. getLinearVelocity(): Nullable<Vector3>;
  20684. /**
  20685. * Sets the linear velocity
  20686. * @param velocity linear velocity or null
  20687. */
  20688. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20689. /**
  20690. * Gets the angular velocity
  20691. * @returns angular velocity or null
  20692. */
  20693. getAngularVelocity(): Nullable<Vector3>;
  20694. /**
  20695. * Sets the angular velocity
  20696. * @param velocity The velocity or null
  20697. */
  20698. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20699. /**
  20700. * Execute a function with the physics plugin native code
  20701. * Provide a function the will have two variables - the world object and the physics body object
  20702. * @param func The function to execute with the physics plugin native code
  20703. */
  20704. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20705. /**
  20706. * Register a function that will be executed before the physics world is stepping forward
  20707. * @param func The function to execute before the physics world is stepped forward
  20708. */
  20709. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20710. /**
  20711. * Unregister a function that will be executed before the physics world is stepping forward
  20712. * @param func The function to execute before the physics world is stepped forward
  20713. */
  20714. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20715. /**
  20716. * Register a function that will be executed after the physics step
  20717. * @param func The function to execute after physics step
  20718. */
  20719. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20720. /**
  20721. * Unregisters a function that will be executed after the physics step
  20722. * @param func The function to execute after physics step
  20723. */
  20724. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20725. /**
  20726. * register a function that will be executed when this impostor collides against a different body
  20727. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20728. * @param func Callback that is executed on collision
  20729. */
  20730. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20731. /**
  20732. * Unregisters the physics imposter on contact
  20733. * @param collideAgainst The physics object to collide against
  20734. * @param func Callback to execute on collision
  20735. */
  20736. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20737. private _tmpQuat;
  20738. private _tmpQuat2;
  20739. /**
  20740. * Get the parent rotation
  20741. * @returns The parent rotation
  20742. */
  20743. getParentsRotation(): Quaternion;
  20744. /**
  20745. * this function is executed by the physics engine.
  20746. */
  20747. beforeStep: () => void;
  20748. /**
  20749. * this function is executed by the physics engine
  20750. */
  20751. afterStep: () => void;
  20752. /**
  20753. * Legacy collision detection event support
  20754. */
  20755. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20756. /**
  20757. * event and body object due to cannon's event-based architecture.
  20758. */
  20759. onCollide: (e: {
  20760. body: any;
  20761. }) => void;
  20762. /**
  20763. * Apply a force
  20764. * @param force The force to apply
  20765. * @param contactPoint The contact point for the force
  20766. * @returns The physics imposter
  20767. */
  20768. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20769. /**
  20770. * Apply an impulse
  20771. * @param force The impulse force
  20772. * @param contactPoint The contact point for the impulse force
  20773. * @returns The physics imposter
  20774. */
  20775. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20776. /**
  20777. * A help function to create a joint
  20778. * @param otherImpostor A physics imposter used to create a joint
  20779. * @param jointType The type of joint
  20780. * @param jointData The data for the joint
  20781. * @returns The physics imposter
  20782. */
  20783. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20784. /**
  20785. * Add a joint to this impostor with a different impostor
  20786. * @param otherImpostor A physics imposter used to add a joint
  20787. * @param joint The joint to add
  20788. * @returns The physics imposter
  20789. */
  20790. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20791. /**
  20792. * Add an anchor to a cloth impostor
  20793. * @param otherImpostor rigid impostor to anchor to
  20794. * @param width ratio across width from 0 to 1
  20795. * @param height ratio up height from 0 to 1
  20796. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20797. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20798. * @returns impostor the soft imposter
  20799. */
  20800. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20801. /**
  20802. * Add a hook to a rope impostor
  20803. * @param otherImpostor rigid impostor to anchor to
  20804. * @param length ratio across rope from 0 to 1
  20805. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20806. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20807. * @returns impostor the rope imposter
  20808. */
  20809. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20810. /**
  20811. * Will keep this body still, in a sleep mode.
  20812. * @returns the physics imposter
  20813. */
  20814. sleep(): PhysicsImpostor;
  20815. /**
  20816. * Wake the body up.
  20817. * @returns The physics imposter
  20818. */
  20819. wakeUp(): PhysicsImpostor;
  20820. /**
  20821. * Clones the physics imposter
  20822. * @param newObject The physics imposter clones to this physics-enabled object
  20823. * @returns A nullable physics imposter
  20824. */
  20825. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20826. /**
  20827. * Disposes the physics imposter
  20828. */
  20829. dispose(): void;
  20830. /**
  20831. * Sets the delta position
  20832. * @param position The delta position amount
  20833. */
  20834. setDeltaPosition(position: Vector3): void;
  20835. /**
  20836. * Sets the delta rotation
  20837. * @param rotation The delta rotation amount
  20838. */
  20839. setDeltaRotation(rotation: Quaternion): void;
  20840. /**
  20841. * Gets the box size of the physics imposter and stores the result in the input parameter
  20842. * @param result Stores the box size
  20843. * @returns The physics imposter
  20844. */
  20845. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20846. /**
  20847. * Gets the radius of the physics imposter
  20848. * @returns Radius of the physics imposter
  20849. */
  20850. getRadius(): number;
  20851. /**
  20852. * Sync a bone with this impostor
  20853. * @param bone The bone to sync to the impostor.
  20854. * @param boneMesh The mesh that the bone is influencing.
  20855. * @param jointPivot The pivot of the joint / bone in local space.
  20856. * @param distToJoint Optional distance from the impostor to the joint.
  20857. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20858. */
  20859. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20860. /**
  20861. * Sync impostor to a bone
  20862. * @param bone The bone that the impostor will be synced to.
  20863. * @param boneMesh The mesh that the bone is influencing.
  20864. * @param jointPivot The pivot of the joint / bone in local space.
  20865. * @param distToJoint Optional distance from the impostor to the joint.
  20866. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20867. * @param boneAxis Optional vector3 axis the bone is aligned with
  20868. */
  20869. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20870. /**
  20871. * No-Imposter type
  20872. */
  20873. static NoImpostor: number;
  20874. /**
  20875. * Sphere-Imposter type
  20876. */
  20877. static SphereImpostor: number;
  20878. /**
  20879. * Box-Imposter type
  20880. */
  20881. static BoxImpostor: number;
  20882. /**
  20883. * Plane-Imposter type
  20884. */
  20885. static PlaneImpostor: number;
  20886. /**
  20887. * Mesh-imposter type
  20888. */
  20889. static MeshImpostor: number;
  20890. /**
  20891. * Cylinder-Imposter type
  20892. */
  20893. static CylinderImpostor: number;
  20894. /**
  20895. * Particle-Imposter type
  20896. */
  20897. static ParticleImpostor: number;
  20898. /**
  20899. * Heightmap-Imposter type
  20900. */
  20901. static HeightmapImpostor: number;
  20902. /**
  20903. * ConvexHull-Impostor type (Ammo.js plugin only)
  20904. */
  20905. static ConvexHullImpostor: number;
  20906. /**
  20907. * Rope-Imposter type
  20908. */
  20909. static RopeImpostor: number;
  20910. /**
  20911. * Cloth-Imposter type
  20912. */
  20913. static ClothImpostor: number;
  20914. /**
  20915. * Softbody-Imposter type
  20916. */
  20917. static SoftbodyImpostor: number;
  20918. }
  20919. }
  20920. declare module "babylonjs/Meshes/mesh" {
  20921. import { Observable } from "babylonjs/Misc/observable";
  20922. import { IAnimatable } from "babylonjs/Misc/tools";
  20923. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20924. import { Camera } from "babylonjs/Cameras/camera";
  20925. import { Scene } from "babylonjs/scene";
  20926. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20927. import { Engine } from "babylonjs/Engines/engine";
  20928. import { Node } from "babylonjs/node";
  20929. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20930. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20931. import { Buffer } from "babylonjs/Meshes/buffer";
  20932. import { Geometry } from "babylonjs/Meshes/geometry";
  20933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20934. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20935. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20936. import { Effect } from "babylonjs/Materials/effect";
  20937. import { Material } from "babylonjs/Materials/material";
  20938. import { Skeleton } from "babylonjs/Bones/skeleton";
  20939. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20940. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20941. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20942. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20943. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20944. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20945. /**
  20946. * Class used to represent a specific level of detail of a mesh
  20947. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20948. */
  20949. export class MeshLODLevel {
  20950. /** Defines the distance where this level should star being displayed */
  20951. distance: number;
  20952. /** Defines the mesh to use to render this level */
  20953. mesh: Nullable<Mesh>;
  20954. /**
  20955. * Creates a new LOD level
  20956. * @param distance defines the distance where this level should star being displayed
  20957. * @param mesh defines the mesh to use to render this level
  20958. */
  20959. constructor(
  20960. /** Defines the distance where this level should star being displayed */
  20961. distance: number,
  20962. /** Defines the mesh to use to render this level */
  20963. mesh: Nullable<Mesh>);
  20964. }
  20965. /**
  20966. * @hidden
  20967. **/
  20968. export class _CreationDataStorage {
  20969. closePath?: boolean;
  20970. closeArray?: boolean;
  20971. idx: number[];
  20972. dashSize: number;
  20973. gapSize: number;
  20974. path3D: Path3D;
  20975. pathArray: Vector3[][];
  20976. arc: number;
  20977. radius: number;
  20978. cap: number;
  20979. tessellation: number;
  20980. }
  20981. /**
  20982. * @hidden
  20983. **/
  20984. class _InstanceDataStorage {
  20985. visibleInstances: any;
  20986. renderIdForInstances: number[];
  20987. batchCache: _InstancesBatch;
  20988. instancesBufferSize: number;
  20989. instancesBuffer: Nullable<Buffer>;
  20990. instancesData: Float32Array;
  20991. overridenInstanceCount: number;
  20992. }
  20993. /**
  20994. * @hidden
  20995. **/
  20996. export class _InstancesBatch {
  20997. mustReturn: boolean;
  20998. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20999. renderSelf: boolean[];
  21000. }
  21001. /**
  21002. * Class used to represent renderable models
  21003. */
  21004. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21005. /**
  21006. * Mesh side orientation : usually the external or front surface
  21007. */
  21008. static readonly FRONTSIDE: number;
  21009. /**
  21010. * Mesh side orientation : usually the internal or back surface
  21011. */
  21012. static readonly BACKSIDE: number;
  21013. /**
  21014. * Mesh side orientation : both internal and external or front and back surfaces
  21015. */
  21016. static readonly DOUBLESIDE: number;
  21017. /**
  21018. * Mesh side orientation : by default, `FRONTSIDE`
  21019. */
  21020. static readonly DEFAULTSIDE: number;
  21021. /**
  21022. * Mesh cap setting : no cap
  21023. */
  21024. static readonly NO_CAP: number;
  21025. /**
  21026. * Mesh cap setting : one cap at the beginning of the mesh
  21027. */
  21028. static readonly CAP_START: number;
  21029. /**
  21030. * Mesh cap setting : one cap at the end of the mesh
  21031. */
  21032. static readonly CAP_END: number;
  21033. /**
  21034. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21035. */
  21036. static readonly CAP_ALL: number;
  21037. /**
  21038. * Gets the default side orientation.
  21039. * @param orientation the orientation to value to attempt to get
  21040. * @returns the default orientation
  21041. * @hidden
  21042. */
  21043. static _GetDefaultSideOrientation(orientation?: number): number;
  21044. private _onBeforeRenderObservable;
  21045. private _onBeforeBindObservable;
  21046. private _onAfterRenderObservable;
  21047. private _onBeforeDrawObservable;
  21048. /**
  21049. * An event triggered before rendering the mesh
  21050. */
  21051. readonly onBeforeRenderObservable: Observable<Mesh>;
  21052. /**
  21053. * An event triggered before binding the mesh
  21054. */
  21055. readonly onBeforeBindObservable: Observable<Mesh>;
  21056. /**
  21057. * An event triggered after rendering the mesh
  21058. */
  21059. readonly onAfterRenderObservable: Observable<Mesh>;
  21060. /**
  21061. * An event triggered before drawing the mesh
  21062. */
  21063. readonly onBeforeDrawObservable: Observable<Mesh>;
  21064. private _onBeforeDrawObserver;
  21065. /**
  21066. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21067. */
  21068. onBeforeDraw: () => void;
  21069. /**
  21070. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21071. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21072. */
  21073. delayLoadState: number;
  21074. /**
  21075. * Gets the list of instances created from this mesh
  21076. * it is not supposed to be modified manually.
  21077. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21078. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21079. */
  21080. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21081. /**
  21082. * Gets the file containing delay loading data for this mesh
  21083. */
  21084. delayLoadingFile: string;
  21085. /** @hidden */
  21086. _binaryInfo: any;
  21087. private _LODLevels;
  21088. /**
  21089. * User defined function used to change how LOD level selection is done
  21090. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21091. */
  21092. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21093. private _morphTargetManager;
  21094. /**
  21095. * Gets or sets the morph target manager
  21096. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21097. */
  21098. morphTargetManager: Nullable<MorphTargetManager>;
  21099. /** @hidden */
  21100. _creationDataStorage: Nullable<_CreationDataStorage>;
  21101. /** @hidden */
  21102. _geometry: Nullable<Geometry>;
  21103. /** @hidden */
  21104. _delayInfo: Array<string>;
  21105. /** @hidden */
  21106. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21107. /** @hidden */
  21108. _instanceDataStorage: _InstanceDataStorage;
  21109. private _effectiveMaterial;
  21110. /** @hidden */
  21111. _shouldGenerateFlatShading: boolean;
  21112. private _preActivateId;
  21113. /** @hidden */
  21114. _originalBuilderSideOrientation: number;
  21115. /**
  21116. * Use this property to change the original side orientation defined at construction time
  21117. */
  21118. overrideMaterialSideOrientation: Nullable<number>;
  21119. private _areNormalsFrozen;
  21120. private _sourcePositions;
  21121. private _sourceNormals;
  21122. private _source;
  21123. private meshMap;
  21124. /**
  21125. * Gets the source mesh (the one used to clone this one from)
  21126. */
  21127. readonly source: Nullable<Mesh>;
  21128. /**
  21129. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21130. */
  21131. isUnIndexed: boolean;
  21132. /**
  21133. * @constructor
  21134. * @param name The value used by scene.getMeshByName() to do a lookup.
  21135. * @param scene The scene to add this mesh to.
  21136. * @param parent The parent of this mesh, if it has one
  21137. * @param source An optional Mesh from which geometry is shared, cloned.
  21138. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21139. * When false, achieved by calling a clone(), also passing False.
  21140. * This will make creation of children, recursive.
  21141. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21142. */
  21143. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21144. /**
  21145. * Gets the class name
  21146. * @returns the string "Mesh".
  21147. */
  21148. getClassName(): string;
  21149. /** @hidden */
  21150. readonly _isMesh: boolean;
  21151. /**
  21152. * Returns a description of this mesh
  21153. * @param fullDetails define if full details about this mesh must be used
  21154. * @returns a descriptive string representing this mesh
  21155. */
  21156. toString(fullDetails?: boolean): string;
  21157. /** @hidden */
  21158. _unBindEffect(): void;
  21159. /**
  21160. * Gets a boolean indicating if this mesh has LOD
  21161. */
  21162. readonly hasLODLevels: boolean;
  21163. /**
  21164. * Gets the list of MeshLODLevel associated with the current mesh
  21165. * @returns an array of MeshLODLevel
  21166. */
  21167. getLODLevels(): MeshLODLevel[];
  21168. private _sortLODLevels;
  21169. /**
  21170. * Add a mesh as LOD level triggered at the given distance.
  21171. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21172. * @param distance The distance from the center of the object to show this level
  21173. * @param mesh The mesh to be added as LOD level (can be null)
  21174. * @return This mesh (for chaining)
  21175. */
  21176. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21177. /**
  21178. * Returns the LOD level mesh at the passed distance or null if not found.
  21179. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21180. * @param distance The distance from the center of the object to show this level
  21181. * @returns a Mesh or `null`
  21182. */
  21183. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21184. /**
  21185. * Remove a mesh from the LOD array
  21186. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21187. * @param mesh defines the mesh to be removed
  21188. * @return This mesh (for chaining)
  21189. */
  21190. removeLODLevel(mesh: Mesh): Mesh;
  21191. /**
  21192. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21193. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21194. * @param camera defines the camera to use to compute distance
  21195. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21196. * @return This mesh (for chaining)
  21197. */
  21198. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21199. /**
  21200. * Gets the mesh internal Geometry object
  21201. */
  21202. readonly geometry: Nullable<Geometry>;
  21203. /**
  21204. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21205. * @returns the total number of vertices
  21206. */
  21207. getTotalVertices(): number;
  21208. /**
  21209. * Returns the content of an associated vertex buffer
  21210. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21211. * - VertexBuffer.PositionKind
  21212. * - VertexBuffer.UVKind
  21213. * - VertexBuffer.UV2Kind
  21214. * - VertexBuffer.UV3Kind
  21215. * - VertexBuffer.UV4Kind
  21216. * - VertexBuffer.UV5Kind
  21217. * - VertexBuffer.UV6Kind
  21218. * - VertexBuffer.ColorKind
  21219. * - VertexBuffer.MatricesIndicesKind
  21220. * - VertexBuffer.MatricesIndicesExtraKind
  21221. * - VertexBuffer.MatricesWeightsKind
  21222. * - VertexBuffer.MatricesWeightsExtraKind
  21223. * @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
  21224. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21225. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21226. */
  21227. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21228. /**
  21229. * Returns the mesh VertexBuffer object from the requested `kind`
  21230. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21231. * - VertexBuffer.PositionKind
  21232. * - VertexBuffer.UVKind
  21233. * - VertexBuffer.UV2Kind
  21234. * - VertexBuffer.UV3Kind
  21235. * - VertexBuffer.UV4Kind
  21236. * - VertexBuffer.UV5Kind
  21237. * - VertexBuffer.UV6Kind
  21238. * - VertexBuffer.ColorKind
  21239. * - VertexBuffer.MatricesIndicesKind
  21240. * - VertexBuffer.MatricesIndicesExtraKind
  21241. * - VertexBuffer.MatricesWeightsKind
  21242. * - VertexBuffer.MatricesWeightsExtraKind
  21243. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21244. */
  21245. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21246. /**
  21247. * Tests if a specific vertex buffer is associated with this mesh
  21248. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21249. * - VertexBuffer.PositionKind
  21250. * - VertexBuffer.UVKind
  21251. * - VertexBuffer.UV2Kind
  21252. * - VertexBuffer.UV3Kind
  21253. * - VertexBuffer.UV4Kind
  21254. * - VertexBuffer.UV5Kind
  21255. * - VertexBuffer.UV6Kind
  21256. * - VertexBuffer.ColorKind
  21257. * - VertexBuffer.MatricesIndicesKind
  21258. * - VertexBuffer.MatricesIndicesExtraKind
  21259. * - VertexBuffer.MatricesWeightsKind
  21260. * - VertexBuffer.MatricesWeightsExtraKind
  21261. * @returns a boolean
  21262. */
  21263. isVerticesDataPresent(kind: string): boolean;
  21264. /**
  21265. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21266. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21267. * - VertexBuffer.PositionKind
  21268. * - VertexBuffer.UVKind
  21269. * - VertexBuffer.UV2Kind
  21270. * - VertexBuffer.UV3Kind
  21271. * - VertexBuffer.UV4Kind
  21272. * - VertexBuffer.UV5Kind
  21273. * - VertexBuffer.UV6Kind
  21274. * - VertexBuffer.ColorKind
  21275. * - VertexBuffer.MatricesIndicesKind
  21276. * - VertexBuffer.MatricesIndicesExtraKind
  21277. * - VertexBuffer.MatricesWeightsKind
  21278. * - VertexBuffer.MatricesWeightsExtraKind
  21279. * @returns a boolean
  21280. */
  21281. isVertexBufferUpdatable(kind: string): boolean;
  21282. /**
  21283. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21284. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21285. * - VertexBuffer.PositionKind
  21286. * - VertexBuffer.UVKind
  21287. * - VertexBuffer.UV2Kind
  21288. * - VertexBuffer.UV3Kind
  21289. * - VertexBuffer.UV4Kind
  21290. * - VertexBuffer.UV5Kind
  21291. * - VertexBuffer.UV6Kind
  21292. * - VertexBuffer.ColorKind
  21293. * - VertexBuffer.MatricesIndicesKind
  21294. * - VertexBuffer.MatricesIndicesExtraKind
  21295. * - VertexBuffer.MatricesWeightsKind
  21296. * - VertexBuffer.MatricesWeightsExtraKind
  21297. * @returns an array of strings
  21298. */
  21299. getVerticesDataKinds(): string[];
  21300. /**
  21301. * Returns a positive integer : the total number of indices in this mesh geometry.
  21302. * @returns the numner of indices or zero if the mesh has no geometry.
  21303. */
  21304. getTotalIndices(): number;
  21305. /**
  21306. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21307. * @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.
  21308. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21309. * @returns the indices array or an empty array if the mesh has no geometry
  21310. */
  21311. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21312. readonly isBlocked: boolean;
  21313. /**
  21314. * Determine if the current mesh is ready to be rendered
  21315. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21316. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21317. * @returns true if all associated assets are ready (material, textures, shaders)
  21318. */
  21319. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21320. /**
  21321. * 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.
  21322. */
  21323. readonly areNormalsFrozen: boolean;
  21324. /**
  21325. * 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.
  21326. * @returns the current mesh
  21327. */
  21328. freezeNormals(): Mesh;
  21329. /**
  21330. * 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
  21331. * @returns the current mesh
  21332. */
  21333. unfreezeNormals(): Mesh;
  21334. /**
  21335. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21336. */
  21337. overridenInstanceCount: number;
  21338. /** @hidden */
  21339. _preActivate(): Mesh;
  21340. /** @hidden */
  21341. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21342. /** @hidden */
  21343. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21344. /**
  21345. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21346. * This means the mesh underlying bounding box and sphere are recomputed.
  21347. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21348. * @returns the current mesh
  21349. */
  21350. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21351. /** @hidden */
  21352. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21353. /**
  21354. * This function will subdivide the mesh into multiple submeshes
  21355. * @param count defines the expected number of submeshes
  21356. */
  21357. subdivide(count: number): void;
  21358. /**
  21359. * Copy a FloatArray into a specific associated vertex buffer
  21360. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21361. * - VertexBuffer.PositionKind
  21362. * - VertexBuffer.UVKind
  21363. * - VertexBuffer.UV2Kind
  21364. * - VertexBuffer.UV3Kind
  21365. * - VertexBuffer.UV4Kind
  21366. * - VertexBuffer.UV5Kind
  21367. * - VertexBuffer.UV6Kind
  21368. * - VertexBuffer.ColorKind
  21369. * - VertexBuffer.MatricesIndicesKind
  21370. * - VertexBuffer.MatricesIndicesExtraKind
  21371. * - VertexBuffer.MatricesWeightsKind
  21372. * - VertexBuffer.MatricesWeightsExtraKind
  21373. * @param data defines the data source
  21374. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21375. * @param stride defines the data stride size (can be null)
  21376. * @returns the current mesh
  21377. */
  21378. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21379. /**
  21380. * Flags an associated vertex buffer as updatable
  21381. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21382. * - VertexBuffer.PositionKind
  21383. * - VertexBuffer.UVKind
  21384. * - VertexBuffer.UV2Kind
  21385. * - VertexBuffer.UV3Kind
  21386. * - VertexBuffer.UV4Kind
  21387. * - VertexBuffer.UV5Kind
  21388. * - VertexBuffer.UV6Kind
  21389. * - VertexBuffer.ColorKind
  21390. * - VertexBuffer.MatricesIndicesKind
  21391. * - VertexBuffer.MatricesIndicesExtraKind
  21392. * - VertexBuffer.MatricesWeightsKind
  21393. * - VertexBuffer.MatricesWeightsExtraKind
  21394. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21395. */
  21396. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21397. /**
  21398. * Sets the mesh global Vertex Buffer
  21399. * @param buffer defines the buffer to use
  21400. * @returns the current mesh
  21401. */
  21402. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21403. /**
  21404. * Update a specific associated vertex buffer
  21405. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21406. * - VertexBuffer.PositionKind
  21407. * - VertexBuffer.UVKind
  21408. * - VertexBuffer.UV2Kind
  21409. * - VertexBuffer.UV3Kind
  21410. * - VertexBuffer.UV4Kind
  21411. * - VertexBuffer.UV5Kind
  21412. * - VertexBuffer.UV6Kind
  21413. * - VertexBuffer.ColorKind
  21414. * - VertexBuffer.MatricesIndicesKind
  21415. * - VertexBuffer.MatricesIndicesExtraKind
  21416. * - VertexBuffer.MatricesWeightsKind
  21417. * - VertexBuffer.MatricesWeightsExtraKind
  21418. * @param data defines the data source
  21419. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21420. * @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)
  21421. * @returns the current mesh
  21422. */
  21423. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21424. /**
  21425. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21426. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21427. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21428. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21429. * @returns the current mesh
  21430. */
  21431. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21432. /**
  21433. * Creates a un-shared specific occurence of the geometry for the mesh.
  21434. * @returns the current mesh
  21435. */
  21436. makeGeometryUnique(): Mesh;
  21437. /**
  21438. * Set the index buffer of this mesh
  21439. * @param indices defines the source data
  21440. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21441. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21442. * @returns the current mesh
  21443. */
  21444. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21445. /**
  21446. * Update the current index buffer
  21447. * @param indices defines the source data
  21448. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21449. * @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)
  21450. * @returns the current mesh
  21451. */
  21452. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21453. /**
  21454. * Invert the geometry to move from a right handed system to a left handed one.
  21455. * @returns the current mesh
  21456. */
  21457. toLeftHanded(): Mesh;
  21458. /** @hidden */
  21459. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21460. /** @hidden */
  21461. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21462. /**
  21463. * Registers for this mesh a javascript function called just before the rendering process
  21464. * @param func defines the function to call before rendering this mesh
  21465. * @returns the current mesh
  21466. */
  21467. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21468. /**
  21469. * Disposes a previously registered javascript function called before the rendering
  21470. * @param func defines the function to remove
  21471. * @returns the current mesh
  21472. */
  21473. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21474. /**
  21475. * Registers for this mesh a javascript function called just after the rendering is complete
  21476. * @param func defines the function to call after rendering this mesh
  21477. * @returns the current mesh
  21478. */
  21479. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21480. /**
  21481. * Disposes a previously registered javascript function called after the rendering.
  21482. * @param func defines the function to remove
  21483. * @returns the current mesh
  21484. */
  21485. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21486. /** @hidden */
  21487. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21488. /** @hidden */
  21489. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21490. /** @hidden */
  21491. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21492. /**
  21493. * 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
  21494. * @param subMesh defines the subMesh to render
  21495. * @param enableAlphaMode defines if alpha mode can be changed
  21496. * @returns the current mesh
  21497. */
  21498. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21499. private _onBeforeDraw;
  21500. /**
  21501. * Renormalize the mesh and patch it up if there are no weights
  21502. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21503. * However in the case of zero weights then we set just a single influence to 1.
  21504. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21505. */
  21506. cleanMatrixWeights(): void;
  21507. private normalizeSkinFourWeights;
  21508. private normalizeSkinWeightsAndExtra;
  21509. /**
  21510. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21511. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21512. * the user know there was an issue with importing the mesh
  21513. * @returns a validation object with skinned, valid and report string
  21514. */
  21515. validateSkinning(): {
  21516. skinned: boolean;
  21517. valid: boolean;
  21518. report: string;
  21519. };
  21520. /** @hidden */
  21521. _checkDelayState(): Mesh;
  21522. private _queueLoad;
  21523. /**
  21524. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21525. * A mesh is in the frustum if its bounding box intersects the frustum
  21526. * @param frustumPlanes defines the frustum to test
  21527. * @returns true if the mesh is in the frustum planes
  21528. */
  21529. isInFrustum(frustumPlanes: Plane[]): boolean;
  21530. /**
  21531. * Sets the mesh material by the material or multiMaterial `id` property
  21532. * @param id is a string identifying the material or the multiMaterial
  21533. * @returns the current mesh
  21534. */
  21535. setMaterialByID(id: string): Mesh;
  21536. /**
  21537. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21538. * @returns an array of IAnimatable
  21539. */
  21540. getAnimatables(): IAnimatable[];
  21541. /**
  21542. * Modifies the mesh geometry according to the passed transformation matrix.
  21543. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21544. * The mesh normals are modified using the same transformation.
  21545. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21546. * @param transform defines the transform matrix to use
  21547. * @see http://doc.babylonjs.com/resources/baking_transformations
  21548. * @returns the current mesh
  21549. */
  21550. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21551. /**
  21552. * Modifies the mesh geometry according to its own current World Matrix.
  21553. * The mesh World Matrix is then reset.
  21554. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21555. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21556. * @see http://doc.babylonjs.com/resources/baking_transformations
  21557. * @returns the current mesh
  21558. */
  21559. bakeCurrentTransformIntoVertices(): Mesh;
  21560. /** @hidden */
  21561. readonly _positions: Nullable<Vector3[]>;
  21562. /** @hidden */
  21563. _resetPointsArrayCache(): Mesh;
  21564. /** @hidden */
  21565. _generatePointsArray(): boolean;
  21566. /**
  21567. * Returns a new Mesh object generated from the current mesh properties.
  21568. * This method must not get confused with createInstance()
  21569. * @param name is a string, the name given to the new mesh
  21570. * @param newParent can be any Node object (default `null`)
  21571. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21572. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21573. * @returns a new mesh
  21574. */
  21575. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21576. /**
  21577. * Releases resources associated with this mesh.
  21578. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21579. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21580. */
  21581. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21582. /**
  21583. * Modifies the mesh geometry according to a displacement map.
  21584. * 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.
  21585. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21586. * @param url is a string, the URL from the image file is to be downloaded.
  21587. * @param minHeight is the lower limit of the displacement.
  21588. * @param maxHeight is the upper limit of the displacement.
  21589. * @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.
  21590. * @param uvOffset is an optional vector2 used to offset UV.
  21591. * @param uvScale is an optional vector2 used to scale UV.
  21592. * @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.
  21593. * @returns the Mesh.
  21594. */
  21595. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21596. /**
  21597. * Modifies the mesh geometry according to a displacementMap buffer.
  21598. * 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.
  21599. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21600. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21601. * @param heightMapWidth is the width of the buffer image.
  21602. * @param heightMapHeight is the height of the buffer image.
  21603. * @param minHeight is the lower limit of the displacement.
  21604. * @param maxHeight is the upper limit of the displacement.
  21605. * @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.
  21606. * @param uvOffset is an optional vector2 used to offset UV.
  21607. * @param uvScale is an optional vector2 used to scale UV.
  21608. * @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.
  21609. * @returns the Mesh.
  21610. */
  21611. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21612. /**
  21613. * Modify the mesh to get a flat shading rendering.
  21614. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21615. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21616. * @returns current mesh
  21617. */
  21618. convertToFlatShadedMesh(): Mesh;
  21619. /**
  21620. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21621. * In other words, more vertices, no more indices and a single bigger VBO.
  21622. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21623. * @returns current mesh
  21624. */
  21625. convertToUnIndexedMesh(): Mesh;
  21626. /**
  21627. * Inverses facet orientations.
  21628. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21629. * @param flipNormals will also inverts the normals
  21630. * @returns current mesh
  21631. */
  21632. flipFaces(flipNormals?: boolean): Mesh;
  21633. /**
  21634. * Increase the number of facets and hence vertices in a mesh
  21635. * Vertex normals are interpolated from existing vertex normals
  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. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21638. */
  21639. increaseVertices(numberPerEdge: number): void;
  21640. /**
  21641. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21642. * This will undo any application of covertToFlatShadedMesh
  21643. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21644. */
  21645. forceSharedVertices(): void;
  21646. /** @hidden */
  21647. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21648. /** @hidden */
  21649. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21650. /**
  21651. * Creates a new InstancedMesh object from the mesh model.
  21652. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21653. * @param name defines the name of the new instance
  21654. * @returns a new InstancedMesh
  21655. */
  21656. createInstance(name: string): InstancedMesh;
  21657. /**
  21658. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21659. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21660. * @returns the current mesh
  21661. */
  21662. synchronizeInstances(): Mesh;
  21663. /**
  21664. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21665. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21666. * This should be used together with the simplification to avoid disappearing triangles.
  21667. * @param successCallback an optional success callback to be called after the optimization finished.
  21668. * @returns the current mesh
  21669. */
  21670. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21671. /**
  21672. * Serialize current mesh
  21673. * @param serializationObject defines the object which will receive the serialization data
  21674. */
  21675. serialize(serializationObject: any): void;
  21676. /** @hidden */
  21677. _syncGeometryWithMorphTargetManager(): void;
  21678. /** @hidden */
  21679. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21680. /**
  21681. * Returns a new Mesh object parsed from the source provided.
  21682. * @param parsedMesh is the source
  21683. * @param scene defines the hosting scene
  21684. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21685. * @returns a new Mesh
  21686. */
  21687. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21688. /**
  21689. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21690. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21691. * @param name defines the name of the mesh to create
  21692. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21693. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21694. * @param closePath creates a seam between the first and the last points of each path of the path array
  21695. * @param offset is taken in account only if the `pathArray` is containing a single path
  21696. * @param scene defines the hosting scene
  21697. * @param updatable defines if the mesh must be flagged as updatable
  21698. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21699. * @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)
  21700. * @returns a new Mesh
  21701. */
  21702. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21703. /**
  21704. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21705. * @param name defines the name of the mesh to create
  21706. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21707. * @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
  21708. * @param scene defines the hosting scene
  21709. * @param updatable defines if the mesh must be flagged as updatable
  21710. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21711. * @returns a new Mesh
  21712. */
  21713. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21714. /**
  21715. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21716. * @param name defines the name of the mesh to create
  21717. * @param size sets the size (float) of each box side (default 1)
  21718. * @param scene defines the hosting scene
  21719. * @param updatable defines if the mesh must be flagged as updatable
  21720. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21721. * @returns a new Mesh
  21722. */
  21723. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21724. /**
  21725. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21726. * @param name defines the name of the mesh to create
  21727. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21728. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21729. * @param scene defines the hosting scene
  21730. * @param updatable defines if the mesh must be flagged as updatable
  21731. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21732. * @returns a new Mesh
  21733. */
  21734. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21735. /**
  21736. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21737. * @param name defines the name of the mesh to create
  21738. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21739. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21740. * @param scene defines the hosting scene
  21741. * @returns a new Mesh
  21742. */
  21743. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21744. /**
  21745. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21746. * @param name defines the name of the mesh to create
  21747. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21748. * @param diameterTop set the top cap diameter (floats, default 1)
  21749. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21750. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21751. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21752. * @param scene defines the hosting scene
  21753. * @param updatable defines if the mesh must be flagged as updatable
  21754. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21755. * @returns a new Mesh
  21756. */
  21757. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21758. /**
  21759. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21760. * @param name defines the name of the mesh to create
  21761. * @param diameter sets the diameter size (float) of the torus (default 1)
  21762. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21763. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21764. * @param scene defines the hosting scene
  21765. * @param updatable defines if the mesh must be flagged as updatable
  21766. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21767. * @returns a new Mesh
  21768. */
  21769. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21770. /**
  21771. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21772. * @param name defines the name of the mesh to create
  21773. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21774. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21775. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21776. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21777. * @param p the number of windings on X axis (positive integers, default 2)
  21778. * @param q the number of windings on Y axis (positive integers, default 3)
  21779. * @param scene defines the hosting scene
  21780. * @param updatable defines if the mesh must be flagged as updatable
  21781. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21782. * @returns a new Mesh
  21783. */
  21784. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21785. /**
  21786. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21787. * @param name defines the name of the mesh to create
  21788. * @param points is an array successive Vector3
  21789. * @param scene defines the hosting scene
  21790. * @param updatable defines if the mesh must be flagged as updatable
  21791. * @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).
  21792. * @returns a new Mesh
  21793. */
  21794. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21795. /**
  21796. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21797. * @param name defines the name of the mesh to create
  21798. * @param points is an array successive Vector3
  21799. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21800. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21801. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21802. * @param scene defines the hosting scene
  21803. * @param updatable defines if the mesh must be flagged as updatable
  21804. * @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)
  21805. * @returns a new Mesh
  21806. */
  21807. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21808. /**
  21809. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21810. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21811. * 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.
  21812. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21813. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21814. * Remember you can only change the shape positions, not their number when updating a polygon.
  21815. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21816. * @param name defines the name of the mesh to create
  21817. * @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
  21818. * @param scene defines the hosting scene
  21819. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21820. * @param updatable defines if the mesh must be flagged as updatable
  21821. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21822. * @param earcutInjection can be used to inject your own earcut reference
  21823. * @returns a new Mesh
  21824. */
  21825. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21826. /**
  21827. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21828. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21829. * @param name defines the name of the mesh to create
  21830. * @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
  21831. * @param depth defines the height of extrusion
  21832. * @param scene defines the hosting scene
  21833. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21834. * @param updatable defines if the mesh must be flagged as updatable
  21835. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21836. * @param earcutInjection can be used to inject your own earcut reference
  21837. * @returns a new Mesh
  21838. */
  21839. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21840. /**
  21841. * Creates an extruded shape mesh.
  21842. * 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
  21843. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21844. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21845. * @param name defines the name of the mesh to create
  21846. * @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
  21847. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21848. * @param scale is the value to scale the shape
  21849. * @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
  21850. * @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
  21851. * @param scene defines the hosting scene
  21852. * @param updatable defines if the mesh must be flagged as updatable
  21853. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21854. * @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)
  21855. * @returns a new Mesh
  21856. */
  21857. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21858. /**
  21859. * Creates an custom extruded shape mesh.
  21860. * The custom extrusion is a parametric shape.
  21861. * It has no predefined shape. Its final shape will depend on the input parameters.
  21862. * Please consider using the same method from the MeshBuilder class instead
  21863. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21864. * @param name defines the name of the mesh to create
  21865. * @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
  21866. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21867. * @param scaleFunction is a custom Javascript function called on each path point
  21868. * @param rotationFunction is a custom Javascript function called on each path point
  21869. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21870. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21871. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  21872. * @param scene defines the hosting scene
  21873. * @param updatable defines if the mesh must be flagged as updatable
  21874. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21875. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  21876. * @returns a new Mesh
  21877. */
  21878. static 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;
  21879. /**
  21880. * Creates lathe mesh.
  21881. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21882. * Please consider using the same method from the MeshBuilder class instead
  21883. * @param name defines the name of the mesh to create
  21884. * @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
  21885. * @param radius is the radius value of the lathe
  21886. * @param tessellation is the side number of the lathe.
  21887. * @param scene defines the hosting scene
  21888. * @param updatable defines if the mesh must be flagged as updatable
  21889. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21890. * @returns a new Mesh
  21891. */
  21892. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21893. /**
  21894. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21895. * @param name defines the name of the mesh to create
  21896. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21897. * @param scene defines the hosting scene
  21898. * @param updatable defines if the mesh must be flagged as updatable
  21899. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21900. * @returns a new Mesh
  21901. */
  21902. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21903. /**
  21904. * Creates a ground mesh.
  21905. * Please consider using the same method from the MeshBuilder class instead
  21906. * @param name defines the name of the mesh to create
  21907. * @param width set the width of the ground
  21908. * @param height set the height of the ground
  21909. * @param subdivisions sets the number of subdivisions per side
  21910. * @param scene defines the hosting scene
  21911. * @param updatable defines if the mesh must be flagged as updatable
  21912. * @returns a new Mesh
  21913. */
  21914. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21915. /**
  21916. * Creates a tiled ground mesh.
  21917. * Please consider using the same method from the MeshBuilder class instead
  21918. * @param name defines the name of the mesh to create
  21919. * @param xmin set the ground minimum X coordinate
  21920. * @param zmin set the ground minimum Y coordinate
  21921. * @param xmax set the ground maximum X coordinate
  21922. * @param zmax set the ground maximum Z coordinate
  21923. * @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
  21924. * @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
  21925. * @param scene defines the hosting scene
  21926. * @param updatable defines if the mesh must be flagged as updatable
  21927. * @returns a new Mesh
  21928. */
  21929. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21930. w: number;
  21931. h: number;
  21932. }, precision: {
  21933. w: number;
  21934. h: number;
  21935. }, scene: Scene, updatable?: boolean): Mesh;
  21936. /**
  21937. * Creates a ground mesh from a height map.
  21938. * Please consider using the same method from the MeshBuilder class instead
  21939. * @see http://doc.babylonjs.com/babylon101/height_map
  21940. * @param name defines the name of the mesh to create
  21941. * @param url sets the URL of the height map image resource
  21942. * @param width set the ground width size
  21943. * @param height set the ground height size
  21944. * @param subdivisions sets the number of subdivision per side
  21945. * @param minHeight is the minimum altitude on the ground
  21946. * @param maxHeight is the maximum altitude on the ground
  21947. * @param scene defines the hosting scene
  21948. * @param updatable defines if the mesh must be flagged as updatable
  21949. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21950. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21951. * @returns a new Mesh
  21952. */
  21953. 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;
  21954. /**
  21955. * Creates a tube mesh.
  21956. * The tube is a parametric shape.
  21957. * It has no predefined shape. Its final shape will depend on the input parameters.
  21958. * Please consider using the same method from the MeshBuilder class instead
  21959. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21960. * @param name defines the name of the mesh to create
  21961. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21962. * @param radius sets the tube radius size
  21963. * @param tessellation is the number of sides on the tubular surface
  21964. * @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
  21965. * @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
  21966. * @param scene defines the hosting scene
  21967. * @param updatable defines if the mesh must be flagged as updatable
  21968. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21969. * @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)
  21970. * @returns a new Mesh
  21971. */
  21972. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21973. (i: number, distance: number): number;
  21974. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21975. /**
  21976. * Creates a polyhedron mesh.
  21977. * Please consider using the same method from the MeshBuilder class instead.
  21978. * * 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
  21979. * * The parameter `size` (positive float, default 1) sets the polygon size
  21980. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21981. * * 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`
  21982. * * 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
  21983. * * 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)`)
  21984. * * 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
  21985. * * 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
  21986. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21987. * * If you create a double-sided mesh, you can choose what parts of 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
  21988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21989. * @param name defines the name of the mesh to create
  21990. * @param options defines the options used to create the mesh
  21991. * @param scene defines the hosting scene
  21992. * @returns a new Mesh
  21993. */
  21994. static CreatePolyhedron(name: string, options: {
  21995. type?: number;
  21996. size?: number;
  21997. sizeX?: number;
  21998. sizeY?: number;
  21999. sizeZ?: number;
  22000. custom?: any;
  22001. faceUV?: Vector4[];
  22002. faceColors?: Color4[];
  22003. updatable?: boolean;
  22004. sideOrientation?: number;
  22005. }, scene: Scene): Mesh;
  22006. /**
  22007. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22008. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22009. * * 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`)
  22010. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22011. * * 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
  22012. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22013. * * If you create a double-sided mesh, you can choose what parts of 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
  22014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22015. * @param name defines the name of the mesh
  22016. * @param options defines the options used to create the mesh
  22017. * @param scene defines the hosting scene
  22018. * @returns a new Mesh
  22019. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22020. */
  22021. static CreateIcoSphere(name: string, options: {
  22022. radius?: number;
  22023. flat?: boolean;
  22024. subdivisions?: number;
  22025. sideOrientation?: number;
  22026. updatable?: boolean;
  22027. }, scene: Scene): Mesh;
  22028. /**
  22029. * Creates a decal mesh.
  22030. * Please consider using the same method from the MeshBuilder class instead.
  22031. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22032. * @param name defines the name of the mesh
  22033. * @param sourceMesh defines the mesh receiving the decal
  22034. * @param position sets the position of the decal in world coordinates
  22035. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22036. * @param size sets the decal scaling
  22037. * @param angle sets the angle to rotate the decal
  22038. * @returns a new Mesh
  22039. */
  22040. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22041. /**
  22042. * Prepare internal position array for software CPU skinning
  22043. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22044. */
  22045. setPositionsForCPUSkinning(): Float32Array;
  22046. /**
  22047. * Prepare internal normal array for software CPU skinning
  22048. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22049. */
  22050. setNormalsForCPUSkinning(): Float32Array;
  22051. /**
  22052. * Updates the vertex buffer by applying transformation from the bones
  22053. * @param skeleton defines the skeleton to apply to current mesh
  22054. * @returns the current mesh
  22055. */
  22056. applySkeleton(skeleton: Skeleton): Mesh;
  22057. /**
  22058. * 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
  22059. * @param meshes defines the list of meshes to scan
  22060. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22061. */
  22062. static MinMax(meshes: AbstractMesh[]): {
  22063. min: Vector3;
  22064. max: Vector3;
  22065. };
  22066. /**
  22067. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22068. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22069. * @returns a vector3
  22070. */
  22071. static Center(meshesOrMinMaxVector: {
  22072. min: Vector3;
  22073. max: Vector3;
  22074. } | AbstractMesh[]): Vector3;
  22075. /**
  22076. * Merge the array of meshes into a single mesh for performance reasons.
  22077. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22078. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22079. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22080. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22081. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22082. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22083. * @returns a new mesh
  22084. */
  22085. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22086. /** @hidden */
  22087. addInstance(instance: InstancedMesh): void;
  22088. /** @hidden */
  22089. removeInstance(instance: InstancedMesh): void;
  22090. }
  22091. }
  22092. declare module "babylonjs/Materials/material" {
  22093. import { IAnimatable } from "babylonjs/Misc/tools";
  22094. import { SmartArray } from "babylonjs/Misc/smartArray";
  22095. import { Observable } from "babylonjs/Misc/observable";
  22096. import { Nullable } from "babylonjs/types";
  22097. import { Scene } from "babylonjs/scene";
  22098. import { Matrix } from "babylonjs/Maths/math";
  22099. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22100. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22101. import { Mesh } from "babylonjs/Meshes/mesh";
  22102. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22103. import { Effect } from "babylonjs/Materials/effect";
  22104. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22105. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22106. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22107. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22108. import { Animation } from "babylonjs/Animations/animation";
  22109. /**
  22110. * Base class for the main features of a material in Babylon.js
  22111. */
  22112. export class Material implements IAnimatable {
  22113. /**
  22114. * Returns the triangle fill mode
  22115. */
  22116. static readonly TriangleFillMode: number;
  22117. /**
  22118. * Returns the wireframe mode
  22119. */
  22120. static readonly WireFrameFillMode: number;
  22121. /**
  22122. * Returns the point fill mode
  22123. */
  22124. static readonly PointFillMode: number;
  22125. /**
  22126. * Returns the point list draw mode
  22127. */
  22128. static readonly PointListDrawMode: number;
  22129. /**
  22130. * Returns the line list draw mode
  22131. */
  22132. static readonly LineListDrawMode: number;
  22133. /**
  22134. * Returns the line loop draw mode
  22135. */
  22136. static readonly LineLoopDrawMode: number;
  22137. /**
  22138. * Returns the line strip draw mode
  22139. */
  22140. static readonly LineStripDrawMode: number;
  22141. /**
  22142. * Returns the triangle strip draw mode
  22143. */
  22144. static readonly TriangleStripDrawMode: number;
  22145. /**
  22146. * Returns the triangle fan draw mode
  22147. */
  22148. static readonly TriangleFanDrawMode: number;
  22149. /**
  22150. * Stores the clock-wise side orientation
  22151. */
  22152. static readonly ClockWiseSideOrientation: number;
  22153. /**
  22154. * Stores the counter clock-wise side orientation
  22155. */
  22156. static readonly CounterClockWiseSideOrientation: number;
  22157. /**
  22158. * The dirty texture flag value
  22159. */
  22160. static readonly TextureDirtyFlag: number;
  22161. /**
  22162. * The dirty light flag value
  22163. */
  22164. static readonly LightDirtyFlag: number;
  22165. /**
  22166. * The dirty fresnel flag value
  22167. */
  22168. static readonly FresnelDirtyFlag: number;
  22169. /**
  22170. * The dirty attribute flag value
  22171. */
  22172. static readonly AttributesDirtyFlag: number;
  22173. /**
  22174. * The dirty misc flag value
  22175. */
  22176. static readonly MiscDirtyFlag: number;
  22177. /**
  22178. * The all dirty flag value
  22179. */
  22180. static readonly AllDirtyFlag: number;
  22181. /**
  22182. * The ID of the material
  22183. */
  22184. id: string;
  22185. /**
  22186. * Gets or sets the unique id of the material
  22187. */
  22188. uniqueId: number;
  22189. /**
  22190. * The name of the material
  22191. */
  22192. name: string;
  22193. /**
  22194. * Gets or sets user defined metadata
  22195. */
  22196. metadata: any;
  22197. /**
  22198. * For internal use only. Please do not use.
  22199. */
  22200. reservedDataStore: any;
  22201. /**
  22202. * Specifies if the ready state should be checked on each call
  22203. */
  22204. checkReadyOnEveryCall: boolean;
  22205. /**
  22206. * Specifies if the ready state should be checked once
  22207. */
  22208. checkReadyOnlyOnce: boolean;
  22209. /**
  22210. * The state of the material
  22211. */
  22212. state: string;
  22213. /**
  22214. * The alpha value of the material
  22215. */
  22216. protected _alpha: number;
  22217. /**
  22218. * List of inspectable custom properties (used by the Inspector)
  22219. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22220. */
  22221. inspectableCustomProperties: IInspectable[];
  22222. /**
  22223. * Sets the alpha value of the material
  22224. */
  22225. /**
  22226. * Gets the alpha value of the material
  22227. */
  22228. alpha: number;
  22229. /**
  22230. * Specifies if back face culling is enabled
  22231. */
  22232. protected _backFaceCulling: boolean;
  22233. /**
  22234. * Sets the back-face culling state
  22235. */
  22236. /**
  22237. * Gets the back-face culling state
  22238. */
  22239. backFaceCulling: boolean;
  22240. /**
  22241. * Stores the value for side orientation
  22242. */
  22243. sideOrientation: number;
  22244. /**
  22245. * Callback triggered when the material is compiled
  22246. */
  22247. onCompiled: (effect: Effect) => void;
  22248. /**
  22249. * Callback triggered when an error occurs
  22250. */
  22251. onError: (effect: Effect, errors: string) => void;
  22252. /**
  22253. * Callback triggered to get the render target textures
  22254. */
  22255. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  22256. /**
  22257. * Gets a boolean indicating that current material needs to register RTT
  22258. */
  22259. readonly hasRenderTargetTextures: boolean;
  22260. /**
  22261. * Specifies if the material should be serialized
  22262. */
  22263. doNotSerialize: boolean;
  22264. /**
  22265. * @hidden
  22266. */
  22267. _storeEffectOnSubMeshes: boolean;
  22268. /**
  22269. * Stores the animations for the material
  22270. */
  22271. animations: Array<Animation>;
  22272. /**
  22273. * An event triggered when the material is disposed
  22274. */
  22275. onDisposeObservable: Observable<Material>;
  22276. /**
  22277. * An observer which watches for dispose events
  22278. */
  22279. private _onDisposeObserver;
  22280. private _onUnBindObservable;
  22281. /**
  22282. * Called during a dispose event
  22283. */
  22284. onDispose: () => void;
  22285. private _onBindObservable;
  22286. /**
  22287. * An event triggered when the material is bound
  22288. */
  22289. readonly onBindObservable: Observable<AbstractMesh>;
  22290. /**
  22291. * An observer which watches for bind events
  22292. */
  22293. private _onBindObserver;
  22294. /**
  22295. * Called during a bind event
  22296. */
  22297. onBind: (Mesh: AbstractMesh) => void;
  22298. /**
  22299. * An event triggered when the material is unbound
  22300. */
  22301. readonly onUnBindObservable: Observable<Material>;
  22302. /**
  22303. * Stores the value of the alpha mode
  22304. */
  22305. private _alphaMode;
  22306. /**
  22307. * Sets the value of the alpha mode.
  22308. *
  22309. * | Value | Type | Description |
  22310. * | --- | --- | --- |
  22311. * | 0 | ALPHA_DISABLE | |
  22312. * | 1 | ALPHA_ADD | |
  22313. * | 2 | ALPHA_COMBINE | |
  22314. * | 3 | ALPHA_SUBTRACT | |
  22315. * | 4 | ALPHA_MULTIPLY | |
  22316. * | 5 | ALPHA_MAXIMIZED | |
  22317. * | 6 | ALPHA_ONEONE | |
  22318. * | 7 | ALPHA_PREMULTIPLIED | |
  22319. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22320. * | 9 | ALPHA_INTERPOLATE | |
  22321. * | 10 | ALPHA_SCREENMODE | |
  22322. *
  22323. */
  22324. /**
  22325. * Gets the value of the alpha mode
  22326. */
  22327. alphaMode: number;
  22328. /**
  22329. * Stores the state of the need depth pre-pass value
  22330. */
  22331. private _needDepthPrePass;
  22332. /**
  22333. * Sets the need depth pre-pass value
  22334. */
  22335. /**
  22336. * Gets the depth pre-pass value
  22337. */
  22338. needDepthPrePass: boolean;
  22339. /**
  22340. * Specifies if depth writing should be disabled
  22341. */
  22342. disableDepthWrite: boolean;
  22343. /**
  22344. * Specifies if depth writing should be forced
  22345. */
  22346. forceDepthWrite: boolean;
  22347. /**
  22348. * Specifies if there should be a separate pass for culling
  22349. */
  22350. separateCullingPass: boolean;
  22351. /**
  22352. * Stores the state specifing if fog should be enabled
  22353. */
  22354. private _fogEnabled;
  22355. /**
  22356. * Sets the state for enabling fog
  22357. */
  22358. /**
  22359. * Gets the value of the fog enabled state
  22360. */
  22361. fogEnabled: boolean;
  22362. /**
  22363. * Stores the size of points
  22364. */
  22365. pointSize: number;
  22366. /**
  22367. * Stores the z offset value
  22368. */
  22369. zOffset: number;
  22370. /**
  22371. * Gets a value specifying if wireframe mode is enabled
  22372. */
  22373. /**
  22374. * Sets the state of wireframe mode
  22375. */
  22376. wireframe: boolean;
  22377. /**
  22378. * Gets the value specifying if point clouds are enabled
  22379. */
  22380. /**
  22381. * Sets the state of point cloud mode
  22382. */
  22383. pointsCloud: boolean;
  22384. /**
  22385. * Gets the material fill mode
  22386. */
  22387. /**
  22388. * Sets the material fill mode
  22389. */
  22390. fillMode: number;
  22391. /**
  22392. * @hidden
  22393. * Stores the effects for the material
  22394. */
  22395. _effect: Nullable<Effect>;
  22396. /**
  22397. * @hidden
  22398. * Specifies if the material was previously ready
  22399. */
  22400. _wasPreviouslyReady: boolean;
  22401. /**
  22402. * Specifies if uniform buffers should be used
  22403. */
  22404. private _useUBO;
  22405. /**
  22406. * Stores a reference to the scene
  22407. */
  22408. private _scene;
  22409. /**
  22410. * Stores the fill mode state
  22411. */
  22412. private _fillMode;
  22413. /**
  22414. * Specifies if the depth write state should be cached
  22415. */
  22416. private _cachedDepthWriteState;
  22417. /**
  22418. * Stores the uniform buffer
  22419. */
  22420. protected _uniformBuffer: UniformBuffer;
  22421. /** @hidden */
  22422. _indexInSceneMaterialArray: number;
  22423. /** @hidden */
  22424. meshMap: Nullable<{
  22425. [id: string]: AbstractMesh | undefined;
  22426. }>;
  22427. /**
  22428. * Creates a material instance
  22429. * @param name defines the name of the material
  22430. * @param scene defines the scene to reference
  22431. * @param doNotAdd specifies if the material should be added to the scene
  22432. */
  22433. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22434. /**
  22435. * Returns a string representation of the current material
  22436. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22437. * @returns a string with material information
  22438. */
  22439. toString(fullDetails?: boolean): string;
  22440. /**
  22441. * Gets the class name of the material
  22442. * @returns a string with the class name of the material
  22443. */
  22444. getClassName(): string;
  22445. /**
  22446. * Specifies if updates for the material been locked
  22447. */
  22448. readonly isFrozen: boolean;
  22449. /**
  22450. * Locks updates for the material
  22451. */
  22452. freeze(): void;
  22453. /**
  22454. * Unlocks updates for the material
  22455. */
  22456. unfreeze(): void;
  22457. /**
  22458. * Specifies if the material is ready to be used
  22459. * @param mesh defines the mesh to check
  22460. * @param useInstances specifies if instances should be used
  22461. * @returns a boolean indicating if the material is ready to be used
  22462. */
  22463. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22464. /**
  22465. * Specifies that the submesh is ready to be used
  22466. * @param mesh defines the mesh to check
  22467. * @param subMesh defines which submesh to check
  22468. * @param useInstances specifies that instances should be used
  22469. * @returns a boolean indicating that the submesh is ready or not
  22470. */
  22471. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22472. /**
  22473. * Returns the material effect
  22474. * @returns the effect associated with the material
  22475. */
  22476. getEffect(): Nullable<Effect>;
  22477. /**
  22478. * Returns the current scene
  22479. * @returns a Scene
  22480. */
  22481. getScene(): Scene;
  22482. /**
  22483. * Specifies if the material will require alpha blending
  22484. * @returns a boolean specifying if alpha blending is needed
  22485. */
  22486. needAlphaBlending(): boolean;
  22487. /**
  22488. * Specifies if the mesh will require alpha blending
  22489. * @param mesh defines the mesh to check
  22490. * @returns a boolean specifying if alpha blending is needed for the mesh
  22491. */
  22492. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22493. /**
  22494. * Specifies if this material should be rendered in alpha test mode
  22495. * @returns a boolean specifying if an alpha test is needed.
  22496. */
  22497. needAlphaTesting(): boolean;
  22498. /**
  22499. * Gets the texture used for the alpha test
  22500. * @returns the texture to use for alpha testing
  22501. */
  22502. getAlphaTestTexture(): Nullable<BaseTexture>;
  22503. /**
  22504. * Marks the material to indicate that it needs to be re-calculated
  22505. */
  22506. markDirty(): void;
  22507. /** @hidden */
  22508. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22509. /**
  22510. * Binds the material to the mesh
  22511. * @param world defines the world transformation matrix
  22512. * @param mesh defines the mesh to bind the material to
  22513. */
  22514. bind(world: Matrix, mesh?: Mesh): void;
  22515. /**
  22516. * Binds the submesh to the material
  22517. * @param world defines the world transformation matrix
  22518. * @param mesh defines the mesh containing the submesh
  22519. * @param subMesh defines the submesh to bind the material to
  22520. */
  22521. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22522. /**
  22523. * Binds the world matrix to the material
  22524. * @param world defines the world transformation matrix
  22525. */
  22526. bindOnlyWorldMatrix(world: Matrix): void;
  22527. /**
  22528. * Binds the scene's uniform buffer to the effect.
  22529. * @param effect defines the effect to bind to the scene uniform buffer
  22530. * @param sceneUbo defines the uniform buffer storing scene data
  22531. */
  22532. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22533. /**
  22534. * Binds the view matrix to the effect
  22535. * @param effect defines the effect to bind the view matrix to
  22536. */
  22537. bindView(effect: Effect): void;
  22538. /**
  22539. * Binds the view projection matrix to the effect
  22540. * @param effect defines the effect to bind the view projection matrix to
  22541. */
  22542. bindViewProjection(effect: Effect): void;
  22543. /**
  22544. * Specifies if material alpha testing should be turned on for the mesh
  22545. * @param mesh defines the mesh to check
  22546. */
  22547. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22548. /**
  22549. * Processes to execute after binding the material to a mesh
  22550. * @param mesh defines the rendered mesh
  22551. */
  22552. protected _afterBind(mesh?: Mesh): void;
  22553. /**
  22554. * Unbinds the material from the mesh
  22555. */
  22556. unbind(): void;
  22557. /**
  22558. * Gets the active textures from the material
  22559. * @returns an array of textures
  22560. */
  22561. getActiveTextures(): BaseTexture[];
  22562. /**
  22563. * Specifies if the material uses a texture
  22564. * @param texture defines the texture to check against the material
  22565. * @returns a boolean specifying if the material uses the texture
  22566. */
  22567. hasTexture(texture: BaseTexture): boolean;
  22568. /**
  22569. * Makes a duplicate of the material, and gives it a new name
  22570. * @param name defines the new name for the duplicated material
  22571. * @returns the cloned material
  22572. */
  22573. clone(name: string): Nullable<Material>;
  22574. /**
  22575. * Gets the meshes bound to the material
  22576. * @returns an array of meshes bound to the material
  22577. */
  22578. getBindedMeshes(): AbstractMesh[];
  22579. /**
  22580. * Force shader compilation
  22581. * @param mesh defines the mesh associated with this material
  22582. * @param onCompiled defines a function to execute once the material is compiled
  22583. * @param options defines the options to configure the compilation
  22584. */
  22585. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22586. clipPlane: boolean;
  22587. }>): void;
  22588. /**
  22589. * Force shader compilation
  22590. * @param mesh defines the mesh that will use this material
  22591. * @param options defines additional options for compiling the shaders
  22592. * @returns a promise that resolves when the compilation completes
  22593. */
  22594. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22595. clipPlane: boolean;
  22596. }>): Promise<void>;
  22597. private static readonly _ImageProcessingDirtyCallBack;
  22598. private static readonly _TextureDirtyCallBack;
  22599. private static readonly _FresnelDirtyCallBack;
  22600. private static readonly _MiscDirtyCallBack;
  22601. private static readonly _LightsDirtyCallBack;
  22602. private static readonly _AttributeDirtyCallBack;
  22603. private static _FresnelAndMiscDirtyCallBack;
  22604. private static _TextureAndMiscDirtyCallBack;
  22605. private static readonly _DirtyCallbackArray;
  22606. private static readonly _RunDirtyCallBacks;
  22607. /**
  22608. * Marks a define in the material to indicate that it needs to be re-computed
  22609. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22610. */
  22611. markAsDirty(flag: number): void;
  22612. /**
  22613. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22614. * @param func defines a function which checks material defines against the submeshes
  22615. */
  22616. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22617. /**
  22618. * Indicates that image processing needs to be re-calculated for all submeshes
  22619. */
  22620. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22621. /**
  22622. * Indicates that textures need to be re-calculated for all submeshes
  22623. */
  22624. protected _markAllSubMeshesAsTexturesDirty(): void;
  22625. /**
  22626. * Indicates that fresnel needs to be re-calculated for all submeshes
  22627. */
  22628. protected _markAllSubMeshesAsFresnelDirty(): void;
  22629. /**
  22630. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22631. */
  22632. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22633. /**
  22634. * Indicates that lights need to be re-calculated for all submeshes
  22635. */
  22636. protected _markAllSubMeshesAsLightsDirty(): void;
  22637. /**
  22638. * Indicates that attributes need to be re-calculated for all submeshes
  22639. */
  22640. protected _markAllSubMeshesAsAttributesDirty(): void;
  22641. /**
  22642. * Indicates that misc needs to be re-calculated for all submeshes
  22643. */
  22644. protected _markAllSubMeshesAsMiscDirty(): void;
  22645. /**
  22646. * Indicates that textures and misc need to be re-calculated for all submeshes
  22647. */
  22648. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22649. /**
  22650. * Disposes the material
  22651. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22652. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22653. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22654. */
  22655. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22656. /** @hidden */
  22657. private releaseVertexArrayObject;
  22658. /**
  22659. * Serializes this material
  22660. * @returns the serialized material object
  22661. */
  22662. serialize(): any;
  22663. /**
  22664. * Creates a material from parsed material data
  22665. * @param parsedMaterial defines parsed material data
  22666. * @param scene defines the hosting scene
  22667. * @param rootUrl defines the root URL to use to load textures
  22668. * @returns a new material
  22669. */
  22670. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22671. }
  22672. }
  22673. declare module "babylonjs/Meshes/subMesh" {
  22674. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22675. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22676. import { Engine } from "babylonjs/Engines/engine";
  22677. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22678. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22679. import { Effect } from "babylonjs/Materials/effect";
  22680. import { Collider } from "babylonjs/Collisions/collider";
  22681. import { Material } from "babylonjs/Materials/material";
  22682. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22683. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22684. import { Mesh } from "babylonjs/Meshes/mesh";
  22685. import { Ray } from "babylonjs/Culling/ray";
  22686. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22687. /**
  22688. * Base class for submeshes
  22689. */
  22690. export class BaseSubMesh {
  22691. /** @hidden */
  22692. _materialDefines: Nullable<MaterialDefines>;
  22693. /** @hidden */
  22694. _materialEffect: Nullable<Effect>;
  22695. /**
  22696. * Gets associated effect
  22697. */
  22698. readonly effect: Nullable<Effect>;
  22699. /**
  22700. * Sets associated effect (effect used to render this submesh)
  22701. * @param effect defines the effect to associate with
  22702. * @param defines defines the set of defines used to compile this effect
  22703. */
  22704. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22705. }
  22706. /**
  22707. * Defines a subdivision inside a mesh
  22708. */
  22709. export class SubMesh extends BaseSubMesh implements ICullable {
  22710. /** the material index to use */
  22711. materialIndex: number;
  22712. /** vertex index start */
  22713. verticesStart: number;
  22714. /** vertices count */
  22715. verticesCount: number;
  22716. /** index start */
  22717. indexStart: number;
  22718. /** indices count */
  22719. indexCount: number;
  22720. /** @hidden */
  22721. _linesIndexCount: number;
  22722. private _mesh;
  22723. private _renderingMesh;
  22724. private _boundingInfo;
  22725. private _linesIndexBuffer;
  22726. /** @hidden */
  22727. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22728. /** @hidden */
  22729. _trianglePlanes: Plane[];
  22730. /** @hidden */
  22731. _lastColliderTransformMatrix: Matrix;
  22732. /** @hidden */
  22733. _renderId: number;
  22734. /** @hidden */
  22735. _alphaIndex: number;
  22736. /** @hidden */
  22737. _distanceToCamera: number;
  22738. /** @hidden */
  22739. _id: number;
  22740. private _currentMaterial;
  22741. /**
  22742. * Add a new submesh to a mesh
  22743. * @param materialIndex defines the material index to use
  22744. * @param verticesStart defines vertex index start
  22745. * @param verticesCount defines vertices count
  22746. * @param indexStart defines index start
  22747. * @param indexCount defines indices count
  22748. * @param mesh defines the parent mesh
  22749. * @param renderingMesh defines an optional rendering mesh
  22750. * @param createBoundingBox defines if bounding box should be created for this submesh
  22751. * @returns the new submesh
  22752. */
  22753. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22754. /**
  22755. * Creates a new submesh
  22756. * @param materialIndex defines the material index to use
  22757. * @param verticesStart defines vertex index start
  22758. * @param verticesCount defines vertices count
  22759. * @param indexStart defines index start
  22760. * @param indexCount defines indices count
  22761. * @param mesh defines the parent mesh
  22762. * @param renderingMesh defines an optional rendering mesh
  22763. * @param createBoundingBox defines if bounding box should be created for this submesh
  22764. */
  22765. constructor(
  22766. /** the material index to use */
  22767. materialIndex: number,
  22768. /** vertex index start */
  22769. verticesStart: number,
  22770. /** vertices count */
  22771. verticesCount: number,
  22772. /** index start */
  22773. indexStart: number,
  22774. /** indices count */
  22775. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22776. /**
  22777. * Returns true if this submesh covers the entire parent mesh
  22778. * @ignorenaming
  22779. */
  22780. readonly IsGlobal: boolean;
  22781. /**
  22782. * Returns the submesh BoudingInfo object
  22783. * @returns current bounding info (or mesh's one if the submesh is global)
  22784. */
  22785. getBoundingInfo(): BoundingInfo;
  22786. /**
  22787. * Sets the submesh BoundingInfo
  22788. * @param boundingInfo defines the new bounding info to use
  22789. * @returns the SubMesh
  22790. */
  22791. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22792. /**
  22793. * Returns the mesh of the current submesh
  22794. * @return the parent mesh
  22795. */
  22796. getMesh(): AbstractMesh;
  22797. /**
  22798. * Returns the rendering mesh of the submesh
  22799. * @returns the rendering mesh (could be different from parent mesh)
  22800. */
  22801. getRenderingMesh(): Mesh;
  22802. /**
  22803. * Returns the submesh material
  22804. * @returns null or the current material
  22805. */
  22806. getMaterial(): Nullable<Material>;
  22807. /**
  22808. * Sets a new updated BoundingInfo object to the submesh
  22809. * @returns the SubMesh
  22810. */
  22811. refreshBoundingInfo(): SubMesh;
  22812. /** @hidden */
  22813. _checkCollision(collider: Collider): boolean;
  22814. /**
  22815. * Updates the submesh BoundingInfo
  22816. * @param world defines the world matrix to use to update the bounding info
  22817. * @returns the submesh
  22818. */
  22819. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22820. /**
  22821. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22822. * @param frustumPlanes defines the frustum planes
  22823. * @returns true if the submesh is intersecting with the frustum
  22824. */
  22825. isInFrustum(frustumPlanes: Plane[]): boolean;
  22826. /**
  22827. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22828. * @param frustumPlanes defines the frustum planes
  22829. * @returns true if the submesh is inside the frustum
  22830. */
  22831. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22832. /**
  22833. * Renders the submesh
  22834. * @param enableAlphaMode defines if alpha needs to be used
  22835. * @returns the submesh
  22836. */
  22837. render(enableAlphaMode: boolean): SubMesh;
  22838. /**
  22839. * @hidden
  22840. */
  22841. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22842. /**
  22843. * Checks if the submesh intersects with a ray
  22844. * @param ray defines the ray to test
  22845. * @returns true is the passed ray intersects the submesh bounding box
  22846. */
  22847. canIntersects(ray: Ray): boolean;
  22848. /**
  22849. * Intersects current submesh with a ray
  22850. * @param ray defines the ray to test
  22851. * @param positions defines mesh's positions array
  22852. * @param indices defines mesh's indices array
  22853. * @param fastCheck defines if only bounding info should be used
  22854. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22855. * @returns intersection info or null if no intersection
  22856. */
  22857. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22858. /** @hidden */
  22859. private _intersectLines;
  22860. /** @hidden */
  22861. private _intersectTriangles;
  22862. /** @hidden */
  22863. _rebuild(): void;
  22864. /**
  22865. * Creates a new submesh from the passed mesh
  22866. * @param newMesh defines the new hosting mesh
  22867. * @param newRenderingMesh defines an optional rendering mesh
  22868. * @returns the new submesh
  22869. */
  22870. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22871. /**
  22872. * Release associated resources
  22873. */
  22874. dispose(): void;
  22875. /**
  22876. * Gets the class name
  22877. * @returns the string "SubMesh".
  22878. */
  22879. getClassName(): string;
  22880. /**
  22881. * Creates a new submesh from indices data
  22882. * @param materialIndex the index of the main mesh material
  22883. * @param startIndex the index where to start the copy in the mesh indices array
  22884. * @param indexCount the number of indices to copy then from the startIndex
  22885. * @param mesh the main mesh to create the submesh from
  22886. * @param renderingMesh the optional rendering mesh
  22887. * @returns a new submesh
  22888. */
  22889. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22890. }
  22891. }
  22892. declare module "babylonjs/Meshes/geometry" {
  22893. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22894. import { Scene } from "babylonjs/scene";
  22895. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22896. import { Engine } from "babylonjs/Engines/engine";
  22897. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22898. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22899. import { Effect } from "babylonjs/Materials/effect";
  22900. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22901. import { Mesh } from "babylonjs/Meshes/mesh";
  22902. /**
  22903. * Class used to store geometry data (vertex buffers + index buffer)
  22904. */
  22905. export class Geometry implements IGetSetVerticesData {
  22906. /**
  22907. * Gets or sets the ID of the geometry
  22908. */
  22909. id: string;
  22910. /**
  22911. * Gets or sets the unique ID of the geometry
  22912. */
  22913. uniqueId: number;
  22914. /**
  22915. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22916. */
  22917. delayLoadState: number;
  22918. /**
  22919. * Gets the file containing the data to load when running in delay load state
  22920. */
  22921. delayLoadingFile: Nullable<string>;
  22922. /**
  22923. * Callback called when the geometry is updated
  22924. */
  22925. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22926. private _scene;
  22927. private _engine;
  22928. private _meshes;
  22929. private _totalVertices;
  22930. /** @hidden */
  22931. _indices: IndicesArray;
  22932. /** @hidden */
  22933. _vertexBuffers: {
  22934. [key: string]: VertexBuffer;
  22935. };
  22936. private _isDisposed;
  22937. private _extend;
  22938. private _boundingBias;
  22939. /** @hidden */
  22940. _delayInfo: Array<string>;
  22941. private _indexBuffer;
  22942. private _indexBufferIsUpdatable;
  22943. /** @hidden */
  22944. _boundingInfo: Nullable<BoundingInfo>;
  22945. /** @hidden */
  22946. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22947. /** @hidden */
  22948. _softwareSkinningFrameId: number;
  22949. private _vertexArrayObjects;
  22950. private _updatable;
  22951. /** @hidden */
  22952. _positions: Nullable<Vector3[]>;
  22953. /**
  22954. * 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
  22955. */
  22956. /**
  22957. * 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
  22958. */
  22959. boundingBias: Vector2;
  22960. /**
  22961. * Static function used to attach a new empty geometry to a mesh
  22962. * @param mesh defines the mesh to attach the geometry to
  22963. * @returns the new Geometry
  22964. */
  22965. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22966. /**
  22967. * Creates a new geometry
  22968. * @param id defines the unique ID
  22969. * @param scene defines the hosting scene
  22970. * @param vertexData defines the VertexData used to get geometry data
  22971. * @param updatable defines if geometry must be updatable (false by default)
  22972. * @param mesh defines the mesh that will be associated with the geometry
  22973. */
  22974. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22975. /**
  22976. * Gets the current extend of the geometry
  22977. */
  22978. readonly extend: {
  22979. minimum: Vector3;
  22980. maximum: Vector3;
  22981. };
  22982. /**
  22983. * Gets the hosting scene
  22984. * @returns the hosting Scene
  22985. */
  22986. getScene(): Scene;
  22987. /**
  22988. * Gets the hosting engine
  22989. * @returns the hosting Engine
  22990. */
  22991. getEngine(): Engine;
  22992. /**
  22993. * Defines if the geometry is ready to use
  22994. * @returns true if the geometry is ready to be used
  22995. */
  22996. isReady(): boolean;
  22997. /**
  22998. * Gets a value indicating that the geometry should not be serialized
  22999. */
  23000. readonly doNotSerialize: boolean;
  23001. /** @hidden */
  23002. _rebuild(): void;
  23003. /**
  23004. * Affects all geometry data in one call
  23005. * @param vertexData defines the geometry data
  23006. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23007. */
  23008. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23009. /**
  23010. * Set specific vertex data
  23011. * @param kind defines the data kind (Position, normal, etc...)
  23012. * @param data defines the vertex data to use
  23013. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23014. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23015. */
  23016. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23017. /**
  23018. * Removes a specific vertex data
  23019. * @param kind defines the data kind (Position, normal, etc...)
  23020. */
  23021. removeVerticesData(kind: string): void;
  23022. /**
  23023. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23024. * @param buffer defines the vertex buffer to use
  23025. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23026. */
  23027. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23028. /**
  23029. * Update a specific vertex buffer
  23030. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  23031. * It will do nothing if the buffer is not updatable
  23032. * @param kind defines the data kind (Position, normal, etc...)
  23033. * @param data defines the data to use
  23034. * @param offset defines the offset in the target buffer where to store the data
  23035. * @param useBytes set to true if the offset is in bytes
  23036. */
  23037. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23038. /**
  23039. * Update a specific vertex buffer
  23040. * This function will create a new buffer if the current one is not updatable
  23041. * @param kind defines the data kind (Position, normal, etc...)
  23042. * @param data defines the data to use
  23043. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23044. */
  23045. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23046. private _updateBoundingInfo;
  23047. /** @hidden */
  23048. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  23049. /**
  23050. * Gets total number of vertices
  23051. * @returns the total number of vertices
  23052. */
  23053. getTotalVertices(): number;
  23054. /**
  23055. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23056. * @param kind defines the data kind (Position, normal, etc...)
  23057. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23058. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23059. * @returns a float array containing vertex data
  23060. */
  23061. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23062. /**
  23063. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23064. * @param kind defines the data kind (Position, normal, etc...)
  23065. * @returns true if the vertex buffer with the specified kind is updatable
  23066. */
  23067. isVertexBufferUpdatable(kind: string): boolean;
  23068. /**
  23069. * Gets a specific vertex buffer
  23070. * @param kind defines the data kind (Position, normal, etc...)
  23071. * @returns a VertexBuffer
  23072. */
  23073. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23074. /**
  23075. * Returns all vertex buffers
  23076. * @return an object holding all vertex buffers indexed by kind
  23077. */
  23078. getVertexBuffers(): Nullable<{
  23079. [key: string]: VertexBuffer;
  23080. }>;
  23081. /**
  23082. * Gets a boolean indicating if specific vertex buffer is present
  23083. * @param kind defines the data kind (Position, normal, etc...)
  23084. * @returns true if data is present
  23085. */
  23086. isVerticesDataPresent(kind: string): boolean;
  23087. /**
  23088. * Gets a list of all attached data kinds (Position, normal, etc...)
  23089. * @returns a list of string containing all kinds
  23090. */
  23091. getVerticesDataKinds(): string[];
  23092. /**
  23093. * Update index buffer
  23094. * @param indices defines the indices to store in the index buffer
  23095. * @param offset defines the offset in the target buffer where to store the data
  23096. * @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)
  23097. */
  23098. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23099. /**
  23100. * Creates a new index buffer
  23101. * @param indices defines the indices to store in the index buffer
  23102. * @param totalVertices defines the total number of vertices (could be null)
  23103. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23104. */
  23105. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23106. /**
  23107. * Return the total number of indices
  23108. * @returns the total number of indices
  23109. */
  23110. getTotalIndices(): number;
  23111. /**
  23112. * Gets the index buffer array
  23113. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23114. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23115. * @returns the index buffer array
  23116. */
  23117. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23118. /**
  23119. * Gets the index buffer
  23120. * @return the index buffer
  23121. */
  23122. getIndexBuffer(): Nullable<WebGLBuffer>;
  23123. /** @hidden */
  23124. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23125. /**
  23126. * Release the associated resources for a specific mesh
  23127. * @param mesh defines the source mesh
  23128. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23129. */
  23130. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23131. /**
  23132. * Apply current geometry to a given mesh
  23133. * @param mesh defines the mesh to apply geometry to
  23134. */
  23135. applyToMesh(mesh: Mesh): void;
  23136. private _updateExtend;
  23137. private _applyToMesh;
  23138. private notifyUpdate;
  23139. /**
  23140. * Load the geometry if it was flagged as delay loaded
  23141. * @param scene defines the hosting scene
  23142. * @param onLoaded defines a callback called when the geometry is loaded
  23143. */
  23144. load(scene: Scene, onLoaded?: () => void): void;
  23145. private _queueLoad;
  23146. /**
  23147. * Invert the geometry to move from a right handed system to a left handed one.
  23148. */
  23149. toLeftHanded(): void;
  23150. /** @hidden */
  23151. _resetPointsArrayCache(): void;
  23152. /** @hidden */
  23153. _generatePointsArray(): boolean;
  23154. /**
  23155. * Gets a value indicating if the geometry is disposed
  23156. * @returns true if the geometry was disposed
  23157. */
  23158. isDisposed(): boolean;
  23159. private _disposeVertexArrayObjects;
  23160. /**
  23161. * Free all associated resources
  23162. */
  23163. dispose(): void;
  23164. /**
  23165. * Clone the current geometry into a new geometry
  23166. * @param id defines the unique ID of the new geometry
  23167. * @returns a new geometry object
  23168. */
  23169. copy(id: string): Geometry;
  23170. /**
  23171. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23172. * @return a JSON representation of the current geometry data (without the vertices data)
  23173. */
  23174. serialize(): any;
  23175. private toNumberArray;
  23176. /**
  23177. * Serialize all vertices data into a JSON oject
  23178. * @returns a JSON representation of the current geometry data
  23179. */
  23180. serializeVerticeData(): any;
  23181. /**
  23182. * Extracts a clone of a mesh geometry
  23183. * @param mesh defines the source mesh
  23184. * @param id defines the unique ID of the new geometry object
  23185. * @returns the new geometry object
  23186. */
  23187. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23188. /**
  23189. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23190. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23191. * Be aware Math.random() could cause collisions, but:
  23192. * "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"
  23193. * @returns a string containing a new GUID
  23194. */
  23195. static RandomId(): string;
  23196. /** @hidden */
  23197. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23198. private static _CleanMatricesWeights;
  23199. /**
  23200. * Create a new geometry from persisted data (Using .babylon file format)
  23201. * @param parsedVertexData defines the persisted data
  23202. * @param scene defines the hosting scene
  23203. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23204. * @returns the new geometry object
  23205. */
  23206. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23207. }
  23208. }
  23209. declare module "babylonjs/Meshes/mesh.vertexData" {
  23210. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23211. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23212. import { Geometry } from "babylonjs/Meshes/geometry";
  23213. import { Mesh } from "babylonjs/Meshes/mesh";
  23214. /**
  23215. * Define an interface for all classes that will get and set the data on vertices
  23216. */
  23217. export interface IGetSetVerticesData {
  23218. /**
  23219. * Gets a boolean indicating if specific vertex data is present
  23220. * @param kind defines the vertex data kind to use
  23221. * @returns true is data kind is present
  23222. */
  23223. isVerticesDataPresent(kind: string): boolean;
  23224. /**
  23225. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23226. * @param kind defines the data kind (Position, normal, etc...)
  23227. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23228. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23229. * @returns a float array containing vertex data
  23230. */
  23231. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23232. /**
  23233. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23234. * @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.
  23235. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23236. * @returns the indices array or an empty array if the mesh has no geometry
  23237. */
  23238. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23239. /**
  23240. * Set specific vertex data
  23241. * @param kind defines the data kind (Position, normal, etc...)
  23242. * @param data defines the vertex data to use
  23243. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23244. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23245. */
  23246. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23247. /**
  23248. * Update a specific associated vertex buffer
  23249. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23250. * - VertexBuffer.PositionKind
  23251. * - VertexBuffer.UVKind
  23252. * - VertexBuffer.UV2Kind
  23253. * - VertexBuffer.UV3Kind
  23254. * - VertexBuffer.UV4Kind
  23255. * - VertexBuffer.UV5Kind
  23256. * - VertexBuffer.UV6Kind
  23257. * - VertexBuffer.ColorKind
  23258. * - VertexBuffer.MatricesIndicesKind
  23259. * - VertexBuffer.MatricesIndicesExtraKind
  23260. * - VertexBuffer.MatricesWeightsKind
  23261. * - VertexBuffer.MatricesWeightsExtraKind
  23262. * @param data defines the data source
  23263. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23264. * @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)
  23265. */
  23266. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23267. /**
  23268. * Creates a new index buffer
  23269. * @param indices defines the indices to store in the index buffer
  23270. * @param totalVertices defines the total number of vertices (could be null)
  23271. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23272. */
  23273. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23274. }
  23275. /**
  23276. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23277. */
  23278. export class VertexData {
  23279. /**
  23280. * Mesh side orientation : usually the external or front surface
  23281. */
  23282. static readonly FRONTSIDE: number;
  23283. /**
  23284. * Mesh side orientation : usually the internal or back surface
  23285. */
  23286. static readonly BACKSIDE: number;
  23287. /**
  23288. * Mesh side orientation : both internal and external or front and back surfaces
  23289. */
  23290. static readonly DOUBLESIDE: number;
  23291. /**
  23292. * Mesh side orientation : by default, `FRONTSIDE`
  23293. */
  23294. static readonly DEFAULTSIDE: number;
  23295. /**
  23296. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23297. */
  23298. positions: Nullable<FloatArray>;
  23299. /**
  23300. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23301. */
  23302. normals: Nullable<FloatArray>;
  23303. /**
  23304. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23305. */
  23306. tangents: Nullable<FloatArray>;
  23307. /**
  23308. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23309. */
  23310. uvs: Nullable<FloatArray>;
  23311. /**
  23312. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23313. */
  23314. uvs2: Nullable<FloatArray>;
  23315. /**
  23316. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23317. */
  23318. uvs3: Nullable<FloatArray>;
  23319. /**
  23320. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23321. */
  23322. uvs4: Nullable<FloatArray>;
  23323. /**
  23324. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23325. */
  23326. uvs5: Nullable<FloatArray>;
  23327. /**
  23328. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23329. */
  23330. uvs6: Nullable<FloatArray>;
  23331. /**
  23332. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23333. */
  23334. colors: Nullable<FloatArray>;
  23335. /**
  23336. * 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).
  23337. */
  23338. matricesIndices: Nullable<FloatArray>;
  23339. /**
  23340. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23341. */
  23342. matricesWeights: Nullable<FloatArray>;
  23343. /**
  23344. * An array extending the number of possible indices
  23345. */
  23346. matricesIndicesExtra: Nullable<FloatArray>;
  23347. /**
  23348. * An array extending the number of possible weights when the number of indices is extended
  23349. */
  23350. matricesWeightsExtra: Nullable<FloatArray>;
  23351. /**
  23352. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23353. */
  23354. indices: Nullable<IndicesArray>;
  23355. /**
  23356. * Uses the passed data array to set the set the values for the specified kind of data
  23357. * @param data a linear array of floating numbers
  23358. * @param kind the type of data that is being set, eg positions, colors etc
  23359. */
  23360. set(data: FloatArray, kind: string): void;
  23361. /**
  23362. * Associates the vertexData to the passed Mesh.
  23363. * Sets it as updatable or not (default `false`)
  23364. * @param mesh the mesh the vertexData is applied to
  23365. * @param updatable when used and having the value true allows new data to update the vertexData
  23366. * @returns the VertexData
  23367. */
  23368. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23369. /**
  23370. * Associates the vertexData to the passed Geometry.
  23371. * Sets it as updatable or not (default `false`)
  23372. * @param geometry the geometry the vertexData is applied to
  23373. * @param updatable when used and having the value true allows new data to update the vertexData
  23374. * @returns VertexData
  23375. */
  23376. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23377. /**
  23378. * Updates the associated mesh
  23379. * @param mesh the mesh to be updated
  23380. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23381. * @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
  23382. * @returns VertexData
  23383. */
  23384. updateMesh(mesh: Mesh): VertexData;
  23385. /**
  23386. * Updates the associated geometry
  23387. * @param geometry the geometry to be updated
  23388. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23389. * @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
  23390. * @returns VertexData.
  23391. */
  23392. updateGeometry(geometry: Geometry): VertexData;
  23393. private _applyTo;
  23394. private _update;
  23395. /**
  23396. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23397. * @param matrix the transforming matrix
  23398. * @returns the VertexData
  23399. */
  23400. transform(matrix: Matrix): VertexData;
  23401. /**
  23402. * Merges the passed VertexData into the current one
  23403. * @param other the VertexData to be merged into the current one
  23404. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23405. * @returns the modified VertexData
  23406. */
  23407. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23408. private _mergeElement;
  23409. private _validate;
  23410. /**
  23411. * Serializes the VertexData
  23412. * @returns a serialized object
  23413. */
  23414. serialize(): any;
  23415. /**
  23416. * Extracts the vertexData from a mesh
  23417. * @param mesh the mesh from which to extract the VertexData
  23418. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23419. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23420. * @returns the object VertexData associated to the passed mesh
  23421. */
  23422. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23423. /**
  23424. * Extracts the vertexData from the geometry
  23425. * @param geometry the geometry from which to extract the VertexData
  23426. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23427. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23428. * @returns the object VertexData associated to the passed mesh
  23429. */
  23430. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23431. private static _ExtractFrom;
  23432. /**
  23433. * Creates the VertexData for a Ribbon
  23434. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23435. * * pathArray array of paths, each of which an array of successive Vector3
  23436. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23437. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23438. * * 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
  23439. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23440. * * 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)
  23441. * * 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)
  23442. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23443. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23444. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23445. * @returns the VertexData of the ribbon
  23446. */
  23447. static CreateRibbon(options: {
  23448. pathArray: Vector3[][];
  23449. closeArray?: boolean;
  23450. closePath?: boolean;
  23451. offset?: number;
  23452. sideOrientation?: number;
  23453. frontUVs?: Vector4;
  23454. backUVs?: Vector4;
  23455. invertUV?: boolean;
  23456. uvs?: Vector2[];
  23457. colors?: Color4[];
  23458. }): VertexData;
  23459. /**
  23460. * Creates the VertexData for a box
  23461. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23462. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23463. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23464. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23465. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23466. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23467. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23468. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23469. * * 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)
  23470. * * 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)
  23471. * @returns the VertexData of the box
  23472. */
  23473. static CreateBox(options: {
  23474. size?: number;
  23475. width?: number;
  23476. height?: number;
  23477. depth?: number;
  23478. faceUV?: Vector4[];
  23479. faceColors?: Color4[];
  23480. sideOrientation?: number;
  23481. frontUVs?: Vector4;
  23482. backUVs?: Vector4;
  23483. }): VertexData;
  23484. /**
  23485. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23486. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23487. * * segments sets the number of horizontal strips optional, default 32
  23488. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23489. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23490. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23491. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23492. * * 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
  23493. * * 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
  23494. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23495. * * 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)
  23496. * * 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)
  23497. * @returns the VertexData of the ellipsoid
  23498. */
  23499. static CreateSphere(options: {
  23500. segments?: number;
  23501. diameter?: number;
  23502. diameterX?: number;
  23503. diameterY?: number;
  23504. diameterZ?: number;
  23505. arc?: number;
  23506. slice?: number;
  23507. sideOrientation?: number;
  23508. frontUVs?: Vector4;
  23509. backUVs?: Vector4;
  23510. }): VertexData;
  23511. /**
  23512. * Creates the VertexData for a cylinder, cone or prism
  23513. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23514. * * height sets the height (y direction) of the cylinder, optional, default 2
  23515. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23516. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23517. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23518. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23519. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23520. * * 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
  23521. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23522. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23523. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23524. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23525. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23526. * * 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)
  23527. * * 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)
  23528. * @returns the VertexData of the cylinder, cone or prism
  23529. */
  23530. static CreateCylinder(options: {
  23531. height?: number;
  23532. diameterTop?: number;
  23533. diameterBottom?: number;
  23534. diameter?: number;
  23535. tessellation?: number;
  23536. subdivisions?: number;
  23537. arc?: number;
  23538. faceColors?: Color4[];
  23539. faceUV?: Vector4[];
  23540. hasRings?: boolean;
  23541. enclose?: boolean;
  23542. sideOrientation?: number;
  23543. frontUVs?: Vector4;
  23544. backUVs?: Vector4;
  23545. }): VertexData;
  23546. /**
  23547. * Creates the VertexData for a torus
  23548. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23549. * * diameter the diameter of the torus, optional default 1
  23550. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23551. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23552. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23553. * * 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)
  23554. * * 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)
  23555. * @returns the VertexData of the torus
  23556. */
  23557. static CreateTorus(options: {
  23558. diameter?: number;
  23559. thickness?: number;
  23560. tessellation?: number;
  23561. sideOrientation?: number;
  23562. frontUVs?: Vector4;
  23563. backUVs?: Vector4;
  23564. }): VertexData;
  23565. /**
  23566. * Creates the VertexData of the LineSystem
  23567. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23568. * - lines an array of lines, each line being an array of successive Vector3
  23569. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23570. * @returns the VertexData of the LineSystem
  23571. */
  23572. static CreateLineSystem(options: {
  23573. lines: Vector3[][];
  23574. colors?: Nullable<Color4[][]>;
  23575. }): VertexData;
  23576. /**
  23577. * Create the VertexData for a DashedLines
  23578. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23579. * - points an array successive Vector3
  23580. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23581. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23582. * - dashNb the intended total number of dashes, optional, default 200
  23583. * @returns the VertexData for the DashedLines
  23584. */
  23585. static CreateDashedLines(options: {
  23586. points: Vector3[];
  23587. dashSize?: number;
  23588. gapSize?: number;
  23589. dashNb?: number;
  23590. }): VertexData;
  23591. /**
  23592. * Creates the VertexData for a Ground
  23593. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23594. * - width the width (x direction) of the ground, optional, default 1
  23595. * - height the height (z direction) of the ground, optional, default 1
  23596. * - subdivisions the number of subdivisions per side, optional, default 1
  23597. * @returns the VertexData of the Ground
  23598. */
  23599. static CreateGround(options: {
  23600. width?: number;
  23601. height?: number;
  23602. subdivisions?: number;
  23603. subdivisionsX?: number;
  23604. subdivisionsY?: number;
  23605. }): VertexData;
  23606. /**
  23607. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23608. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23609. * * xmin the ground minimum X coordinate, optional, default -1
  23610. * * zmin the ground minimum Z coordinate, optional, default -1
  23611. * * xmax the ground maximum X coordinate, optional, default 1
  23612. * * zmax the ground maximum Z coordinate, optional, default 1
  23613. * * 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}
  23614. * * 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}
  23615. * @returns the VertexData of the TiledGround
  23616. */
  23617. static CreateTiledGround(options: {
  23618. xmin: number;
  23619. zmin: number;
  23620. xmax: number;
  23621. zmax: number;
  23622. subdivisions?: {
  23623. w: number;
  23624. h: number;
  23625. };
  23626. precision?: {
  23627. w: number;
  23628. h: number;
  23629. };
  23630. }): VertexData;
  23631. /**
  23632. * Creates the VertexData of the Ground designed from a heightmap
  23633. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23634. * * width the width (x direction) of the ground
  23635. * * height the height (z direction) of the ground
  23636. * * subdivisions the number of subdivisions per side
  23637. * * minHeight the minimum altitude on the ground, optional, default 0
  23638. * * maxHeight the maximum altitude on the ground, optional default 1
  23639. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23640. * * buffer the array holding the image color data
  23641. * * bufferWidth the width of image
  23642. * * bufferHeight the height of image
  23643. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23644. * @returns the VertexData of the Ground designed from a heightmap
  23645. */
  23646. static CreateGroundFromHeightMap(options: {
  23647. width: number;
  23648. height: number;
  23649. subdivisions: number;
  23650. minHeight: number;
  23651. maxHeight: number;
  23652. colorFilter: Color3;
  23653. buffer: Uint8Array;
  23654. bufferWidth: number;
  23655. bufferHeight: number;
  23656. alphaFilter: number;
  23657. }): VertexData;
  23658. /**
  23659. * Creates the VertexData for a Plane
  23660. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23661. * * size sets the width and height of the plane to the value of size, optional default 1
  23662. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23663. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23664. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23665. * * 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)
  23666. * * 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)
  23667. * @returns the VertexData of the box
  23668. */
  23669. static CreatePlane(options: {
  23670. size?: number;
  23671. width?: number;
  23672. height?: number;
  23673. sideOrientation?: number;
  23674. frontUVs?: Vector4;
  23675. backUVs?: Vector4;
  23676. }): VertexData;
  23677. /**
  23678. * Creates the VertexData of the Disc or regular Polygon
  23679. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23680. * * radius the radius of the disc, optional default 0.5
  23681. * * tessellation the number of polygon sides, optional, default 64
  23682. * * 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
  23683. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23684. * * 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)
  23685. * * 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)
  23686. * @returns the VertexData of the box
  23687. */
  23688. static CreateDisc(options: {
  23689. radius?: number;
  23690. tessellation?: number;
  23691. arc?: number;
  23692. sideOrientation?: number;
  23693. frontUVs?: Vector4;
  23694. backUVs?: Vector4;
  23695. }): VertexData;
  23696. /**
  23697. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23698. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23699. * @param polygon a mesh built from polygonTriangulation.build()
  23700. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23701. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23702. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23703. * @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)
  23704. * @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)
  23705. * @returns the VertexData of the Polygon
  23706. */
  23707. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23708. /**
  23709. * Creates the VertexData of the IcoSphere
  23710. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23711. * * radius the radius of the IcoSphere, optional default 1
  23712. * * radiusX allows stretching in the x direction, optional, default radius
  23713. * * radiusY allows stretching in the y direction, optional, default radius
  23714. * * radiusZ allows stretching in the z direction, optional, default radius
  23715. * * flat when true creates a flat shaded mesh, optional, default true
  23716. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23717. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23718. * * 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)
  23719. * * 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)
  23720. * @returns the VertexData of the IcoSphere
  23721. */
  23722. static CreateIcoSphere(options: {
  23723. radius?: number;
  23724. radiusX?: number;
  23725. radiusY?: number;
  23726. radiusZ?: number;
  23727. flat?: boolean;
  23728. subdivisions?: number;
  23729. sideOrientation?: number;
  23730. frontUVs?: Vector4;
  23731. backUVs?: Vector4;
  23732. }): VertexData;
  23733. /**
  23734. * Creates the VertexData for a Polyhedron
  23735. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23736. * * type provided types are:
  23737. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23738. * * 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)
  23739. * * size the size of the IcoSphere, optional default 1
  23740. * * sizeX allows stretching in the x direction, optional, default size
  23741. * * sizeY allows stretching in the y direction, optional, default size
  23742. * * sizeZ allows stretching in the z direction, optional, default size
  23743. * * 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
  23744. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23745. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23746. * * flat when true creates a flat shaded mesh, optional, default true
  23747. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23748. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23749. * * 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)
  23750. * * 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)
  23751. * @returns the VertexData of the Polyhedron
  23752. */
  23753. static CreatePolyhedron(options: {
  23754. type?: number;
  23755. size?: number;
  23756. sizeX?: number;
  23757. sizeY?: number;
  23758. sizeZ?: number;
  23759. custom?: any;
  23760. faceUV?: Vector4[];
  23761. faceColors?: Color4[];
  23762. flat?: boolean;
  23763. sideOrientation?: number;
  23764. frontUVs?: Vector4;
  23765. backUVs?: Vector4;
  23766. }): VertexData;
  23767. /**
  23768. * Creates the VertexData for a TorusKnot
  23769. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23770. * * radius the radius of the torus knot, optional, default 2
  23771. * * tube the thickness of the tube, optional, default 0.5
  23772. * * radialSegments the number of sides on each tube segments, optional, default 32
  23773. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23774. * * p the number of windings around the z axis, optional, default 2
  23775. * * q the number of windings around the x axis, optional, default 3
  23776. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23777. * * 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)
  23778. * * 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)
  23779. * @returns the VertexData of the Torus Knot
  23780. */
  23781. static CreateTorusKnot(options: {
  23782. radius?: number;
  23783. tube?: number;
  23784. radialSegments?: number;
  23785. tubularSegments?: number;
  23786. p?: number;
  23787. q?: number;
  23788. sideOrientation?: number;
  23789. frontUVs?: Vector4;
  23790. backUVs?: Vector4;
  23791. }): VertexData;
  23792. /**
  23793. * Compute normals for given positions and indices
  23794. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23795. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23796. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23797. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23798. * * facetNormals : optional array of facet normals (vector3)
  23799. * * facetPositions : optional array of facet positions (vector3)
  23800. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23801. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23802. * * bInfo : optional bounding info, required for facetPartitioning computation
  23803. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23804. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23805. * * useRightHandedSystem: optional boolean to for right handed system computation
  23806. * * depthSort : optional boolean to enable the facet depth sort computation
  23807. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23808. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23809. */
  23810. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23811. facetNormals?: any;
  23812. facetPositions?: any;
  23813. facetPartitioning?: any;
  23814. ratio?: number;
  23815. bInfo?: any;
  23816. bbSize?: Vector3;
  23817. subDiv?: any;
  23818. useRightHandedSystem?: boolean;
  23819. depthSort?: boolean;
  23820. distanceTo?: Vector3;
  23821. depthSortedFacets?: any;
  23822. }): void;
  23823. /** @hidden */
  23824. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23825. /**
  23826. * Applies VertexData created from the imported parameters to the geometry
  23827. * @param parsedVertexData the parsed data from an imported file
  23828. * @param geometry the geometry to apply the VertexData to
  23829. */
  23830. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23831. }
  23832. }
  23833. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23834. import { Nullable } from "babylonjs/types";
  23835. import { Scene } from "babylonjs/scene";
  23836. import { Vector4 } from "babylonjs/Maths/math";
  23837. import { Mesh } from "babylonjs/Meshes/mesh";
  23838. /**
  23839. * Class containing static functions to help procedurally build meshes
  23840. */
  23841. export class DiscBuilder {
  23842. /**
  23843. * Creates a plane polygonal mesh. By default, this is a disc
  23844. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23845. * * 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
  23846. * * 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
  23847. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23848. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23850. * @param name defines the name of the mesh
  23851. * @param options defines the options used to create the mesh
  23852. * @param scene defines the hosting scene
  23853. * @returns the plane polygonal mesh
  23854. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23855. */
  23856. static CreateDisc(name: string, options: {
  23857. radius?: number;
  23858. tessellation?: number;
  23859. arc?: number;
  23860. updatable?: boolean;
  23861. sideOrientation?: number;
  23862. frontUVs?: Vector4;
  23863. backUVs?: Vector4;
  23864. }, scene?: Nullable<Scene>): Mesh;
  23865. }
  23866. }
  23867. declare module "babylonjs/Particles/solidParticleSystem" {
  23868. import { Vector3 } from "babylonjs/Maths/math";
  23869. import { Mesh } from "babylonjs/Meshes/mesh";
  23870. import { Scene, IDisposable } from "babylonjs/scene";
  23871. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23872. /**
  23873. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23874. *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.
  23875. * The SPS is also a particle system. It provides some methods to manage the particles.
  23876. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23877. *
  23878. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23879. */
  23880. export class SolidParticleSystem implements IDisposable {
  23881. /**
  23882. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23883. * Example : var p = SPS.particles[i];
  23884. */
  23885. particles: SolidParticle[];
  23886. /**
  23887. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23888. */
  23889. nbParticles: number;
  23890. /**
  23891. * If the particles must ever face the camera (default false). Useful for planar particles.
  23892. */
  23893. billboard: boolean;
  23894. /**
  23895. * Recompute normals when adding a shape
  23896. */
  23897. recomputeNormals: boolean;
  23898. /**
  23899. * This a counter ofr your own usage. It's not set by any SPS functions.
  23900. */
  23901. counter: number;
  23902. /**
  23903. * The SPS name. This name is also given to the underlying mesh.
  23904. */
  23905. name: string;
  23906. /**
  23907. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23908. */
  23909. mesh: Mesh;
  23910. /**
  23911. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23912. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23913. */
  23914. vars: any;
  23915. /**
  23916. * This array is populated when the SPS is set as 'pickable'.
  23917. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23918. * Each element of this array is an object `{idx: int, faceId: int}`.
  23919. * `idx` is the picked particle index in the `SPS.particles` array
  23920. * `faceId` is the picked face index counted within this particle.
  23921. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23922. */
  23923. pickedParticles: {
  23924. idx: number;
  23925. faceId: number;
  23926. }[];
  23927. /**
  23928. * This array is populated when `enableDepthSort` is set to true.
  23929. * Each element of this array is an instance of the class DepthSortedParticle.
  23930. */
  23931. depthSortedParticles: DepthSortedParticle[];
  23932. /**
  23933. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23934. * @hidden
  23935. */
  23936. _bSphereOnly: boolean;
  23937. /**
  23938. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23939. * @hidden
  23940. */
  23941. _bSphereRadiusFactor: number;
  23942. private _scene;
  23943. private _positions;
  23944. private _indices;
  23945. private _normals;
  23946. private _colors;
  23947. private _uvs;
  23948. private _indices32;
  23949. private _positions32;
  23950. private _normals32;
  23951. private _fixedNormal32;
  23952. private _colors32;
  23953. private _uvs32;
  23954. private _index;
  23955. private _updatable;
  23956. private _pickable;
  23957. private _isVisibilityBoxLocked;
  23958. private _alwaysVisible;
  23959. private _depthSort;
  23960. private _shapeCounter;
  23961. private _copy;
  23962. private _color;
  23963. private _computeParticleColor;
  23964. private _computeParticleTexture;
  23965. private _computeParticleRotation;
  23966. private _computeParticleVertex;
  23967. private _computeBoundingBox;
  23968. private _depthSortParticles;
  23969. private _camera;
  23970. private _mustUnrotateFixedNormals;
  23971. private _particlesIntersect;
  23972. private _needs32Bits;
  23973. /**
  23974. * Creates a SPS (Solid Particle System) object.
  23975. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23976. * @param scene (Scene) is the scene in which the SPS is added.
  23977. * @param options defines the options of the sps e.g.
  23978. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23979. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23980. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23981. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23982. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23983. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23984. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23985. */
  23986. constructor(name: string, scene: Scene, options?: {
  23987. updatable?: boolean;
  23988. isPickable?: boolean;
  23989. enableDepthSort?: boolean;
  23990. particleIntersection?: boolean;
  23991. boundingSphereOnly?: boolean;
  23992. bSphereRadiusFactor?: number;
  23993. });
  23994. /**
  23995. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23996. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23997. * @returns the created mesh
  23998. */
  23999. buildMesh(): Mesh;
  24000. /**
  24001. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24002. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24003. * Thus the particles generated from `digest()` have their property `position` set yet.
  24004. * @param mesh ( Mesh ) is the mesh to be digested
  24005. * @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
  24006. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24007. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24008. * @returns the current SPS
  24009. */
  24010. digest(mesh: Mesh, options?: {
  24011. facetNb?: number;
  24012. number?: number;
  24013. delta?: number;
  24014. }): SolidParticleSystem;
  24015. private _unrotateFixedNormals;
  24016. private _resetCopy;
  24017. private _meshBuilder;
  24018. private _posToShape;
  24019. private _uvsToShapeUV;
  24020. private _addParticle;
  24021. /**
  24022. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24023. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24024. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24025. * @param nb (positive integer) the number of particles to be created from this model
  24026. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24027. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24028. * @returns the number of shapes in the system
  24029. */
  24030. addShape(mesh: Mesh, nb: number, options?: {
  24031. positionFunction?: any;
  24032. vertexFunction?: any;
  24033. }): number;
  24034. private _rebuildParticle;
  24035. /**
  24036. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24037. * @returns the SPS.
  24038. */
  24039. rebuildMesh(): SolidParticleSystem;
  24040. /**
  24041. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24042. * This method calls `updateParticle()` for each particle of the SPS.
  24043. * For an animated SPS, it is usually called within the render loop.
  24044. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24045. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24046. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24047. * @returns the SPS.
  24048. */
  24049. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24050. /**
  24051. * Disposes the SPS.
  24052. */
  24053. dispose(): void;
  24054. /**
  24055. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24056. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24057. * @returns the SPS.
  24058. */
  24059. refreshVisibleSize(): SolidParticleSystem;
  24060. /**
  24061. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24062. * @param size the size (float) of the visibility box
  24063. * note : this doesn't lock the SPS mesh bounding box.
  24064. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24065. */
  24066. setVisibilityBox(size: number): void;
  24067. /**
  24068. * Gets whether the SPS as always visible or not
  24069. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24070. */
  24071. /**
  24072. * Sets the SPS as always visible or not
  24073. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24074. */
  24075. isAlwaysVisible: boolean;
  24076. /**
  24077. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24078. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24079. */
  24080. /**
  24081. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24082. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24083. */
  24084. isVisibilityBoxLocked: boolean;
  24085. /**
  24086. * Tells to `setParticles()` to compute the particle rotations or not.
  24087. * Default value : true. The SPS is faster when it's set to false.
  24088. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24089. */
  24090. /**
  24091. * Gets if `setParticles()` computes the particle rotations or not.
  24092. * Default value : true. The SPS is faster when it's set to false.
  24093. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24094. */
  24095. computeParticleRotation: boolean;
  24096. /**
  24097. * Tells to `setParticles()` to compute the particle colors or not.
  24098. * Default value : true. The SPS is faster when it's set to false.
  24099. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24100. */
  24101. /**
  24102. * Gets if `setParticles()` computes the particle colors or not.
  24103. * Default value : true. The SPS is faster when it's set to false.
  24104. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24105. */
  24106. computeParticleColor: boolean;
  24107. /**
  24108. * Gets if `setParticles()` computes the particle textures or not.
  24109. * Default value : true. The SPS is faster when it's set to false.
  24110. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24111. */
  24112. computeParticleTexture: boolean;
  24113. /**
  24114. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24115. * Default value : false. The SPS is faster when it's set to false.
  24116. * Note : the particle custom vertex positions aren't stored values.
  24117. */
  24118. /**
  24119. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24120. * Default value : false. The SPS is faster when it's set to false.
  24121. * Note : the particle custom vertex positions aren't stored values.
  24122. */
  24123. computeParticleVertex: boolean;
  24124. /**
  24125. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24126. */
  24127. /**
  24128. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24129. */
  24130. computeBoundingBox: boolean;
  24131. /**
  24132. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24133. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24134. * Default : `true`
  24135. */
  24136. /**
  24137. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24138. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24139. * Default : `true`
  24140. */
  24141. depthSortParticles: boolean;
  24142. /**
  24143. * This function does nothing. It may be overwritten to set all the particle first values.
  24144. * The SPS doesn't call this function, you may have to call it by your own.
  24145. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24146. */
  24147. initParticles(): void;
  24148. /**
  24149. * This function does nothing. It may be overwritten to recycle a particle.
  24150. * The SPS doesn't call this function, you may have to call it by your own.
  24151. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24152. * @param particle The particle to recycle
  24153. * @returns the recycled particle
  24154. */
  24155. recycleParticle(particle: SolidParticle): SolidParticle;
  24156. /**
  24157. * Updates a particle : this function should be overwritten by the user.
  24158. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24159. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24160. * @example : just set a particle position or velocity and recycle conditions
  24161. * @param particle The particle to update
  24162. * @returns the updated particle
  24163. */
  24164. updateParticle(particle: SolidParticle): SolidParticle;
  24165. /**
  24166. * Updates a vertex of a particle : it can be overwritten by the user.
  24167. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24168. * @param particle the current particle
  24169. * @param vertex the current index of the current particle
  24170. * @param pt the index of the current vertex in the particle shape
  24171. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24172. * @example : just set a vertex particle position
  24173. * @returns the updated vertex
  24174. */
  24175. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24176. /**
  24177. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24178. * This does nothing and may be overwritten by the user.
  24179. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24180. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24181. * @param update the boolean update value actually passed to setParticles()
  24182. */
  24183. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24184. /**
  24185. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24186. * This will be passed three parameters.
  24187. * This does nothing and may be overwritten by the user.
  24188. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24189. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24190. * @param update the boolean update value actually passed to setParticles()
  24191. */
  24192. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24193. }
  24194. }
  24195. declare module "babylonjs/Particles/solidParticle" {
  24196. import { Nullable } from "babylonjs/types";
  24197. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24198. import { Mesh } from "babylonjs/Meshes/mesh";
  24199. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24200. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24201. /**
  24202. * Represents one particle of a solid particle system.
  24203. */
  24204. export class SolidParticle {
  24205. /**
  24206. * particle global index
  24207. */
  24208. idx: number;
  24209. /**
  24210. * The color of the particle
  24211. */
  24212. color: Nullable<Color4>;
  24213. /**
  24214. * The world space position of the particle.
  24215. */
  24216. position: Vector3;
  24217. /**
  24218. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24219. */
  24220. rotation: Vector3;
  24221. /**
  24222. * The world space rotation quaternion of the particle.
  24223. */
  24224. rotationQuaternion: Nullable<Quaternion>;
  24225. /**
  24226. * The scaling of the particle.
  24227. */
  24228. scaling: Vector3;
  24229. /**
  24230. * The uvs of the particle.
  24231. */
  24232. uvs: Vector4;
  24233. /**
  24234. * The current speed of the particle.
  24235. */
  24236. velocity: Vector3;
  24237. /**
  24238. * The pivot point in the particle local space.
  24239. */
  24240. pivot: Vector3;
  24241. /**
  24242. * Must the particle be translated from its pivot point in its local space ?
  24243. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24244. * Default : false
  24245. */
  24246. translateFromPivot: boolean;
  24247. /**
  24248. * Is the particle active or not ?
  24249. */
  24250. alive: boolean;
  24251. /**
  24252. * Is the particle visible or not ?
  24253. */
  24254. isVisible: boolean;
  24255. /**
  24256. * Index of this particle in the global "positions" array (Internal use)
  24257. * @hidden
  24258. */
  24259. _pos: number;
  24260. /**
  24261. * @hidden Index of this particle in the global "indices" array (Internal use)
  24262. */
  24263. _ind: number;
  24264. /**
  24265. * @hidden ModelShape of this particle (Internal use)
  24266. */
  24267. _model: ModelShape;
  24268. /**
  24269. * ModelShape id of this particle
  24270. */
  24271. shapeId: number;
  24272. /**
  24273. * Index of the particle in its shape id (Internal use)
  24274. */
  24275. idxInShape: number;
  24276. /**
  24277. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24278. */
  24279. _modelBoundingInfo: BoundingInfo;
  24280. /**
  24281. * @hidden Particle BoundingInfo object (Internal use)
  24282. */
  24283. _boundingInfo: BoundingInfo;
  24284. /**
  24285. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24286. */
  24287. _sps: SolidParticleSystem;
  24288. /**
  24289. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24290. */
  24291. _stillInvisible: boolean;
  24292. /**
  24293. * @hidden Last computed particle rotation matrix
  24294. */
  24295. _rotationMatrix: number[];
  24296. /**
  24297. * Parent particle Id, if any.
  24298. * Default null.
  24299. */
  24300. parentId: Nullable<number>;
  24301. /**
  24302. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24303. * The possible values are :
  24304. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24305. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24306. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24307. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24308. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24309. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24310. * */
  24311. cullingStrategy: number;
  24312. /**
  24313. * @hidden Internal global position in the SPS.
  24314. */
  24315. _globalPosition: Vector3;
  24316. /**
  24317. * Creates a Solid Particle object.
  24318. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24319. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24320. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24321. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24322. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24323. * @param shapeId (integer) is the model shape identifier in the SPS.
  24324. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24325. * @param sps defines the sps it is associated to
  24326. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24327. */
  24328. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24329. /**
  24330. * Legacy support, changed scale to scaling
  24331. */
  24332. /**
  24333. * Legacy support, changed scale to scaling
  24334. */
  24335. scale: Vector3;
  24336. /**
  24337. * Legacy support, changed quaternion to rotationQuaternion
  24338. */
  24339. /**
  24340. * Legacy support, changed quaternion to rotationQuaternion
  24341. */
  24342. quaternion: Nullable<Quaternion>;
  24343. /**
  24344. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24345. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24346. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24347. * @returns true if it intersects
  24348. */
  24349. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24350. /**
  24351. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24352. * A particle is in the frustum if its bounding box intersects the frustum
  24353. * @param frustumPlanes defines the frustum to test
  24354. * @returns true if the particle is in the frustum planes
  24355. */
  24356. isInFrustum(frustumPlanes: Plane[]): boolean;
  24357. /**
  24358. * get the rotation matrix of the particle
  24359. * @hidden
  24360. */
  24361. getRotationMatrix(m: Matrix): void;
  24362. }
  24363. /**
  24364. * Represents the shape of the model used by one particle of a solid particle system.
  24365. * SPS internal tool, don't use it manually.
  24366. */
  24367. export class ModelShape {
  24368. /**
  24369. * The shape id
  24370. * @hidden
  24371. */
  24372. shapeID: number;
  24373. /**
  24374. * flat array of model positions (internal use)
  24375. * @hidden
  24376. */
  24377. _shape: Vector3[];
  24378. /**
  24379. * flat array of model UVs (internal use)
  24380. * @hidden
  24381. */
  24382. _shapeUV: number[];
  24383. /**
  24384. * length of the shape in the model indices array (internal use)
  24385. * @hidden
  24386. */
  24387. _indicesLength: number;
  24388. /**
  24389. * Custom position function (internal use)
  24390. * @hidden
  24391. */
  24392. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24393. /**
  24394. * Custom vertex function (internal use)
  24395. * @hidden
  24396. */
  24397. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24398. /**
  24399. * 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.
  24400. * SPS internal tool, don't use it manually.
  24401. * @hidden
  24402. */
  24403. 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>);
  24404. }
  24405. /**
  24406. * Represents a Depth Sorted Particle in the solid particle system.
  24407. */
  24408. export class DepthSortedParticle {
  24409. /**
  24410. * Index of the particle in the "indices" array
  24411. */
  24412. ind: number;
  24413. /**
  24414. * Length of the particle shape in the "indices" array
  24415. */
  24416. indicesLength: number;
  24417. /**
  24418. * Squared distance from the particle to the camera
  24419. */
  24420. sqDistance: number;
  24421. }
  24422. }
  24423. declare module "babylonjs/Meshes/abstractMesh" {
  24424. import { Observable } from "babylonjs/Misc/observable";
  24425. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24426. import { Camera } from "babylonjs/Cameras/camera";
  24427. import { Scene, IDisposable } from "babylonjs/scene";
  24428. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24429. import { Node } from "babylonjs/node";
  24430. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24431. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24432. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24433. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24434. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24435. import { Material } from "babylonjs/Materials/material";
  24436. import { Light } from "babylonjs/Lights/light";
  24437. import { Skeleton } from "babylonjs/Bones/skeleton";
  24438. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24439. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24440. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24441. import { Ray } from "babylonjs/Culling/ray";
  24442. import { Collider } from "babylonjs/Collisions/collider";
  24443. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24444. /**
  24445. * Class used to store all common mesh properties
  24446. */
  24447. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24448. /** No occlusion */
  24449. static OCCLUSION_TYPE_NONE: number;
  24450. /** Occlusion set to optimisitic */
  24451. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24452. /** Occlusion set to strict */
  24453. static OCCLUSION_TYPE_STRICT: number;
  24454. /** Use an accurante occlusion algorithm */
  24455. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24456. /** Use a conservative occlusion algorithm */
  24457. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24458. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24459. * Test order :
  24460. * Is the bounding sphere outside the frustum ?
  24461. * If not, are the bounding box vertices outside the frustum ?
  24462. * It not, then the cullable object is in the frustum.
  24463. */
  24464. static readonly CULLINGSTRATEGY_STANDARD: number;
  24465. /** Culling strategy : Bounding Sphere Only.
  24466. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24467. * It's also less accurate than the standard because some not visible objects can still be selected.
  24468. * Test : is the bounding sphere outside the frustum ?
  24469. * If not, then the cullable object is in the frustum.
  24470. */
  24471. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24472. /** Culling strategy : Optimistic Inclusion.
  24473. * This in an inclusion test first, then the standard exclusion test.
  24474. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24475. * 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.
  24476. * Anyway, it's as accurate as the standard strategy.
  24477. * Test :
  24478. * Is the cullable object bounding sphere center in the frustum ?
  24479. * If not, apply the default culling strategy.
  24480. */
  24481. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24482. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24483. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24484. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24485. * 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.
  24486. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24487. * Test :
  24488. * Is the cullable object bounding sphere center in the frustum ?
  24489. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24490. */
  24491. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24492. /**
  24493. * No billboard
  24494. */
  24495. static readonly BILLBOARDMODE_NONE: number;
  24496. /** Billboard on X axis */
  24497. static readonly BILLBOARDMODE_X: number;
  24498. /** Billboard on Y axis */
  24499. static readonly BILLBOARDMODE_Y: number;
  24500. /** Billboard on Z axis */
  24501. static readonly BILLBOARDMODE_Z: number;
  24502. /** Billboard on all axes */
  24503. static readonly BILLBOARDMODE_ALL: number;
  24504. private _facetData;
  24505. /**
  24506. * The culling strategy to use to check whether the mesh must be rendered or not.
  24507. * This value can be changed at any time and will be used on the next render mesh selection.
  24508. * The possible values are :
  24509. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24510. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24511. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24512. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24513. * Please read each static variable documentation to get details about the culling process.
  24514. * */
  24515. cullingStrategy: number;
  24516. /**
  24517. * Gets the number of facets in the mesh
  24518. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24519. */
  24520. readonly facetNb: number;
  24521. /**
  24522. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24523. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24524. */
  24525. partitioningSubdivisions: number;
  24526. /**
  24527. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24528. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24529. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24530. */
  24531. partitioningBBoxRatio: number;
  24532. /**
  24533. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24534. * Works only for updatable meshes.
  24535. * Doesn't work with multi-materials
  24536. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24537. */
  24538. mustDepthSortFacets: boolean;
  24539. /**
  24540. * The location (Vector3) where the facet depth sort must be computed from.
  24541. * By default, the active camera position.
  24542. * Used only when facet depth sort is enabled
  24543. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24544. */
  24545. facetDepthSortFrom: Vector3;
  24546. /**
  24547. * gets a boolean indicating if facetData is enabled
  24548. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24549. */
  24550. readonly isFacetDataEnabled: boolean;
  24551. /** @hidden */
  24552. _updateNonUniformScalingState(value: boolean): boolean;
  24553. /**
  24554. * An event triggered when this mesh collides with another one
  24555. */
  24556. onCollideObservable: Observable<AbstractMesh>;
  24557. private _onCollideObserver;
  24558. /** Set a function to call when this mesh collides with another one */
  24559. onCollide: () => void;
  24560. /**
  24561. * An event triggered when the collision's position changes
  24562. */
  24563. onCollisionPositionChangeObservable: Observable<Vector3>;
  24564. private _onCollisionPositionChangeObserver;
  24565. /** Set a function to call when the collision's position changes */
  24566. onCollisionPositionChange: () => void;
  24567. /**
  24568. * An event triggered when material is changed
  24569. */
  24570. onMaterialChangedObservable: Observable<AbstractMesh>;
  24571. /**
  24572. * Gets or sets the orientation for POV movement & rotation
  24573. */
  24574. definedFacingForward: boolean;
  24575. /** @hidden */
  24576. _occlusionQuery: Nullable<WebGLQuery>;
  24577. private _visibility;
  24578. /**
  24579. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24580. */
  24581. /**
  24582. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24583. */
  24584. visibility: number;
  24585. /** Gets or sets the alpha index used to sort transparent meshes
  24586. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24587. */
  24588. alphaIndex: number;
  24589. /**
  24590. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24591. */
  24592. isVisible: boolean;
  24593. /**
  24594. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24595. */
  24596. isPickable: boolean;
  24597. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24598. showSubMeshesBoundingBox: boolean;
  24599. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24600. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24601. */
  24602. isBlocker: boolean;
  24603. /**
  24604. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24605. */
  24606. enablePointerMoveEvents: boolean;
  24607. /**
  24608. * Specifies the rendering group id for this mesh (0 by default)
  24609. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24610. */
  24611. renderingGroupId: number;
  24612. private _material;
  24613. /** Gets or sets current material */
  24614. material: Nullable<Material>;
  24615. private _receiveShadows;
  24616. /**
  24617. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24618. * @see http://doc.babylonjs.com/babylon101/shadows
  24619. */
  24620. receiveShadows: boolean;
  24621. /** Defines color to use when rendering outline */
  24622. outlineColor: Color3;
  24623. /** Define width to use when rendering outline */
  24624. outlineWidth: number;
  24625. /** Defines color to use when rendering overlay */
  24626. overlayColor: Color3;
  24627. /** Defines alpha to use when rendering overlay */
  24628. overlayAlpha: number;
  24629. private _hasVertexAlpha;
  24630. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24631. hasVertexAlpha: boolean;
  24632. private _useVertexColors;
  24633. /** 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) */
  24634. useVertexColors: boolean;
  24635. private _computeBonesUsingShaders;
  24636. /**
  24637. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24638. */
  24639. computeBonesUsingShaders: boolean;
  24640. private _numBoneInfluencers;
  24641. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24642. numBoneInfluencers: number;
  24643. private _applyFog;
  24644. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24645. applyFog: boolean;
  24646. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24647. useOctreeForRenderingSelection: boolean;
  24648. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24649. useOctreeForPicking: boolean;
  24650. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24651. useOctreeForCollisions: boolean;
  24652. private _layerMask;
  24653. /**
  24654. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24655. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24656. */
  24657. layerMask: number;
  24658. /**
  24659. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24660. */
  24661. alwaysSelectAsActiveMesh: boolean;
  24662. /**
  24663. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24664. */
  24665. doNotSyncBoundingInfo: boolean;
  24666. /**
  24667. * Gets or sets the current action manager
  24668. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24669. */
  24670. actionManager: Nullable<AbstractActionManager>;
  24671. private _checkCollisions;
  24672. private _collisionMask;
  24673. private _collisionGroup;
  24674. /**
  24675. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24676. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24677. */
  24678. ellipsoid: Vector3;
  24679. /**
  24680. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24681. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24682. */
  24683. ellipsoidOffset: Vector3;
  24684. private _collider;
  24685. private _oldPositionForCollisions;
  24686. private _diffPositionForCollisions;
  24687. /**
  24688. * Gets or sets a collision mask used to mask collisions (default is -1).
  24689. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24690. */
  24691. collisionMask: number;
  24692. /**
  24693. * Gets or sets the current collision group mask (-1 by default).
  24694. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24695. */
  24696. collisionGroup: number;
  24697. /**
  24698. * Defines edge width used when edgesRenderer is enabled
  24699. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24700. */
  24701. edgesWidth: number;
  24702. /**
  24703. * Defines edge color used when edgesRenderer is enabled
  24704. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24705. */
  24706. edgesColor: Color4;
  24707. /** @hidden */
  24708. _edgesRenderer: Nullable<IEdgesRenderer>;
  24709. /** @hidden */
  24710. _masterMesh: Nullable<AbstractMesh>;
  24711. /** @hidden */
  24712. _boundingInfo: Nullable<BoundingInfo>;
  24713. /** @hidden */
  24714. _renderId: number;
  24715. /**
  24716. * Gets or sets the list of subMeshes
  24717. * @see http://doc.babylonjs.com/how_to/multi_materials
  24718. */
  24719. subMeshes: SubMesh[];
  24720. /** @hidden */
  24721. _intersectionsInProgress: AbstractMesh[];
  24722. /** @hidden */
  24723. _unIndexed: boolean;
  24724. /** @hidden */
  24725. _lightSources: Light[];
  24726. /** @hidden */
  24727. readonly _positions: Nullable<Vector3[]>;
  24728. /** @hidden */
  24729. _waitingActions: any;
  24730. /** @hidden */
  24731. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24732. private _skeleton;
  24733. /** @hidden */
  24734. _bonesTransformMatrices: Nullable<Float32Array>;
  24735. /**
  24736. * Gets or sets a skeleton to apply skining transformations
  24737. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24738. */
  24739. skeleton: Nullable<Skeleton>;
  24740. /**
  24741. * An event triggered when the mesh is rebuilt.
  24742. */
  24743. onRebuildObservable: Observable<AbstractMesh>;
  24744. /**
  24745. * Creates a new AbstractMesh
  24746. * @param name defines the name of the mesh
  24747. * @param scene defines the hosting scene
  24748. */
  24749. constructor(name: string, scene?: Nullable<Scene>);
  24750. /**
  24751. * Returns the string "AbstractMesh"
  24752. * @returns "AbstractMesh"
  24753. */
  24754. getClassName(): string;
  24755. /**
  24756. * Gets a string representation of the current mesh
  24757. * @param fullDetails defines a boolean indicating if full details must be included
  24758. * @returns a string representation of the current mesh
  24759. */
  24760. toString(fullDetails?: boolean): string;
  24761. /**
  24762. * @hidden
  24763. */
  24764. protected _getEffectiveParent(): Nullable<Node>;
  24765. /** @hidden */
  24766. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24767. /** @hidden */
  24768. _rebuild(): void;
  24769. /** @hidden */
  24770. _resyncLightSources(): void;
  24771. /** @hidden */
  24772. _resyncLighSource(light: Light): void;
  24773. /** @hidden */
  24774. _unBindEffect(): void;
  24775. /** @hidden */
  24776. _removeLightSource(light: Light): void;
  24777. private _markSubMeshesAsDirty;
  24778. /** @hidden */
  24779. _markSubMeshesAsLightDirty(): void;
  24780. /** @hidden */
  24781. _markSubMeshesAsAttributesDirty(): void;
  24782. /** @hidden */
  24783. _markSubMeshesAsMiscDirty(): void;
  24784. /**
  24785. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24786. */
  24787. scaling: Vector3;
  24788. /**
  24789. * Returns true if the mesh is blocked. Implemented by child classes
  24790. */
  24791. readonly isBlocked: boolean;
  24792. /**
  24793. * Returns the mesh itself by default. Implemented by child classes
  24794. * @param camera defines the camera to use to pick the right LOD level
  24795. * @returns the currentAbstractMesh
  24796. */
  24797. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24798. /**
  24799. * Returns 0 by default. Implemented by child classes
  24800. * @returns an integer
  24801. */
  24802. getTotalVertices(): number;
  24803. /**
  24804. * Returns a positive integer : the total number of indices in this mesh geometry.
  24805. * @returns the numner of indices or zero if the mesh has no geometry.
  24806. */
  24807. getTotalIndices(): number;
  24808. /**
  24809. * Returns null by default. Implemented by child classes
  24810. * @returns null
  24811. */
  24812. getIndices(): Nullable<IndicesArray>;
  24813. /**
  24814. * Returns the array of the requested vertex data kind. Implemented by child classes
  24815. * @param kind defines the vertex data kind to use
  24816. * @returns null
  24817. */
  24818. getVerticesData(kind: string): Nullable<FloatArray>;
  24819. /**
  24820. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24821. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24822. * Note that a new underlying VertexBuffer object is created each call.
  24823. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24824. * @param kind defines vertex data kind:
  24825. * * VertexBuffer.PositionKind
  24826. * * VertexBuffer.UVKind
  24827. * * VertexBuffer.UV2Kind
  24828. * * VertexBuffer.UV3Kind
  24829. * * VertexBuffer.UV4Kind
  24830. * * VertexBuffer.UV5Kind
  24831. * * VertexBuffer.UV6Kind
  24832. * * VertexBuffer.ColorKind
  24833. * * VertexBuffer.MatricesIndicesKind
  24834. * * VertexBuffer.MatricesIndicesExtraKind
  24835. * * VertexBuffer.MatricesWeightsKind
  24836. * * VertexBuffer.MatricesWeightsExtraKind
  24837. * @param data defines the data source
  24838. * @param updatable defines if the data must be flagged as updatable (or static)
  24839. * @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
  24840. * @returns the current mesh
  24841. */
  24842. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24843. /**
  24844. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24845. * If the mesh has no geometry, it is simply returned as it is.
  24846. * @param kind defines vertex data kind:
  24847. * * VertexBuffer.PositionKind
  24848. * * VertexBuffer.UVKind
  24849. * * VertexBuffer.UV2Kind
  24850. * * VertexBuffer.UV3Kind
  24851. * * VertexBuffer.UV4Kind
  24852. * * VertexBuffer.UV5Kind
  24853. * * VertexBuffer.UV6Kind
  24854. * * VertexBuffer.ColorKind
  24855. * * VertexBuffer.MatricesIndicesKind
  24856. * * VertexBuffer.MatricesIndicesExtraKind
  24857. * * VertexBuffer.MatricesWeightsKind
  24858. * * VertexBuffer.MatricesWeightsExtraKind
  24859. * @param data defines the data source
  24860. * @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
  24861. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24862. * @returns the current mesh
  24863. */
  24864. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24865. /**
  24866. * Sets the mesh indices,
  24867. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24868. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24869. * @param totalVertices Defines the total number of vertices
  24870. * @returns the current mesh
  24871. */
  24872. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24873. /**
  24874. * Gets a boolean indicating if specific vertex data is present
  24875. * @param kind defines the vertex data kind to use
  24876. * @returns true is data kind is present
  24877. */
  24878. isVerticesDataPresent(kind: string): boolean;
  24879. /**
  24880. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24881. * @returns a BoundingInfo
  24882. */
  24883. getBoundingInfo(): BoundingInfo;
  24884. /**
  24885. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24886. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24887. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24888. * @returns the current mesh
  24889. */
  24890. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24891. /**
  24892. * Overwrite the current bounding info
  24893. * @param boundingInfo defines the new bounding info
  24894. * @returns the current mesh
  24895. */
  24896. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24897. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24898. readonly useBones: boolean;
  24899. /** @hidden */
  24900. _preActivate(): void;
  24901. /** @hidden */
  24902. _preActivateForIntermediateRendering(renderId: number): void;
  24903. /** @hidden */
  24904. _activate(renderId: number): void;
  24905. /**
  24906. * Gets the current world matrix
  24907. * @returns a Matrix
  24908. */
  24909. getWorldMatrix(): Matrix;
  24910. /** @hidden */
  24911. _getWorldMatrixDeterminant(): number;
  24912. /**
  24913. * Perform relative position change from the point of view of behind the front of the mesh.
  24914. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24915. * Supports definition of mesh facing forward or backward
  24916. * @param amountRight defines the distance on the right axis
  24917. * @param amountUp defines the distance on the up axis
  24918. * @param amountForward defines the distance on the forward axis
  24919. * @returns the current mesh
  24920. */
  24921. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24922. /**
  24923. * Calculate relative position change from the point of view of behind the front of the mesh.
  24924. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24925. * Supports definition of mesh facing forward or backward
  24926. * @param amountRight defines the distance on the right axis
  24927. * @param amountUp defines the distance on the up axis
  24928. * @param amountForward defines the distance on the forward axis
  24929. * @returns the new displacement vector
  24930. */
  24931. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24932. /**
  24933. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24934. * Supports definition of mesh facing forward or backward
  24935. * @param flipBack defines the flip
  24936. * @param twirlClockwise defines the twirl
  24937. * @param tiltRight defines the tilt
  24938. * @returns the current mesh
  24939. */
  24940. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24941. /**
  24942. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24943. * Supports definition of mesh facing forward or backward.
  24944. * @param flipBack defines the flip
  24945. * @param twirlClockwise defines the twirl
  24946. * @param tiltRight defines the tilt
  24947. * @returns the new rotation vector
  24948. */
  24949. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24950. /**
  24951. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24952. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24953. * @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
  24954. * @returns the new bounding vectors
  24955. */
  24956. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24957. min: Vector3;
  24958. max: Vector3;
  24959. };
  24960. /**
  24961. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24962. * This means the mesh underlying bounding box and sphere are recomputed.
  24963. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24964. * @returns the current mesh
  24965. */
  24966. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24967. /** @hidden */
  24968. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24969. /** @hidden */
  24970. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24971. /** @hidden */
  24972. _updateBoundingInfo(): AbstractMesh;
  24973. /** @hidden */
  24974. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24975. /** @hidden */
  24976. protected _afterComputeWorldMatrix(): void;
  24977. /** @hidden */
  24978. readonly _effectiveMesh: AbstractMesh;
  24979. /**
  24980. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24981. * A mesh is in the frustum if its bounding box intersects the frustum
  24982. * @param frustumPlanes defines the frustum to test
  24983. * @returns true if the mesh is in the frustum planes
  24984. */
  24985. isInFrustum(frustumPlanes: Plane[]): boolean;
  24986. /**
  24987. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24988. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24989. * @param frustumPlanes defines the frustum to test
  24990. * @returns true if the mesh is completely in the frustum planes
  24991. */
  24992. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24993. /**
  24994. * True if the mesh intersects another mesh or a SolidParticle object
  24995. * @param mesh defines a target mesh or SolidParticle to test
  24996. * @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)
  24997. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24998. * @returns true if there is an intersection
  24999. */
  25000. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25001. /**
  25002. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25003. * @param point defines the point to test
  25004. * @returns true if there is an intersection
  25005. */
  25006. intersectsPoint(point: Vector3): boolean;
  25007. /**
  25008. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25009. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25010. */
  25011. checkCollisions: boolean;
  25012. /**
  25013. * Gets Collider object used to compute collisions (not physics)
  25014. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25015. */
  25016. readonly collider: Collider;
  25017. /**
  25018. * Move the mesh using collision engine
  25019. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25020. * @param displacement defines the requested displacement vector
  25021. * @returns the current mesh
  25022. */
  25023. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25024. private _onCollisionPositionChange;
  25025. /** @hidden */
  25026. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25027. /** @hidden */
  25028. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25029. /** @hidden */
  25030. _checkCollision(collider: Collider): AbstractMesh;
  25031. /** @hidden */
  25032. _generatePointsArray(): boolean;
  25033. /**
  25034. * Checks if the passed Ray intersects with the mesh
  25035. * @param ray defines the ray to use
  25036. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25037. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25038. * @returns the picking info
  25039. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25040. */
  25041. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25042. /**
  25043. * Clones the current mesh
  25044. * @param name defines the mesh name
  25045. * @param newParent defines the new mesh parent
  25046. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25047. * @returns the new mesh
  25048. */
  25049. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25050. /**
  25051. * Disposes all the submeshes of the current meshnp
  25052. * @returns the current mesh
  25053. */
  25054. releaseSubMeshes(): AbstractMesh;
  25055. /**
  25056. * Releases resources associated with this abstract mesh.
  25057. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25058. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25059. */
  25060. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25061. /**
  25062. * Adds the passed mesh as a child to the current mesh
  25063. * @param mesh defines the child mesh
  25064. * @returns the current mesh
  25065. */
  25066. addChild(mesh: AbstractMesh): AbstractMesh;
  25067. /**
  25068. * Removes the passed mesh from the current mesh children list
  25069. * @param mesh defines the child mesh
  25070. * @returns the current mesh
  25071. */
  25072. removeChild(mesh: AbstractMesh): AbstractMesh;
  25073. /** @hidden */
  25074. private _initFacetData;
  25075. /**
  25076. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25077. * This method can be called within the render loop.
  25078. * 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
  25079. * @returns the current mesh
  25080. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25081. */
  25082. updateFacetData(): AbstractMesh;
  25083. /**
  25084. * Returns the facetLocalNormals array.
  25085. * The normals are expressed in the mesh local spac
  25086. * @returns an array of Vector3
  25087. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25088. */
  25089. getFacetLocalNormals(): Vector3[];
  25090. /**
  25091. * Returns the facetLocalPositions array.
  25092. * The facet positions are expressed in the mesh local space
  25093. * @returns an array of Vector3
  25094. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25095. */
  25096. getFacetLocalPositions(): Vector3[];
  25097. /**
  25098. * Returns the facetLocalPartioning array
  25099. * @returns an array of array of numbers
  25100. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25101. */
  25102. getFacetLocalPartitioning(): number[][];
  25103. /**
  25104. * Returns the i-th facet position in the world system.
  25105. * This method allocates a new Vector3 per call
  25106. * @param i defines the facet index
  25107. * @returns a new Vector3
  25108. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25109. */
  25110. getFacetPosition(i: number): Vector3;
  25111. /**
  25112. * Sets the reference Vector3 with the i-th facet position in the world system
  25113. * @param i defines the facet index
  25114. * @param ref defines the target vector
  25115. * @returns the current mesh
  25116. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25117. */
  25118. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25119. /**
  25120. * Returns the i-th facet normal in the world system.
  25121. * This method allocates a new Vector3 per call
  25122. * @param i defines the facet index
  25123. * @returns a new Vector3
  25124. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25125. */
  25126. getFacetNormal(i: number): Vector3;
  25127. /**
  25128. * Sets the reference Vector3 with the i-th facet normal in the world system
  25129. * @param i defines the facet index
  25130. * @param ref defines the target vector
  25131. * @returns the current mesh
  25132. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25133. */
  25134. getFacetNormalToRef(i: number, ref: Vector3): this;
  25135. /**
  25136. * 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)
  25137. * @param x defines x coordinate
  25138. * @param y defines y coordinate
  25139. * @param z defines z coordinate
  25140. * @returns the array of facet indexes
  25141. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25142. */
  25143. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25144. /**
  25145. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25146. * @param projected sets as the (x,y,z) world projection on the facet
  25147. * @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
  25148. * @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
  25149. * @param x defines x coordinate
  25150. * @param y defines y coordinate
  25151. * @param z defines z coordinate
  25152. * @returns the face index if found (or null instead)
  25153. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25154. */
  25155. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25156. /**
  25157. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25158. * @param projected sets as the (x,y,z) local projection on the facet
  25159. * @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
  25160. * @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
  25161. * @param x defines x coordinate
  25162. * @param y defines y coordinate
  25163. * @param z defines z coordinate
  25164. * @returns the face index if found (or null instead)
  25165. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25166. */
  25167. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25168. /**
  25169. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25170. * @returns the parameters
  25171. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25172. */
  25173. getFacetDataParameters(): any;
  25174. /**
  25175. * Disables the feature FacetData and frees the related memory
  25176. * @returns the current mesh
  25177. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25178. */
  25179. disableFacetData(): AbstractMesh;
  25180. /**
  25181. * Updates the AbstractMesh indices array
  25182. * @param indices defines the data source
  25183. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25184. * @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)
  25185. * @returns the current mesh
  25186. */
  25187. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25188. /**
  25189. * Creates new normals data for the mesh
  25190. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25191. * @returns the current mesh
  25192. */
  25193. createNormals(updatable: boolean): AbstractMesh;
  25194. /**
  25195. * Align the mesh with a normal
  25196. * @param normal defines the normal to use
  25197. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25198. * @returns the current mesh
  25199. */
  25200. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25201. /** @hidden */
  25202. _checkOcclusionQuery(): boolean;
  25203. }
  25204. }
  25205. declare module "babylonjs/Actions/actionEvent" {
  25206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25207. import { Nullable } from "babylonjs/types";
  25208. import { Sprite } from "babylonjs/Sprites/sprite";
  25209. import { Scene } from "babylonjs/scene";
  25210. import { Vector2 } from "babylonjs/Maths/math";
  25211. /**
  25212. * Interface used to define ActionEvent
  25213. */
  25214. export interface IActionEvent {
  25215. /** The mesh or sprite that triggered the action */
  25216. source: any;
  25217. /** The X mouse cursor position at the time of the event */
  25218. pointerX: number;
  25219. /** The Y mouse cursor position at the time of the event */
  25220. pointerY: number;
  25221. /** The mesh that is currently pointed at (can be null) */
  25222. meshUnderPointer: Nullable<AbstractMesh>;
  25223. /** the original (browser) event that triggered the ActionEvent */
  25224. sourceEvent?: any;
  25225. /** additional data for the event */
  25226. additionalData?: any;
  25227. }
  25228. /**
  25229. * ActionEvent is the event being sent when an action is triggered.
  25230. */
  25231. export class ActionEvent implements IActionEvent {
  25232. /** The mesh or sprite that triggered the action */
  25233. source: any;
  25234. /** The X mouse cursor position at the time of the event */
  25235. pointerX: number;
  25236. /** The Y mouse cursor position at the time of the event */
  25237. pointerY: number;
  25238. /** The mesh that is currently pointed at (can be null) */
  25239. meshUnderPointer: Nullable<AbstractMesh>;
  25240. /** the original (browser) event that triggered the ActionEvent */
  25241. sourceEvent?: any;
  25242. /** additional data for the event */
  25243. additionalData?: any;
  25244. /**
  25245. * Creates a new ActionEvent
  25246. * @param source The mesh or sprite that triggered the action
  25247. * @param pointerX The X mouse cursor position at the time of the event
  25248. * @param pointerY The Y mouse cursor position at the time of the event
  25249. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25250. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25251. * @param additionalData additional data for the event
  25252. */
  25253. constructor(
  25254. /** The mesh or sprite that triggered the action */
  25255. source: any,
  25256. /** The X mouse cursor position at the time of the event */
  25257. pointerX: number,
  25258. /** The Y mouse cursor position at the time of the event */
  25259. pointerY: number,
  25260. /** The mesh that is currently pointed at (can be null) */
  25261. meshUnderPointer: Nullable<AbstractMesh>,
  25262. /** the original (browser) event that triggered the ActionEvent */
  25263. sourceEvent?: any,
  25264. /** additional data for the event */
  25265. additionalData?: any);
  25266. /**
  25267. * Helper function to auto-create an ActionEvent from a source mesh.
  25268. * @param source The source mesh that triggered the event
  25269. * @param evt The original (browser) event
  25270. * @param additionalData additional data for the event
  25271. * @returns the new ActionEvent
  25272. */
  25273. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25274. /**
  25275. * Helper function to auto-create an ActionEvent from a source sprite
  25276. * @param source The source sprite that triggered the event
  25277. * @param scene Scene associated with the sprite
  25278. * @param evt The original (browser) event
  25279. * @param additionalData additional data for the event
  25280. * @returns the new ActionEvent
  25281. */
  25282. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25283. /**
  25284. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25285. * @param scene the scene where the event occurred
  25286. * @param evt The original (browser) event
  25287. * @returns the new ActionEvent
  25288. */
  25289. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25290. /**
  25291. * Helper function to auto-create an ActionEvent from a primitive
  25292. * @param prim defines the target primitive
  25293. * @param pointerPos defines the pointer position
  25294. * @param evt The original (browser) event
  25295. * @param additionalData additional data for the event
  25296. * @returns the new ActionEvent
  25297. */
  25298. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25299. }
  25300. }
  25301. declare module "babylonjs/Actions/abstractActionManager" {
  25302. import { IDisposable } from "babylonjs/scene";
  25303. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25304. import { IAction } from "babylonjs/Actions/action";
  25305. import { Nullable } from "babylonjs/types";
  25306. /**
  25307. * Abstract class used to decouple action Manager from scene and meshes.
  25308. * Do not instantiate.
  25309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25310. */
  25311. export abstract class AbstractActionManager implements IDisposable {
  25312. /** Gets the list of active triggers */
  25313. static Triggers: {
  25314. [key: string]: number;
  25315. };
  25316. /** Gets the cursor to use when hovering items */
  25317. hoverCursor: string;
  25318. /** Gets the list of actions */
  25319. actions: IAction[];
  25320. /**
  25321. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25322. */
  25323. isRecursive: boolean;
  25324. /**
  25325. * Releases all associated resources
  25326. */
  25327. abstract dispose(): void;
  25328. /**
  25329. * Does this action manager has pointer triggers
  25330. */
  25331. abstract readonly hasPointerTriggers: boolean;
  25332. /**
  25333. * Does this action manager has pick triggers
  25334. */
  25335. abstract readonly hasPickTriggers: boolean;
  25336. /**
  25337. * Process a specific trigger
  25338. * @param trigger defines the trigger to process
  25339. * @param evt defines the event details to be processed
  25340. */
  25341. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25342. /**
  25343. * Does this action manager handles actions of any of the given triggers
  25344. * @param triggers defines the triggers to be tested
  25345. * @return a boolean indicating whether one (or more) of the triggers is handled
  25346. */
  25347. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25348. /**
  25349. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25350. * speed.
  25351. * @param triggerA defines the trigger to be tested
  25352. * @param triggerB defines the trigger to be tested
  25353. * @return a boolean indicating whether one (or more) of the triggers is handled
  25354. */
  25355. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25356. /**
  25357. * Does this action manager handles actions of a given trigger
  25358. * @param trigger defines the trigger to be tested
  25359. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25360. * @return whether the trigger is handled
  25361. */
  25362. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25363. /**
  25364. * Serialize this manager to a JSON object
  25365. * @param name defines the property name to store this manager
  25366. * @returns a JSON representation of this manager
  25367. */
  25368. abstract serialize(name: string): any;
  25369. /**
  25370. * Registers an action to this action manager
  25371. * @param action defines the action to be registered
  25372. * @return the action amended (prepared) after registration
  25373. */
  25374. abstract registerAction(action: IAction): Nullable<IAction>;
  25375. /**
  25376. * Unregisters an action to this action manager
  25377. * @param action defines the action to be unregistered
  25378. * @return a boolean indicating whether the action has been unregistered
  25379. */
  25380. abstract unregisterAction(action: IAction): Boolean;
  25381. /**
  25382. * Does exist one action manager with at least one trigger
  25383. **/
  25384. static readonly HasTriggers: boolean;
  25385. /**
  25386. * Does exist one action manager with at least one pick trigger
  25387. **/
  25388. static readonly HasPickTriggers: boolean;
  25389. /**
  25390. * Does exist one action manager that handles actions of a given trigger
  25391. * @param trigger defines the trigger to be tested
  25392. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25393. **/
  25394. static HasSpecificTrigger(trigger: number): boolean;
  25395. }
  25396. }
  25397. declare module "babylonjs/node" {
  25398. import { Scene } from "babylonjs/scene";
  25399. import { Nullable } from "babylonjs/types";
  25400. import { Matrix } from "babylonjs/Maths/math";
  25401. import { Engine } from "babylonjs/Engines/engine";
  25402. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25403. import { Observable } from "babylonjs/Misc/observable";
  25404. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25405. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25406. import { Animatable } from "babylonjs/Animations/animatable";
  25407. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25408. import { Animation } from "babylonjs/Animations/animation";
  25409. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25411. /**
  25412. * Defines how a node can be built from a string name.
  25413. */
  25414. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25415. /**
  25416. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25417. */
  25418. export class Node implements IBehaviorAware<Node> {
  25419. /** @hidden */
  25420. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25421. private static _NodeConstructors;
  25422. /**
  25423. * Add a new node constructor
  25424. * @param type defines the type name of the node to construct
  25425. * @param constructorFunc defines the constructor function
  25426. */
  25427. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25428. /**
  25429. * Returns a node constructor based on type name
  25430. * @param type defines the type name
  25431. * @param name defines the new node name
  25432. * @param scene defines the hosting scene
  25433. * @param options defines optional options to transmit to constructors
  25434. * @returns the new constructor or null
  25435. */
  25436. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25437. /**
  25438. * Gets or sets the name of the node
  25439. */
  25440. name: string;
  25441. /**
  25442. * Gets or sets the id of the node
  25443. */
  25444. id: string;
  25445. /**
  25446. * Gets or sets the unique id of the node
  25447. */
  25448. uniqueId: number;
  25449. /**
  25450. * Gets or sets a string used to store user defined state for the node
  25451. */
  25452. state: string;
  25453. /**
  25454. * Gets or sets an object used to store user defined information for the node
  25455. */
  25456. metadata: any;
  25457. /**
  25458. * For internal use only. Please do not use.
  25459. */
  25460. reservedDataStore: any;
  25461. /**
  25462. * List of inspectable custom properties (used by the Inspector)
  25463. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25464. */
  25465. inspectableCustomProperties: IInspectable[];
  25466. /**
  25467. * Gets or sets a boolean used to define if the node must be serialized
  25468. */
  25469. doNotSerialize: boolean;
  25470. /** @hidden */
  25471. _isDisposed: boolean;
  25472. /**
  25473. * Gets a list of Animations associated with the node
  25474. */
  25475. animations: import("babylonjs/Animations/animation").Animation[];
  25476. protected _ranges: {
  25477. [name: string]: Nullable<AnimationRange>;
  25478. };
  25479. /**
  25480. * Callback raised when the node is ready to be used
  25481. */
  25482. onReady: (node: Node) => void;
  25483. private _isEnabled;
  25484. private _isParentEnabled;
  25485. private _isReady;
  25486. /** @hidden */
  25487. _currentRenderId: number;
  25488. private _parentUpdateId;
  25489. protected _childUpdateId: number;
  25490. /** @hidden */
  25491. _waitingParentId: Nullable<string>;
  25492. /** @hidden */
  25493. _scene: Scene;
  25494. /** @hidden */
  25495. _cache: any;
  25496. private _parentNode;
  25497. private _children;
  25498. /** @hidden */
  25499. _worldMatrix: Matrix;
  25500. /** @hidden */
  25501. _worldMatrixDeterminant: number;
  25502. /** @hidden */
  25503. _worldMatrixDeterminantIsDirty: boolean;
  25504. /** @hidden */
  25505. private _sceneRootNodesIndex;
  25506. /**
  25507. * Gets a boolean indicating if the node has been disposed
  25508. * @returns true if the node was disposed
  25509. */
  25510. isDisposed(): boolean;
  25511. /**
  25512. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25513. * @see https://doc.babylonjs.com/how_to/parenting
  25514. */
  25515. parent: Nullable<Node>;
  25516. private addToSceneRootNodes;
  25517. private removeFromSceneRootNodes;
  25518. private _animationPropertiesOverride;
  25519. /**
  25520. * Gets or sets the animation properties override
  25521. */
  25522. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25523. /**
  25524. * Gets a string idenfifying the name of the class
  25525. * @returns "Node" string
  25526. */
  25527. getClassName(): string;
  25528. /** @hidden */
  25529. readonly _isNode: boolean;
  25530. /**
  25531. * An event triggered when the mesh is disposed
  25532. */
  25533. onDisposeObservable: Observable<Node>;
  25534. private _onDisposeObserver;
  25535. /**
  25536. * Sets a callback that will be raised when the node will be disposed
  25537. */
  25538. onDispose: () => void;
  25539. /**
  25540. * Creates a new Node
  25541. * @param name the name and id to be given to this node
  25542. * @param scene the scene this node will be added to
  25543. * @param addToRootNodes the node will be added to scene.rootNodes
  25544. */
  25545. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25546. /**
  25547. * Gets the scene of the node
  25548. * @returns a scene
  25549. */
  25550. getScene(): Scene;
  25551. /**
  25552. * Gets the engine of the node
  25553. * @returns a Engine
  25554. */
  25555. getEngine(): Engine;
  25556. private _behaviors;
  25557. /**
  25558. * Attach a behavior to the node
  25559. * @see http://doc.babylonjs.com/features/behaviour
  25560. * @param behavior defines the behavior to attach
  25561. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25562. * @returns the current Node
  25563. */
  25564. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25565. /**
  25566. * Remove an attached behavior
  25567. * @see http://doc.babylonjs.com/features/behaviour
  25568. * @param behavior defines the behavior to attach
  25569. * @returns the current Node
  25570. */
  25571. removeBehavior(behavior: Behavior<Node>): Node;
  25572. /**
  25573. * Gets the list of attached behaviors
  25574. * @see http://doc.babylonjs.com/features/behaviour
  25575. */
  25576. readonly behaviors: Behavior<Node>[];
  25577. /**
  25578. * Gets an attached behavior by name
  25579. * @param name defines the name of the behavior to look for
  25580. * @see http://doc.babylonjs.com/features/behaviour
  25581. * @returns null if behavior was not found else the requested behavior
  25582. */
  25583. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25584. /**
  25585. * Returns the latest update of the World matrix
  25586. * @returns a Matrix
  25587. */
  25588. getWorldMatrix(): Matrix;
  25589. /** @hidden */
  25590. _getWorldMatrixDeterminant(): number;
  25591. /**
  25592. * Returns directly the latest state of the mesh World matrix.
  25593. * A Matrix is returned.
  25594. */
  25595. readonly worldMatrixFromCache: Matrix;
  25596. /** @hidden */
  25597. _initCache(): void;
  25598. /** @hidden */
  25599. updateCache(force?: boolean): void;
  25600. /** @hidden */
  25601. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25602. /** @hidden */
  25603. _updateCache(ignoreParentClass?: boolean): void;
  25604. /** @hidden */
  25605. _isSynchronized(): boolean;
  25606. /** @hidden */
  25607. _markSyncedWithParent(): void;
  25608. /** @hidden */
  25609. isSynchronizedWithParent(): boolean;
  25610. /** @hidden */
  25611. isSynchronized(): boolean;
  25612. /**
  25613. * Is this node ready to be used/rendered
  25614. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25615. * @return true if the node is ready
  25616. */
  25617. isReady(completeCheck?: boolean): boolean;
  25618. /**
  25619. * Is this node enabled?
  25620. * 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
  25621. * @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
  25622. * @return whether this node (and its parent) is enabled
  25623. */
  25624. isEnabled(checkAncestors?: boolean): boolean;
  25625. /** @hidden */
  25626. protected _syncParentEnabledState(): void;
  25627. /**
  25628. * Set the enabled state of this node
  25629. * @param value defines the new enabled state
  25630. */
  25631. setEnabled(value: boolean): void;
  25632. /**
  25633. * Is this node a descendant of the given node?
  25634. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25635. * @param ancestor defines the parent node to inspect
  25636. * @returns a boolean indicating if this node is a descendant of the given node
  25637. */
  25638. isDescendantOf(ancestor: Node): boolean;
  25639. /** @hidden */
  25640. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25641. /**
  25642. * Will return all nodes that have this node as ascendant
  25643. * @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
  25644. * @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
  25645. * @return all children nodes of all types
  25646. */
  25647. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25648. /**
  25649. * Get all child-meshes of this node
  25650. * @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)
  25651. * @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
  25652. * @returns an array of AbstractMesh
  25653. */
  25654. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25655. /**
  25656. * Get all direct children of this node
  25657. * @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
  25658. * @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)
  25659. * @returns an array of Node
  25660. */
  25661. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25662. /** @hidden */
  25663. _setReady(state: boolean): void;
  25664. /**
  25665. * Get an animation by name
  25666. * @param name defines the name of the animation to look for
  25667. * @returns null if not found else the requested animation
  25668. */
  25669. getAnimationByName(name: string): Nullable<Animation>;
  25670. /**
  25671. * Creates an animation range for this node
  25672. * @param name defines the name of the range
  25673. * @param from defines the starting key
  25674. * @param to defines the end key
  25675. */
  25676. createAnimationRange(name: string, from: number, to: number): void;
  25677. /**
  25678. * Delete a specific animation range
  25679. * @param name defines the name of the range to delete
  25680. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25681. */
  25682. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25683. /**
  25684. * Get an animation range by name
  25685. * @param name defines the name of the animation range to look for
  25686. * @returns null if not found else the requested animation range
  25687. */
  25688. getAnimationRange(name: string): Nullable<AnimationRange>;
  25689. /**
  25690. * Gets the list of all animation ranges defined on this node
  25691. * @returns an array
  25692. */
  25693. getAnimationRanges(): Nullable<AnimationRange>[];
  25694. /**
  25695. * Will start the animation sequence
  25696. * @param name defines the range frames for animation sequence
  25697. * @param loop defines if the animation should loop (false by default)
  25698. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25699. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25700. * @returns the object created for this animation. If range does not exist, it will return null
  25701. */
  25702. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25703. /**
  25704. * Serialize animation ranges into a JSON compatible object
  25705. * @returns serialization object
  25706. */
  25707. serializeAnimationRanges(): any;
  25708. /**
  25709. * Computes the world matrix of the node
  25710. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25711. * @returns the world matrix
  25712. */
  25713. computeWorldMatrix(force?: boolean): Matrix;
  25714. /**
  25715. * Releases resources associated with this node.
  25716. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25717. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25718. */
  25719. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25720. /**
  25721. * Parse animation range data from a serialization object and store them into a given node
  25722. * @param node defines where to store the animation ranges
  25723. * @param parsedNode defines the serialization object to read data from
  25724. * @param scene defines the hosting scene
  25725. */
  25726. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25727. }
  25728. }
  25729. declare module "babylonjs/Animations/animation" {
  25730. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25731. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25732. import { Nullable } from "babylonjs/types";
  25733. import { Scene } from "babylonjs/scene";
  25734. import { IAnimatable } from "babylonjs/Misc/tools";
  25735. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25736. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25737. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25738. import { Node } from "babylonjs/node";
  25739. import { Animatable } from "babylonjs/Animations/animatable";
  25740. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25741. /**
  25742. * Class used to store any kind of animation
  25743. */
  25744. export class Animation {
  25745. /**Name of the animation */
  25746. name: string;
  25747. /**Property to animate */
  25748. targetProperty: string;
  25749. /**The frames per second of the animation */
  25750. framePerSecond: number;
  25751. /**The data type of the animation */
  25752. dataType: number;
  25753. /**The loop mode of the animation */
  25754. loopMode?: number | undefined;
  25755. /**Specifies if blending should be enabled */
  25756. enableBlending?: boolean | undefined;
  25757. /**
  25758. * Use matrix interpolation instead of using direct key value when animating matrices
  25759. */
  25760. static AllowMatricesInterpolation: boolean;
  25761. /**
  25762. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25763. */
  25764. static AllowMatrixDecomposeForInterpolation: boolean;
  25765. /**
  25766. * Stores the key frames of the animation
  25767. */
  25768. private _keys;
  25769. /**
  25770. * Stores the easing function of the animation
  25771. */
  25772. private _easingFunction;
  25773. /**
  25774. * @hidden Internal use only
  25775. */
  25776. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25777. /**
  25778. * The set of event that will be linked to this animation
  25779. */
  25780. private _events;
  25781. /**
  25782. * Stores an array of target property paths
  25783. */
  25784. targetPropertyPath: string[];
  25785. /**
  25786. * Stores the blending speed of the animation
  25787. */
  25788. blendingSpeed: number;
  25789. /**
  25790. * Stores the animation ranges for the animation
  25791. */
  25792. private _ranges;
  25793. /**
  25794. * @hidden Internal use
  25795. */
  25796. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25797. /**
  25798. * Sets up an animation
  25799. * @param property The property to animate
  25800. * @param animationType The animation type to apply
  25801. * @param framePerSecond The frames per second of the animation
  25802. * @param easingFunction The easing function used in the animation
  25803. * @returns The created animation
  25804. */
  25805. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25806. /**
  25807. * Create and start an animation on a node
  25808. * @param name defines the name of the global animation that will be run on all nodes
  25809. * @param node defines the root node where the animation will take place
  25810. * @param targetProperty defines property to animate
  25811. * @param framePerSecond defines the number of frame per second yo use
  25812. * @param totalFrame defines the number of frames in total
  25813. * @param from defines the initial value
  25814. * @param to defines the final value
  25815. * @param loopMode defines which loop mode you want to use (off by default)
  25816. * @param easingFunction defines the easing function to use (linear by default)
  25817. * @param onAnimationEnd defines the callback to call when animation end
  25818. * @returns the animatable created for this animation
  25819. */
  25820. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25821. /**
  25822. * Create and start an animation on a node and its descendants
  25823. * @param name defines the name of the global animation that will be run on all nodes
  25824. * @param node defines the root node where the animation will take place
  25825. * @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
  25826. * @param targetProperty defines property to animate
  25827. * @param framePerSecond defines the number of frame per second to use
  25828. * @param totalFrame defines the number of frames in total
  25829. * @param from defines the initial value
  25830. * @param to defines the final value
  25831. * @param loopMode defines which loop mode you want to use (off by default)
  25832. * @param easingFunction defines the easing function to use (linear by default)
  25833. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25834. * @returns the list of animatables created for all nodes
  25835. * @example https://www.babylonjs-playground.com/#MH0VLI
  25836. */
  25837. 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[]>;
  25838. /**
  25839. * Creates a new animation, merges it with the existing animations and starts it
  25840. * @param name Name of the animation
  25841. * @param node Node which contains the scene that begins the animations
  25842. * @param targetProperty Specifies which property to animate
  25843. * @param framePerSecond The frames per second of the animation
  25844. * @param totalFrame The total number of frames
  25845. * @param from The frame at the beginning of the animation
  25846. * @param to The frame at the end of the animation
  25847. * @param loopMode Specifies the loop mode of the animation
  25848. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25849. * @param onAnimationEnd Callback to run once the animation is complete
  25850. * @returns Nullable animation
  25851. */
  25852. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25853. /**
  25854. * Transition property of an host to the target Value
  25855. * @param property The property to transition
  25856. * @param targetValue The target Value of the property
  25857. * @param host The object where the property to animate belongs
  25858. * @param scene Scene used to run the animation
  25859. * @param frameRate Framerate (in frame/s) to use
  25860. * @param transition The transition type we want to use
  25861. * @param duration The duration of the animation, in milliseconds
  25862. * @param onAnimationEnd Callback trigger at the end of the animation
  25863. * @returns Nullable animation
  25864. */
  25865. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25866. /**
  25867. * Return the array of runtime animations currently using this animation
  25868. */
  25869. readonly runtimeAnimations: RuntimeAnimation[];
  25870. /**
  25871. * Specifies if any of the runtime animations are currently running
  25872. */
  25873. readonly hasRunningRuntimeAnimations: boolean;
  25874. /**
  25875. * Initializes the animation
  25876. * @param name Name of the animation
  25877. * @param targetProperty Property to animate
  25878. * @param framePerSecond The frames per second of the animation
  25879. * @param dataType The data type of the animation
  25880. * @param loopMode The loop mode of the animation
  25881. * @param enableBlending Specifies if blending should be enabled
  25882. */
  25883. constructor(
  25884. /**Name of the animation */
  25885. name: string,
  25886. /**Property to animate */
  25887. targetProperty: string,
  25888. /**The frames per second of the animation */
  25889. framePerSecond: number,
  25890. /**The data type of the animation */
  25891. dataType: number,
  25892. /**The loop mode of the animation */
  25893. loopMode?: number | undefined,
  25894. /**Specifies if blending should be enabled */
  25895. enableBlending?: boolean | undefined);
  25896. /**
  25897. * Converts the animation to a string
  25898. * @param fullDetails support for multiple levels of logging within scene loading
  25899. * @returns String form of the animation
  25900. */
  25901. toString(fullDetails?: boolean): string;
  25902. /**
  25903. * Add an event to this animation
  25904. * @param event Event to add
  25905. */
  25906. addEvent(event: AnimationEvent): void;
  25907. /**
  25908. * Remove all events found at the given frame
  25909. * @param frame The frame to remove events from
  25910. */
  25911. removeEvents(frame: number): void;
  25912. /**
  25913. * Retrieves all the events from the animation
  25914. * @returns Events from the animation
  25915. */
  25916. getEvents(): AnimationEvent[];
  25917. /**
  25918. * Creates an animation range
  25919. * @param name Name of the animation range
  25920. * @param from Starting frame of the animation range
  25921. * @param to Ending frame of the animation
  25922. */
  25923. createRange(name: string, from: number, to: number): void;
  25924. /**
  25925. * Deletes an animation range by name
  25926. * @param name Name of the animation range to delete
  25927. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25928. */
  25929. deleteRange(name: string, deleteFrames?: boolean): void;
  25930. /**
  25931. * Gets the animation range by name, or null if not defined
  25932. * @param name Name of the animation range
  25933. * @returns Nullable animation range
  25934. */
  25935. getRange(name: string): Nullable<AnimationRange>;
  25936. /**
  25937. * Gets the key frames from the animation
  25938. * @returns The key frames of the animation
  25939. */
  25940. getKeys(): Array<IAnimationKey>;
  25941. /**
  25942. * Gets the highest frame rate of the animation
  25943. * @returns Highest frame rate of the animation
  25944. */
  25945. getHighestFrame(): number;
  25946. /**
  25947. * Gets the easing function of the animation
  25948. * @returns Easing function of the animation
  25949. */
  25950. getEasingFunction(): IEasingFunction;
  25951. /**
  25952. * Sets the easing function of the animation
  25953. * @param easingFunction A custom mathematical formula for animation
  25954. */
  25955. setEasingFunction(easingFunction: EasingFunction): void;
  25956. /**
  25957. * Interpolates a scalar linearly
  25958. * @param startValue Start value of the animation curve
  25959. * @param endValue End value of the animation curve
  25960. * @param gradient Scalar amount to interpolate
  25961. * @returns Interpolated scalar value
  25962. */
  25963. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25964. /**
  25965. * Interpolates a scalar cubically
  25966. * @param startValue Start value of the animation curve
  25967. * @param outTangent End tangent of the animation
  25968. * @param endValue End value of the animation curve
  25969. * @param inTangent Start tangent of the animation curve
  25970. * @param gradient Scalar amount to interpolate
  25971. * @returns Interpolated scalar value
  25972. */
  25973. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25974. /**
  25975. * Interpolates a quaternion using a spherical linear interpolation
  25976. * @param startValue Start value of the animation curve
  25977. * @param endValue End value of the animation curve
  25978. * @param gradient Scalar amount to interpolate
  25979. * @returns Interpolated quaternion value
  25980. */
  25981. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25982. /**
  25983. * Interpolates a quaternion cubically
  25984. * @param startValue Start value of the animation curve
  25985. * @param outTangent End tangent of the animation curve
  25986. * @param endValue End value of the animation curve
  25987. * @param inTangent Start tangent of the animation curve
  25988. * @param gradient Scalar amount to interpolate
  25989. * @returns Interpolated quaternion value
  25990. */
  25991. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25992. /**
  25993. * Interpolates a Vector3 linearl
  25994. * @param startValue Start value of the animation curve
  25995. * @param endValue End value of the animation curve
  25996. * @param gradient Scalar amount to interpolate
  25997. * @returns Interpolated scalar value
  25998. */
  25999. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26000. /**
  26001. * Interpolates a Vector3 cubically
  26002. * @param startValue Start value of the animation curve
  26003. * @param outTangent End tangent of the animation
  26004. * @param endValue End value of the animation curve
  26005. * @param inTangent Start tangent of the animation curve
  26006. * @param gradient Scalar amount to interpolate
  26007. * @returns InterpolatedVector3 value
  26008. */
  26009. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26010. /**
  26011. * Interpolates a Vector2 linearly
  26012. * @param startValue Start value of the animation curve
  26013. * @param endValue End value of the animation curve
  26014. * @param gradient Scalar amount to interpolate
  26015. * @returns Interpolated Vector2 value
  26016. */
  26017. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26018. /**
  26019. * Interpolates a Vector2 cubically
  26020. * @param startValue Start value of the animation curve
  26021. * @param outTangent End tangent of the animation
  26022. * @param endValue End value of the animation curve
  26023. * @param inTangent Start tangent of the animation curve
  26024. * @param gradient Scalar amount to interpolate
  26025. * @returns Interpolated Vector2 value
  26026. */
  26027. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26028. /**
  26029. * Interpolates a size linearly
  26030. * @param startValue Start value of the animation curve
  26031. * @param endValue End value of the animation curve
  26032. * @param gradient Scalar amount to interpolate
  26033. * @returns Interpolated Size value
  26034. */
  26035. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26036. /**
  26037. * Interpolates a Color3 linearly
  26038. * @param startValue Start value of the animation curve
  26039. * @param endValue End value of the animation curve
  26040. * @param gradient Scalar amount to interpolate
  26041. * @returns Interpolated Color3 value
  26042. */
  26043. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26044. /**
  26045. * @hidden Internal use only
  26046. */
  26047. _getKeyValue(value: any): any;
  26048. /**
  26049. * @hidden Internal use only
  26050. */
  26051. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  26052. /**
  26053. * Defines the function to use to interpolate matrices
  26054. * @param startValue defines the start matrix
  26055. * @param endValue defines the end matrix
  26056. * @param gradient defines the gradient between both matrices
  26057. * @param result defines an optional target matrix where to store the interpolation
  26058. * @returns the interpolated matrix
  26059. */
  26060. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26061. /**
  26062. * Makes a copy of the animation
  26063. * @returns Cloned animation
  26064. */
  26065. clone(): Animation;
  26066. /**
  26067. * Sets the key frames of the animation
  26068. * @param values The animation key frames to set
  26069. */
  26070. setKeys(values: Array<IAnimationKey>): void;
  26071. /**
  26072. * Serializes the animation to an object
  26073. * @returns Serialized object
  26074. */
  26075. serialize(): any;
  26076. /**
  26077. * Float animation type
  26078. */
  26079. private static _ANIMATIONTYPE_FLOAT;
  26080. /**
  26081. * Vector3 animation type
  26082. */
  26083. private static _ANIMATIONTYPE_VECTOR3;
  26084. /**
  26085. * Quaternion animation type
  26086. */
  26087. private static _ANIMATIONTYPE_QUATERNION;
  26088. /**
  26089. * Matrix animation type
  26090. */
  26091. private static _ANIMATIONTYPE_MATRIX;
  26092. /**
  26093. * Color3 animation type
  26094. */
  26095. private static _ANIMATIONTYPE_COLOR3;
  26096. /**
  26097. * Vector2 animation type
  26098. */
  26099. private static _ANIMATIONTYPE_VECTOR2;
  26100. /**
  26101. * Size animation type
  26102. */
  26103. private static _ANIMATIONTYPE_SIZE;
  26104. /**
  26105. * Relative Loop Mode
  26106. */
  26107. private static _ANIMATIONLOOPMODE_RELATIVE;
  26108. /**
  26109. * Cycle Loop Mode
  26110. */
  26111. private static _ANIMATIONLOOPMODE_CYCLE;
  26112. /**
  26113. * Constant Loop Mode
  26114. */
  26115. private static _ANIMATIONLOOPMODE_CONSTANT;
  26116. /**
  26117. * Get the float animation type
  26118. */
  26119. static readonly ANIMATIONTYPE_FLOAT: number;
  26120. /**
  26121. * Get the Vector3 animation type
  26122. */
  26123. static readonly ANIMATIONTYPE_VECTOR3: number;
  26124. /**
  26125. * Get the Vector2 animation type
  26126. */
  26127. static readonly ANIMATIONTYPE_VECTOR2: number;
  26128. /**
  26129. * Get the Size animation type
  26130. */
  26131. static readonly ANIMATIONTYPE_SIZE: number;
  26132. /**
  26133. * Get the Quaternion animation type
  26134. */
  26135. static readonly ANIMATIONTYPE_QUATERNION: number;
  26136. /**
  26137. * Get the Matrix animation type
  26138. */
  26139. static readonly ANIMATIONTYPE_MATRIX: number;
  26140. /**
  26141. * Get the Color3 animation type
  26142. */
  26143. static readonly ANIMATIONTYPE_COLOR3: number;
  26144. /**
  26145. * Get the Relative Loop Mode
  26146. */
  26147. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26148. /**
  26149. * Get the Cycle Loop Mode
  26150. */
  26151. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26152. /**
  26153. * Get the Constant Loop Mode
  26154. */
  26155. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26156. /** @hidden */
  26157. static _UniversalLerp(left: any, right: any, amount: number): any;
  26158. /**
  26159. * Parses an animation object and creates an animation
  26160. * @param parsedAnimation Parsed animation object
  26161. * @returns Animation object
  26162. */
  26163. static Parse(parsedAnimation: any): Animation;
  26164. /**
  26165. * Appends the serialized animations from the source animations
  26166. * @param source Source containing the animations
  26167. * @param destination Target to store the animations
  26168. */
  26169. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26170. }
  26171. }
  26172. declare module "babylonjs/Materials/Textures/baseTexture" {
  26173. import { Observable } from "babylonjs/Misc/observable";
  26174. import { IAnimatable } from "babylonjs/Misc/tools";
  26175. import { Nullable } from "babylonjs/types";
  26176. import { Scene } from "babylonjs/scene";
  26177. import { Matrix, ISize } from "babylonjs/Maths/math";
  26178. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26179. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26180. /**
  26181. * Base class of all the textures in babylon.
  26182. * It groups all the common properties the materials, post process, lights... might need
  26183. * in order to make a correct use of the texture.
  26184. */
  26185. export class BaseTexture implements IAnimatable {
  26186. /**
  26187. * Default anisotropic filtering level for the application.
  26188. * It is set to 4 as a good tradeoff between perf and quality.
  26189. */
  26190. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26191. /**
  26192. * Gets or sets the unique id of the texture
  26193. */
  26194. uniqueId: number;
  26195. /**
  26196. * Define the name of the texture.
  26197. */
  26198. name: string;
  26199. /**
  26200. * Gets or sets an object used to store user defined information.
  26201. */
  26202. metadata: any;
  26203. /**
  26204. * For internal use only. Please do not use.
  26205. */
  26206. reservedDataStore: any;
  26207. private _hasAlpha;
  26208. /**
  26209. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26210. */
  26211. hasAlpha: boolean;
  26212. /**
  26213. * Defines if the alpha value should be determined via the rgb values.
  26214. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26215. */
  26216. getAlphaFromRGB: boolean;
  26217. /**
  26218. * Intensity or strength of the texture.
  26219. * It is commonly used by materials to fine tune the intensity of the texture
  26220. */
  26221. level: number;
  26222. /**
  26223. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26224. * This is part of the texture as textures usually maps to one uv set.
  26225. */
  26226. coordinatesIndex: number;
  26227. private _coordinatesMode;
  26228. /**
  26229. * How a texture is mapped.
  26230. *
  26231. * | Value | Type | Description |
  26232. * | ----- | ----------------------------------- | ----------- |
  26233. * | 0 | EXPLICIT_MODE | |
  26234. * | 1 | SPHERICAL_MODE | |
  26235. * | 2 | PLANAR_MODE | |
  26236. * | 3 | CUBIC_MODE | |
  26237. * | 4 | PROJECTION_MODE | |
  26238. * | 5 | SKYBOX_MODE | |
  26239. * | 6 | INVCUBIC_MODE | |
  26240. * | 7 | EQUIRECTANGULAR_MODE | |
  26241. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26242. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26243. */
  26244. coordinatesMode: number;
  26245. /**
  26246. * | Value | Type | Description |
  26247. * | ----- | ------------------ | ----------- |
  26248. * | 0 | CLAMP_ADDRESSMODE | |
  26249. * | 1 | WRAP_ADDRESSMODE | |
  26250. * | 2 | MIRROR_ADDRESSMODE | |
  26251. */
  26252. wrapU: number;
  26253. /**
  26254. * | Value | Type | Description |
  26255. * | ----- | ------------------ | ----------- |
  26256. * | 0 | CLAMP_ADDRESSMODE | |
  26257. * | 1 | WRAP_ADDRESSMODE | |
  26258. * | 2 | MIRROR_ADDRESSMODE | |
  26259. */
  26260. wrapV: number;
  26261. /**
  26262. * | Value | Type | Description |
  26263. * | ----- | ------------------ | ----------- |
  26264. * | 0 | CLAMP_ADDRESSMODE | |
  26265. * | 1 | WRAP_ADDRESSMODE | |
  26266. * | 2 | MIRROR_ADDRESSMODE | |
  26267. */
  26268. wrapR: number;
  26269. /**
  26270. * With compliant hardware and browser (supporting anisotropic filtering)
  26271. * this defines the level of anisotropic filtering in the texture.
  26272. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26273. */
  26274. anisotropicFilteringLevel: number;
  26275. /**
  26276. * Define if the texture is a cube texture or if false a 2d texture.
  26277. */
  26278. isCube: boolean;
  26279. /**
  26280. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26281. */
  26282. is3D: boolean;
  26283. /**
  26284. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26285. * HDR texture are usually stored in linear space.
  26286. * This only impacts the PBR and Background materials
  26287. */
  26288. gammaSpace: boolean;
  26289. /**
  26290. * Gets whether or not the texture contains RGBD data.
  26291. */
  26292. readonly isRGBD: boolean;
  26293. /**
  26294. * Is Z inverted in the texture (useful in a cube texture).
  26295. */
  26296. invertZ: boolean;
  26297. /**
  26298. * Are mip maps generated for this texture or not.
  26299. */
  26300. readonly noMipmap: boolean;
  26301. /**
  26302. * @hidden
  26303. */
  26304. lodLevelInAlpha: boolean;
  26305. /**
  26306. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26307. */
  26308. lodGenerationOffset: number;
  26309. /**
  26310. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26311. */
  26312. lodGenerationScale: number;
  26313. /**
  26314. * Define if the texture is a render target.
  26315. */
  26316. isRenderTarget: boolean;
  26317. /**
  26318. * Define the unique id of the texture in the scene.
  26319. */
  26320. readonly uid: string;
  26321. /**
  26322. * Return a string representation of the texture.
  26323. * @returns the texture as a string
  26324. */
  26325. toString(): string;
  26326. /**
  26327. * Get the class name of the texture.
  26328. * @returns "BaseTexture"
  26329. */
  26330. getClassName(): string;
  26331. /**
  26332. * Define the list of animation attached to the texture.
  26333. */
  26334. animations: import("babylonjs/Animations/animation").Animation[];
  26335. /**
  26336. * An event triggered when the texture is disposed.
  26337. */
  26338. onDisposeObservable: Observable<BaseTexture>;
  26339. private _onDisposeObserver;
  26340. /**
  26341. * Callback triggered when the texture has been disposed.
  26342. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26343. */
  26344. onDispose: () => void;
  26345. /**
  26346. * Define the current state of the loading sequence when in delayed load mode.
  26347. */
  26348. delayLoadState: number;
  26349. private _scene;
  26350. /** @hidden */
  26351. _texture: Nullable<InternalTexture>;
  26352. private _uid;
  26353. /**
  26354. * Define if the texture is preventinga material to render or not.
  26355. * If not and the texture is not ready, the engine will use a default black texture instead.
  26356. */
  26357. readonly isBlocking: boolean;
  26358. /**
  26359. * Instantiates a new BaseTexture.
  26360. * Base class of all the textures in babylon.
  26361. * It groups all the common properties the materials, post process, lights... might need
  26362. * in order to make a correct use of the texture.
  26363. * @param scene Define the scene the texture blongs to
  26364. */
  26365. constructor(scene: Nullable<Scene>);
  26366. /**
  26367. * Get the scene the texture belongs to.
  26368. * @returns the scene or null if undefined
  26369. */
  26370. getScene(): Nullable<Scene>;
  26371. /**
  26372. * Get the texture transform matrix used to offset tile the texture for istance.
  26373. * @returns the transformation matrix
  26374. */
  26375. getTextureMatrix(): Matrix;
  26376. /**
  26377. * Get the texture reflection matrix used to rotate/transform the reflection.
  26378. * @returns the reflection matrix
  26379. */
  26380. getReflectionTextureMatrix(): Matrix;
  26381. /**
  26382. * Get the underlying lower level texture from Babylon.
  26383. * @returns the insternal texture
  26384. */
  26385. getInternalTexture(): Nullable<InternalTexture>;
  26386. /**
  26387. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26388. * @returns true if ready or not blocking
  26389. */
  26390. isReadyOrNotBlocking(): boolean;
  26391. /**
  26392. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26393. * @returns true if fully ready
  26394. */
  26395. isReady(): boolean;
  26396. private _cachedSize;
  26397. /**
  26398. * Get the size of the texture.
  26399. * @returns the texture size.
  26400. */
  26401. getSize(): ISize;
  26402. /**
  26403. * Get the base size of the texture.
  26404. * It can be different from the size if the texture has been resized for POT for instance
  26405. * @returns the base size
  26406. */
  26407. getBaseSize(): ISize;
  26408. /**
  26409. * Update the sampling mode of the texture.
  26410. * Default is Trilinear mode.
  26411. *
  26412. * | Value | Type | Description |
  26413. * | ----- | ------------------ | ----------- |
  26414. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26415. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26416. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26417. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26418. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26419. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26420. * | 7 | NEAREST_LINEAR | |
  26421. * | 8 | NEAREST_NEAREST | |
  26422. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26423. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26424. * | 11 | LINEAR_LINEAR | |
  26425. * | 12 | LINEAR_NEAREST | |
  26426. *
  26427. * > _mag_: magnification filter (close to the viewer)
  26428. * > _min_: minification filter (far from the viewer)
  26429. * > _mip_: filter used between mip map levels
  26430. *@param samplingMode Define the new sampling mode of the texture
  26431. */
  26432. updateSamplingMode(samplingMode: number): void;
  26433. /**
  26434. * Scales the texture if is `canRescale()`
  26435. * @param ratio the resize factor we want to use to rescale
  26436. */
  26437. scale(ratio: number): void;
  26438. /**
  26439. * Get if the texture can rescale.
  26440. */
  26441. readonly canRescale: boolean;
  26442. /** @hidden */
  26443. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26444. /** @hidden */
  26445. _rebuild(): void;
  26446. /**
  26447. * Triggers the load sequence in delayed load mode.
  26448. */
  26449. delayLoad(): void;
  26450. /**
  26451. * Clones the texture.
  26452. * @returns the cloned texture
  26453. */
  26454. clone(): Nullable<BaseTexture>;
  26455. /**
  26456. * Get the texture underlying type (INT, FLOAT...)
  26457. */
  26458. readonly textureType: number;
  26459. /**
  26460. * Get the texture underlying format (RGB, RGBA...)
  26461. */
  26462. readonly textureFormat: number;
  26463. /**
  26464. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26465. * This will returns an RGBA array buffer containing either in values (0-255) or
  26466. * float values (0-1) depending of the underlying buffer type.
  26467. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26468. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26469. * @param buffer defines a user defined buffer to fill with data (can be null)
  26470. * @returns The Array buffer containing the pixels data.
  26471. */
  26472. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26473. /**
  26474. * Release and destroy the underlying lower level texture aka internalTexture.
  26475. */
  26476. releaseInternalTexture(): void;
  26477. /**
  26478. * Get the polynomial representation of the texture data.
  26479. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26480. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26481. */
  26482. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26483. /** @hidden */
  26484. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26485. /** @hidden */
  26486. readonly _lodTextureMid: Nullable<BaseTexture>;
  26487. /** @hidden */
  26488. readonly _lodTextureLow: Nullable<BaseTexture>;
  26489. /**
  26490. * Dispose the texture and release its associated resources.
  26491. */
  26492. dispose(): void;
  26493. /**
  26494. * Serialize the texture into a JSON representation that can be parsed later on.
  26495. * @returns the JSON representation of the texture
  26496. */
  26497. serialize(): any;
  26498. /**
  26499. * Helper function to be called back once a list of texture contains only ready textures.
  26500. * @param textures Define the list of textures to wait for
  26501. * @param callback Define the callback triggered once the entire list will be ready
  26502. */
  26503. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26504. }
  26505. }
  26506. declare module "babylonjs/Materials/uniformBuffer" {
  26507. import { Nullable, FloatArray } from "babylonjs/types";
  26508. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26509. import { Engine } from "babylonjs/Engines/engine";
  26510. import { Effect } from "babylonjs/Materials/effect";
  26511. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26512. /**
  26513. * Uniform buffer objects.
  26514. *
  26515. * Handles blocks of uniform on the GPU.
  26516. *
  26517. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26518. *
  26519. * For more information, please refer to :
  26520. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26521. */
  26522. export class UniformBuffer {
  26523. private _engine;
  26524. private _buffer;
  26525. private _data;
  26526. private _bufferData;
  26527. private _dynamic?;
  26528. private _uniformLocations;
  26529. private _uniformSizes;
  26530. private _uniformLocationPointer;
  26531. private _needSync;
  26532. private _noUBO;
  26533. private _currentEffect;
  26534. private static _MAX_UNIFORM_SIZE;
  26535. private static _tempBuffer;
  26536. /**
  26537. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26538. * This is dynamic to allow compat with webgl 1 and 2.
  26539. * You will need to pass the name of the uniform as well as the value.
  26540. */
  26541. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26542. /**
  26543. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26544. * This is dynamic to allow compat with webgl 1 and 2.
  26545. * You will need to pass the name of the uniform as well as the value.
  26546. */
  26547. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26548. /**
  26549. * Lambda to Update a single float in a uniform buffer.
  26550. * This is dynamic to allow compat with webgl 1 and 2.
  26551. * You will need to pass the name of the uniform as well as the value.
  26552. */
  26553. updateFloat: (name: string, x: number) => void;
  26554. /**
  26555. * Lambda to Update a vec2 of float in a uniform buffer.
  26556. * This is dynamic to allow compat with webgl 1 and 2.
  26557. * You will need to pass the name of the uniform as well as the value.
  26558. */
  26559. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26560. /**
  26561. * Lambda to Update a vec3 of float in a uniform buffer.
  26562. * This is dynamic to allow compat with webgl 1 and 2.
  26563. * You will need to pass the name of the uniform as well as the value.
  26564. */
  26565. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26566. /**
  26567. * Lambda to Update a vec4 of float in a uniform buffer.
  26568. * This is dynamic to allow compat with webgl 1 and 2.
  26569. * You will need to pass the name of the uniform as well as the value.
  26570. */
  26571. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26572. /**
  26573. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26574. * This is dynamic to allow compat with webgl 1 and 2.
  26575. * You will need to pass the name of the uniform as well as the value.
  26576. */
  26577. updateMatrix: (name: string, mat: Matrix) => void;
  26578. /**
  26579. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26580. * This is dynamic to allow compat with webgl 1 and 2.
  26581. * You will need to pass the name of the uniform as well as the value.
  26582. */
  26583. updateVector3: (name: string, vector: Vector3) => void;
  26584. /**
  26585. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26586. * This is dynamic to allow compat with webgl 1 and 2.
  26587. * You will need to pass the name of the uniform as well as the value.
  26588. */
  26589. updateVector4: (name: string, vector: Vector4) => void;
  26590. /**
  26591. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26592. * This is dynamic to allow compat with webgl 1 and 2.
  26593. * You will need to pass the name of the uniform as well as the value.
  26594. */
  26595. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26596. /**
  26597. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26598. * This is dynamic to allow compat with webgl 1 and 2.
  26599. * You will need to pass the name of the uniform as well as the value.
  26600. */
  26601. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26602. /**
  26603. * Instantiates a new Uniform buffer objects.
  26604. *
  26605. * Handles blocks of uniform on the GPU.
  26606. *
  26607. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26608. *
  26609. * For more information, please refer to :
  26610. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26611. * @param engine Define the engine the buffer is associated with
  26612. * @param data Define the data contained in the buffer
  26613. * @param dynamic Define if the buffer is updatable
  26614. */
  26615. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26616. /**
  26617. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26618. * or just falling back on setUniformXXX calls.
  26619. */
  26620. readonly useUbo: boolean;
  26621. /**
  26622. * Indicates if the WebGL underlying uniform buffer is in sync
  26623. * with the javascript cache data.
  26624. */
  26625. readonly isSync: boolean;
  26626. /**
  26627. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26628. * Also, a dynamic UniformBuffer will disable cache verification and always
  26629. * update the underlying WebGL uniform buffer to the GPU.
  26630. * @returns if Dynamic, otherwise false
  26631. */
  26632. isDynamic(): boolean;
  26633. /**
  26634. * The data cache on JS side.
  26635. * @returns the underlying data as a float array
  26636. */
  26637. getData(): Float32Array;
  26638. /**
  26639. * The underlying WebGL Uniform buffer.
  26640. * @returns the webgl buffer
  26641. */
  26642. getBuffer(): Nullable<WebGLBuffer>;
  26643. /**
  26644. * std140 layout specifies how to align data within an UBO structure.
  26645. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26646. * for specs.
  26647. */
  26648. private _fillAlignment;
  26649. /**
  26650. * Adds an uniform in the buffer.
  26651. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26652. * for the layout to be correct !
  26653. * @param name Name of the uniform, as used in the uniform block in the shader.
  26654. * @param size Data size, or data directly.
  26655. */
  26656. addUniform(name: string, size: number | number[]): void;
  26657. /**
  26658. * Adds a Matrix 4x4 to the uniform buffer.
  26659. * @param name Name of the uniform, as used in the uniform block in the shader.
  26660. * @param mat A 4x4 matrix.
  26661. */
  26662. addMatrix(name: string, mat: Matrix): void;
  26663. /**
  26664. * Adds a vec2 to the uniform buffer.
  26665. * @param name Name of the uniform, as used in the uniform block in the shader.
  26666. * @param x Define the x component value of the vec2
  26667. * @param y Define the y component value of the vec2
  26668. */
  26669. addFloat2(name: string, x: number, y: number): void;
  26670. /**
  26671. * Adds a vec3 to the uniform buffer.
  26672. * @param name Name of the uniform, as used in the uniform block in the shader.
  26673. * @param x Define the x component value of the vec3
  26674. * @param y Define the y component value of the vec3
  26675. * @param z Define the z component value of the vec3
  26676. */
  26677. addFloat3(name: string, x: number, y: number, z: number): void;
  26678. /**
  26679. * Adds a vec3 to the uniform buffer.
  26680. * @param name Name of the uniform, as used in the uniform block in the shader.
  26681. * @param color Define the vec3 from a Color
  26682. */
  26683. addColor3(name: string, color: Color3): void;
  26684. /**
  26685. * Adds a vec4 to the uniform buffer.
  26686. * @param name Name of the uniform, as used in the uniform block in the shader.
  26687. * @param color Define the rgb components from a Color
  26688. * @param alpha Define the a component of the vec4
  26689. */
  26690. addColor4(name: string, color: Color3, alpha: number): void;
  26691. /**
  26692. * Adds a vec3 to the uniform buffer.
  26693. * @param name Name of the uniform, as used in the uniform block in the shader.
  26694. * @param vector Define the vec3 components from a Vector
  26695. */
  26696. addVector3(name: string, vector: Vector3): void;
  26697. /**
  26698. * Adds a Matrix 3x3 to the uniform buffer.
  26699. * @param name Name of the uniform, as used in the uniform block in the shader.
  26700. */
  26701. addMatrix3x3(name: string): void;
  26702. /**
  26703. * Adds a Matrix 2x2 to the uniform buffer.
  26704. * @param name Name of the uniform, as used in the uniform block in the shader.
  26705. */
  26706. addMatrix2x2(name: string): void;
  26707. /**
  26708. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26709. */
  26710. create(): void;
  26711. /** @hidden */
  26712. _rebuild(): void;
  26713. /**
  26714. * Updates the WebGL Uniform Buffer on the GPU.
  26715. * If the `dynamic` flag is set to true, no cache comparison is done.
  26716. * Otherwise, the buffer will be updated only if the cache differs.
  26717. */
  26718. update(): void;
  26719. /**
  26720. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26721. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26722. * @param data Define the flattened data
  26723. * @param size Define the size of the data.
  26724. */
  26725. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26726. private _updateMatrix3x3ForUniform;
  26727. private _updateMatrix3x3ForEffect;
  26728. private _updateMatrix2x2ForEffect;
  26729. private _updateMatrix2x2ForUniform;
  26730. private _updateFloatForEffect;
  26731. private _updateFloatForUniform;
  26732. private _updateFloat2ForEffect;
  26733. private _updateFloat2ForUniform;
  26734. private _updateFloat3ForEffect;
  26735. private _updateFloat3ForUniform;
  26736. private _updateFloat4ForEffect;
  26737. private _updateFloat4ForUniform;
  26738. private _updateMatrixForEffect;
  26739. private _updateMatrixForUniform;
  26740. private _updateVector3ForEffect;
  26741. private _updateVector3ForUniform;
  26742. private _updateVector4ForEffect;
  26743. private _updateVector4ForUniform;
  26744. private _updateColor3ForEffect;
  26745. private _updateColor3ForUniform;
  26746. private _updateColor4ForEffect;
  26747. private _updateColor4ForUniform;
  26748. /**
  26749. * Sets a sampler uniform on the effect.
  26750. * @param name Define the name of the sampler.
  26751. * @param texture Define the texture to set in the sampler
  26752. */
  26753. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26754. /**
  26755. * Directly updates the value of the uniform in the cache AND on the GPU.
  26756. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26757. * @param data Define the flattened data
  26758. */
  26759. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26760. /**
  26761. * Binds this uniform buffer to an effect.
  26762. * @param effect Define the effect to bind the buffer to
  26763. * @param name Name of the uniform block in the shader.
  26764. */
  26765. bindToEffect(effect: Effect, name: string): void;
  26766. /**
  26767. * Disposes the uniform buffer.
  26768. */
  26769. dispose(): void;
  26770. }
  26771. }
  26772. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26773. import { Nullable } from "babylonjs/types";
  26774. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26775. /**
  26776. * This represents the required contract to create a new type of texture loader.
  26777. */
  26778. export interface IInternalTextureLoader {
  26779. /**
  26780. * Defines wether the loader supports cascade loading the different faces.
  26781. */
  26782. supportCascades: boolean;
  26783. /**
  26784. * This returns if the loader support the current file information.
  26785. * @param extension defines the file extension of the file being loaded
  26786. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26787. * @param fallback defines the fallback internal texture if any
  26788. * @param isBase64 defines whether the texture is encoded as a base64
  26789. * @param isBuffer defines whether the texture data are stored as a buffer
  26790. * @returns true if the loader can load the specified file
  26791. */
  26792. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26793. /**
  26794. * Transform the url before loading if required.
  26795. * @param rootUrl the url of the texture
  26796. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26797. * @returns the transformed texture
  26798. */
  26799. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26800. /**
  26801. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26802. * @param rootUrl the url of the texture
  26803. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26804. * @returns the fallback texture
  26805. */
  26806. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26807. /**
  26808. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26809. * @param data contains the texture data
  26810. * @param texture defines the BabylonJS internal texture
  26811. * @param createPolynomials will be true if polynomials have been requested
  26812. * @param onLoad defines the callback to trigger once the texture is ready
  26813. * @param onError defines the callback to trigger in case of error
  26814. */
  26815. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26816. /**
  26817. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26818. * @param data contains the texture data
  26819. * @param texture defines the BabylonJS internal texture
  26820. * @param callback defines the method to call once ready to upload
  26821. */
  26822. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26823. }
  26824. }
  26825. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26826. import { Scene } from "babylonjs/scene";
  26827. import { Engine } from "babylonjs/Engines/engine";
  26828. import { Texture } from "babylonjs/Materials/Textures/texture";
  26829. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26830. /**
  26831. * Creation options of the multi render target texture.
  26832. */
  26833. export interface IMultiRenderTargetOptions {
  26834. /**
  26835. * Define if the texture needs to create mip maps after render.
  26836. */
  26837. generateMipMaps?: boolean;
  26838. /**
  26839. * Define the types of all the draw buffers we want to create
  26840. */
  26841. types?: number[];
  26842. /**
  26843. * Define the sampling modes of all the draw buffers we want to create
  26844. */
  26845. samplingModes?: number[];
  26846. /**
  26847. * Define if a depth buffer is required
  26848. */
  26849. generateDepthBuffer?: boolean;
  26850. /**
  26851. * Define if a stencil buffer is required
  26852. */
  26853. generateStencilBuffer?: boolean;
  26854. /**
  26855. * Define if a depth texture is required instead of a depth buffer
  26856. */
  26857. generateDepthTexture?: boolean;
  26858. /**
  26859. * Define the number of desired draw buffers
  26860. */
  26861. textureCount?: number;
  26862. /**
  26863. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26864. */
  26865. doNotChangeAspectRatio?: boolean;
  26866. /**
  26867. * Define the default type of the buffers we are creating
  26868. */
  26869. defaultType?: number;
  26870. }
  26871. /**
  26872. * A multi render target, like a render target provides the ability to render to a texture.
  26873. * Unlike the render target, it can render to several draw buffers in one draw.
  26874. * This is specially interesting in deferred rendering or for any effects requiring more than
  26875. * just one color from a single pass.
  26876. */
  26877. export class MultiRenderTarget extends RenderTargetTexture {
  26878. private _internalTextures;
  26879. private _textures;
  26880. private _multiRenderTargetOptions;
  26881. /**
  26882. * Get if draw buffers are currently supported by the used hardware and browser.
  26883. */
  26884. readonly isSupported: boolean;
  26885. /**
  26886. * Get the list of textures generated by the multi render target.
  26887. */
  26888. readonly textures: Texture[];
  26889. /**
  26890. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26891. */
  26892. readonly depthTexture: Texture;
  26893. /**
  26894. * Set the wrapping mode on U of all the textures we are rendering to.
  26895. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26896. */
  26897. wrapU: number;
  26898. /**
  26899. * Set the wrapping mode on V of all the textures we are rendering to.
  26900. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26901. */
  26902. wrapV: number;
  26903. /**
  26904. * Instantiate a new multi render target texture.
  26905. * A multi render target, like a render target provides the ability to render to a texture.
  26906. * Unlike the render target, it can render to several draw buffers in one draw.
  26907. * This is specially interesting in deferred rendering or for any effects requiring more than
  26908. * just one color from a single pass.
  26909. * @param name Define the name of the texture
  26910. * @param size Define the size of the buffers to render to
  26911. * @param count Define the number of target we are rendering into
  26912. * @param scene Define the scene the texture belongs to
  26913. * @param options Define the options used to create the multi render target
  26914. */
  26915. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26916. /** @hidden */
  26917. _rebuild(): void;
  26918. private _createInternalTextures;
  26919. private _createTextures;
  26920. /**
  26921. * Define the number of samples used if MSAA is enabled.
  26922. */
  26923. samples: number;
  26924. /**
  26925. * Resize all the textures in the multi render target.
  26926. * Be carrefull as it will recreate all the data in the new texture.
  26927. * @param size Define the new size
  26928. */
  26929. resize(size: any): void;
  26930. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26931. /**
  26932. * Dispose the render targets and their associated resources
  26933. */
  26934. dispose(): void;
  26935. /**
  26936. * Release all the underlying texture used as draw buffers.
  26937. */
  26938. releaseInternalTextures(): void;
  26939. }
  26940. }
  26941. declare module "babylonjs/Audio/analyser" {
  26942. import { Scene } from "babylonjs/scene";
  26943. /**
  26944. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26945. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26946. */
  26947. export class Analyser {
  26948. /**
  26949. * Gets or sets the smoothing
  26950. * @ignorenaming
  26951. */
  26952. SMOOTHING: number;
  26953. /**
  26954. * Gets or sets the FFT table size
  26955. * @ignorenaming
  26956. */
  26957. FFT_SIZE: number;
  26958. /**
  26959. * Gets or sets the bar graph amplitude
  26960. * @ignorenaming
  26961. */
  26962. BARGRAPHAMPLITUDE: number;
  26963. /**
  26964. * Gets or sets the position of the debug canvas
  26965. * @ignorenaming
  26966. */
  26967. DEBUGCANVASPOS: {
  26968. x: number;
  26969. y: number;
  26970. };
  26971. /**
  26972. * Gets or sets the debug canvas size
  26973. * @ignorenaming
  26974. */
  26975. DEBUGCANVASSIZE: {
  26976. width: number;
  26977. height: number;
  26978. };
  26979. private _byteFreqs;
  26980. private _byteTime;
  26981. private _floatFreqs;
  26982. private _webAudioAnalyser;
  26983. private _debugCanvas;
  26984. private _debugCanvasContext;
  26985. private _scene;
  26986. private _registerFunc;
  26987. private _audioEngine;
  26988. /**
  26989. * Creates a new analyser
  26990. * @param scene defines hosting scene
  26991. */
  26992. constructor(scene: Scene);
  26993. /**
  26994. * Get the number of data values you will have to play with for the visualization
  26995. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26996. * @returns a number
  26997. */
  26998. getFrequencyBinCount(): number;
  26999. /**
  27000. * Gets the current frequency data as a byte array
  27001. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27002. * @returns a Uint8Array
  27003. */
  27004. getByteFrequencyData(): Uint8Array;
  27005. /**
  27006. * Gets the current waveform as a byte array
  27007. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27008. * @returns a Uint8Array
  27009. */
  27010. getByteTimeDomainData(): Uint8Array;
  27011. /**
  27012. * Gets the current frequency data as a float array
  27013. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27014. * @returns a Float32Array
  27015. */
  27016. getFloatFrequencyData(): Float32Array;
  27017. /**
  27018. * Renders the debug canvas
  27019. */
  27020. drawDebugCanvas(): void;
  27021. /**
  27022. * Stops rendering the debug canvas and removes it
  27023. */
  27024. stopDebugCanvas(): void;
  27025. /**
  27026. * Connects two audio nodes
  27027. * @param inputAudioNode defines first node to connect
  27028. * @param outputAudioNode defines second node to connect
  27029. */
  27030. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27031. /**
  27032. * Releases all associated resources
  27033. */
  27034. dispose(): void;
  27035. }
  27036. }
  27037. declare module "babylonjs/Audio/audioEngine" {
  27038. import { IDisposable } from "babylonjs/scene";
  27039. import { Analyser } from "babylonjs/Audio/analyser";
  27040. import { Nullable } from "babylonjs/types";
  27041. import { Observable } from "babylonjs/Misc/observable";
  27042. /**
  27043. * This represents an audio engine and it is responsible
  27044. * to play, synchronize and analyse sounds throughout the application.
  27045. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27046. */
  27047. export interface IAudioEngine extends IDisposable {
  27048. /**
  27049. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27050. */
  27051. readonly canUseWebAudio: boolean;
  27052. /**
  27053. * Gets the current AudioContext if available.
  27054. */
  27055. readonly audioContext: Nullable<AudioContext>;
  27056. /**
  27057. * The master gain node defines the global audio volume of your audio engine.
  27058. */
  27059. readonly masterGain: GainNode;
  27060. /**
  27061. * Gets whether or not mp3 are supported by your browser.
  27062. */
  27063. readonly isMP3supported: boolean;
  27064. /**
  27065. * Gets whether or not ogg are supported by your browser.
  27066. */
  27067. readonly isOGGsupported: boolean;
  27068. /**
  27069. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27070. * @ignoreNaming
  27071. */
  27072. WarnedWebAudioUnsupported: boolean;
  27073. /**
  27074. * Defines if the audio engine relies on a custom unlocked button.
  27075. * In this case, the embedded button will not be displayed.
  27076. */
  27077. useCustomUnlockedButton: boolean;
  27078. /**
  27079. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27080. */
  27081. readonly unlocked: boolean;
  27082. /**
  27083. * Event raised when audio has been unlocked on the browser.
  27084. */
  27085. onAudioUnlockedObservable: Observable<AudioEngine>;
  27086. /**
  27087. * Event raised when audio has been locked on the browser.
  27088. */
  27089. onAudioLockedObservable: Observable<AudioEngine>;
  27090. /**
  27091. * Flags the audio engine in Locked state.
  27092. * This happens due to new browser policies preventing audio to autoplay.
  27093. */
  27094. lock(): void;
  27095. /**
  27096. * Unlocks the audio engine once a user action has been done on the dom.
  27097. * This is helpful to resume play once browser policies have been satisfied.
  27098. */
  27099. unlock(): void;
  27100. }
  27101. /**
  27102. * This represents the default audio engine used in babylon.
  27103. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27104. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27105. */
  27106. export class AudioEngine implements IAudioEngine {
  27107. private _audioContext;
  27108. private _audioContextInitialized;
  27109. private _muteButton;
  27110. private _hostElement;
  27111. /**
  27112. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27113. */
  27114. canUseWebAudio: boolean;
  27115. /**
  27116. * The master gain node defines the global audio volume of your audio engine.
  27117. */
  27118. masterGain: GainNode;
  27119. /**
  27120. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27121. * @ignoreNaming
  27122. */
  27123. WarnedWebAudioUnsupported: boolean;
  27124. /**
  27125. * Gets whether or not mp3 are supported by your browser.
  27126. */
  27127. isMP3supported: boolean;
  27128. /**
  27129. * Gets whether or not ogg are supported by your browser.
  27130. */
  27131. isOGGsupported: boolean;
  27132. /**
  27133. * Gets whether audio has been unlocked on the device.
  27134. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27135. * a user interaction has happened.
  27136. */
  27137. unlocked: boolean;
  27138. /**
  27139. * Defines if the audio engine relies on a custom unlocked button.
  27140. * In this case, the embedded button will not be displayed.
  27141. */
  27142. useCustomUnlockedButton: boolean;
  27143. /**
  27144. * Event raised when audio has been unlocked on the browser.
  27145. */
  27146. onAudioUnlockedObservable: Observable<AudioEngine>;
  27147. /**
  27148. * Event raised when audio has been locked on the browser.
  27149. */
  27150. onAudioLockedObservable: Observable<AudioEngine>;
  27151. /**
  27152. * Gets the current AudioContext if available.
  27153. */
  27154. readonly audioContext: Nullable<AudioContext>;
  27155. private _connectedAnalyser;
  27156. /**
  27157. * Instantiates a new audio engine.
  27158. *
  27159. * There should be only one per page as some browsers restrict the number
  27160. * of audio contexts you can create.
  27161. * @param hostElement defines the host element where to display the mute icon if necessary
  27162. */
  27163. constructor(hostElement?: Nullable<HTMLElement>);
  27164. /**
  27165. * Flags the audio engine in Locked state.
  27166. * This happens due to new browser policies preventing audio to autoplay.
  27167. */
  27168. lock(): void;
  27169. /**
  27170. * Unlocks the audio engine once a user action has been done on the dom.
  27171. * This is helpful to resume play once browser policies have been satisfied.
  27172. */
  27173. unlock(): void;
  27174. private _resumeAudioContext;
  27175. private _initializeAudioContext;
  27176. private _tryToRun;
  27177. private _triggerRunningState;
  27178. private _triggerSuspendedState;
  27179. private _displayMuteButton;
  27180. private _moveButtonToTopLeft;
  27181. private _onResize;
  27182. private _hideMuteButton;
  27183. /**
  27184. * Destroy and release the resources associated with the audio ccontext.
  27185. */
  27186. dispose(): void;
  27187. /**
  27188. * Gets the global volume sets on the master gain.
  27189. * @returns the global volume if set or -1 otherwise
  27190. */
  27191. getGlobalVolume(): number;
  27192. /**
  27193. * Sets the global volume of your experience (sets on the master gain).
  27194. * @param newVolume Defines the new global volume of the application
  27195. */
  27196. setGlobalVolume(newVolume: number): void;
  27197. /**
  27198. * Connect the audio engine to an audio analyser allowing some amazing
  27199. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27200. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27201. * @param analyser The analyser to connect to the engine
  27202. */
  27203. connectToAnalyser(analyser: Analyser): void;
  27204. }
  27205. }
  27206. declare module "babylonjs/Loading/loadingScreen" {
  27207. /**
  27208. * Interface used to present a loading screen while loading a scene
  27209. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27210. */
  27211. export interface ILoadingScreen {
  27212. /**
  27213. * Function called to display the loading screen
  27214. */
  27215. displayLoadingUI: () => void;
  27216. /**
  27217. * Function called to hide the loading screen
  27218. */
  27219. hideLoadingUI: () => void;
  27220. /**
  27221. * Gets or sets the color to use for the background
  27222. */
  27223. loadingUIBackgroundColor: string;
  27224. /**
  27225. * Gets or sets the text to display while loading
  27226. */
  27227. loadingUIText: string;
  27228. }
  27229. /**
  27230. * Class used for the default loading screen
  27231. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27232. */
  27233. export class DefaultLoadingScreen implements ILoadingScreen {
  27234. private _renderingCanvas;
  27235. private _loadingText;
  27236. private _loadingDivBackgroundColor;
  27237. private _loadingDiv;
  27238. private _loadingTextDiv;
  27239. /**
  27240. * Creates a new default loading screen
  27241. * @param _renderingCanvas defines the canvas used to render the scene
  27242. * @param _loadingText defines the default text to display
  27243. * @param _loadingDivBackgroundColor defines the default background color
  27244. */
  27245. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27246. /**
  27247. * Function called to display the loading screen
  27248. */
  27249. displayLoadingUI(): void;
  27250. /**
  27251. * Function called to hide the loading screen
  27252. */
  27253. hideLoadingUI(): void;
  27254. /**
  27255. * Gets or sets the text to display while loading
  27256. */
  27257. loadingUIText: string;
  27258. /**
  27259. * Gets or sets the color to use for the background
  27260. */
  27261. loadingUIBackgroundColor: string;
  27262. private _resizeLoadingUI;
  27263. }
  27264. }
  27265. declare module "babylonjs/Materials/Textures/videoTexture" {
  27266. import { Observable } from "babylonjs/Misc/observable";
  27267. import { Nullable } from "babylonjs/types";
  27268. import { Scene } from "babylonjs/scene";
  27269. import { Texture } from "babylonjs/Materials/Textures/texture";
  27270. /**
  27271. * Settings for finer control over video usage
  27272. */
  27273. export interface VideoTextureSettings {
  27274. /**
  27275. * Applies `autoplay` to video, if specified
  27276. */
  27277. autoPlay?: boolean;
  27278. /**
  27279. * Applies `loop` to video, if specified
  27280. */
  27281. loop?: boolean;
  27282. /**
  27283. * Automatically updates internal texture from video at every frame in the render loop
  27284. */
  27285. autoUpdateTexture: boolean;
  27286. /**
  27287. * Image src displayed during the video loading or until the user interacts with the video.
  27288. */
  27289. poster?: string;
  27290. }
  27291. /**
  27292. * If you want to display a video in your scene, this is the special texture for that.
  27293. * This special texture works similar to other textures, with the exception of a few parameters.
  27294. * @see https://doc.babylonjs.com/how_to/video_texture
  27295. */
  27296. export class VideoTexture extends Texture {
  27297. /**
  27298. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27299. */
  27300. readonly autoUpdateTexture: boolean;
  27301. /**
  27302. * The video instance used by the texture internally
  27303. */
  27304. readonly video: HTMLVideoElement;
  27305. private _onUserActionRequestedObservable;
  27306. /**
  27307. * Event triggerd when a dom action is required by the user to play the video.
  27308. * This happens due to recent changes in browser policies preventing video to auto start.
  27309. */
  27310. readonly onUserActionRequestedObservable: Observable<Texture>;
  27311. private _generateMipMaps;
  27312. private _engine;
  27313. private _stillImageCaptured;
  27314. private _displayingPosterTexture;
  27315. private _settings;
  27316. private _createInternalTextureOnEvent;
  27317. /**
  27318. * Creates a video texture.
  27319. * If you want to display a video in your scene, this is the special texture for that.
  27320. * This special texture works similar to other textures, with the exception of a few parameters.
  27321. * @see https://doc.babylonjs.com/how_to/video_texture
  27322. * @param name optional name, will detect from video source, if not defined
  27323. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27324. * @param scene is obviously the current scene.
  27325. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27326. * @param invertY is false by default but can be used to invert video on Y axis
  27327. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27328. * @param settings allows finer control over video usage
  27329. */
  27330. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27331. private _getName;
  27332. private _getVideo;
  27333. private _createInternalTexture;
  27334. private reset;
  27335. /**
  27336. * @hidden Internal method to initiate `update`.
  27337. */
  27338. _rebuild(): void;
  27339. /**
  27340. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27341. */
  27342. update(): void;
  27343. /**
  27344. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27345. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27346. */
  27347. updateTexture(isVisible: boolean): void;
  27348. protected _updateInternalTexture: () => void;
  27349. /**
  27350. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27351. * @param url New url.
  27352. */
  27353. updateURL(url: string): void;
  27354. /**
  27355. * Dispose the texture and release its associated resources.
  27356. */
  27357. dispose(): void;
  27358. /**
  27359. * Creates a video texture straight from a stream.
  27360. * @param scene Define the scene the texture should be created in
  27361. * @param stream Define the stream the texture should be created from
  27362. * @returns The created video texture as a promise
  27363. */
  27364. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27365. /**
  27366. * Creates a video texture straight from your WebCam video feed.
  27367. * @param scene Define the scene the texture should be created in
  27368. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27369. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27370. * @returns The created video texture as a promise
  27371. */
  27372. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27373. minWidth: number;
  27374. maxWidth: number;
  27375. minHeight: number;
  27376. maxHeight: number;
  27377. deviceId: string;
  27378. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27379. /**
  27380. * Creates a video texture straight from your WebCam video feed.
  27381. * @param scene Define the scene the texture should be created in
  27382. * @param onReady Define a callback to triggered once the texture will be ready
  27383. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27384. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27385. */
  27386. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27387. minWidth: number;
  27388. maxWidth: number;
  27389. minHeight: number;
  27390. maxHeight: number;
  27391. deviceId: string;
  27392. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27393. }
  27394. }
  27395. declare module "babylonjs/Engines/engine" {
  27396. import { Observable } from "babylonjs/Misc/observable";
  27397. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27398. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27399. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27400. import { Camera } from "babylonjs/Cameras/camera";
  27401. import { Scene } from "babylonjs/scene";
  27402. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27403. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27404. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27405. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27406. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27407. import { Material } from "babylonjs/Materials/material";
  27408. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27409. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27410. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27411. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  27412. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27413. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27414. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27415. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27416. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27417. import { WebRequest } from "babylonjs/Misc/webRequest";
  27418. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27419. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27420. /**
  27421. * Interface for attribute information associated with buffer instanciation
  27422. */
  27423. export class InstancingAttributeInfo {
  27424. /**
  27425. * Index/offset of the attribute in the vertex shader
  27426. */
  27427. index: number;
  27428. /**
  27429. * size of the attribute, 1, 2, 3 or 4
  27430. */
  27431. attributeSize: number;
  27432. /**
  27433. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27434. * default is FLOAT
  27435. */
  27436. attribyteType: number;
  27437. /**
  27438. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27439. */
  27440. normalized: boolean;
  27441. /**
  27442. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27443. */
  27444. offset: number;
  27445. /**
  27446. * Name of the GLSL attribute, for debugging purpose only
  27447. */
  27448. attributeName: string;
  27449. }
  27450. /**
  27451. * Define options used to create a depth texture
  27452. */
  27453. export class DepthTextureCreationOptions {
  27454. /** Specifies whether or not a stencil should be allocated in the texture */
  27455. generateStencil?: boolean;
  27456. /** Specifies whether or not bilinear filtering is enable on the texture */
  27457. bilinearFiltering?: boolean;
  27458. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27459. comparisonFunction?: number;
  27460. /** Specifies if the created texture is a cube texture */
  27461. isCube?: boolean;
  27462. }
  27463. /**
  27464. * Class used to describe the capabilities of the engine relatively to the current browser
  27465. */
  27466. export class EngineCapabilities {
  27467. /** Maximum textures units per fragment shader */
  27468. maxTexturesImageUnits: number;
  27469. /** Maximum texture units per vertex shader */
  27470. maxVertexTextureImageUnits: number;
  27471. /** Maximum textures units in the entire pipeline */
  27472. maxCombinedTexturesImageUnits: number;
  27473. /** Maximum texture size */
  27474. maxTextureSize: number;
  27475. /** Maximum cube texture size */
  27476. maxCubemapTextureSize: number;
  27477. /** Maximum render texture size */
  27478. maxRenderTextureSize: number;
  27479. /** Maximum number of vertex attributes */
  27480. maxVertexAttribs: number;
  27481. /** Maximum number of varyings */
  27482. maxVaryingVectors: number;
  27483. /** Maximum number of uniforms per vertex shader */
  27484. maxVertexUniformVectors: number;
  27485. /** Maximum number of uniforms per fragment shader */
  27486. maxFragmentUniformVectors: number;
  27487. /** Defines if standard derivates (dx/dy) are supported */
  27488. standardDerivatives: boolean;
  27489. /** Defines if s3tc texture compression is supported */
  27490. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27491. /** Defines if pvrtc texture compression is supported */
  27492. pvrtc: any;
  27493. /** Defines if etc1 texture compression is supported */
  27494. etc1: any;
  27495. /** Defines if etc2 texture compression is supported */
  27496. etc2: any;
  27497. /** Defines if astc texture compression is supported */
  27498. astc: any;
  27499. /** Defines if float textures are supported */
  27500. textureFloat: boolean;
  27501. /** Defines if vertex array objects are supported */
  27502. vertexArrayObject: boolean;
  27503. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27504. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27505. /** Gets the maximum level of anisotropy supported */
  27506. maxAnisotropy: number;
  27507. /** Defines if instancing is supported */
  27508. instancedArrays: boolean;
  27509. /** Defines if 32 bits indices are supported */
  27510. uintIndices: boolean;
  27511. /** Defines if high precision shaders are supported */
  27512. highPrecisionShaderSupported: boolean;
  27513. /** Defines if depth reading in the fragment shader is supported */
  27514. fragmentDepthSupported: boolean;
  27515. /** Defines if float texture linear filtering is supported*/
  27516. textureFloatLinearFiltering: boolean;
  27517. /** Defines if rendering to float textures is supported */
  27518. textureFloatRender: boolean;
  27519. /** Defines if half float textures are supported*/
  27520. textureHalfFloat: boolean;
  27521. /** Defines if half float texture linear filtering is supported*/
  27522. textureHalfFloatLinearFiltering: boolean;
  27523. /** Defines if rendering to half float textures is supported */
  27524. textureHalfFloatRender: boolean;
  27525. /** Defines if textureLOD shader command is supported */
  27526. textureLOD: boolean;
  27527. /** Defines if draw buffers extension is supported */
  27528. drawBuffersExtension: boolean;
  27529. /** Defines if depth textures are supported */
  27530. depthTextureExtension: boolean;
  27531. /** Defines if float color buffer are supported */
  27532. colorBufferFloat: boolean;
  27533. /** Gets disjoint timer query extension (null if not supported) */
  27534. timerQuery: EXT_disjoint_timer_query;
  27535. /** Defines if timestamp can be used with timer query */
  27536. canUseTimestampForTimerQuery: boolean;
  27537. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27538. multiview: any;
  27539. /** Function used to let the system compiles shaders in background */
  27540. parallelShaderCompile: {
  27541. COMPLETION_STATUS_KHR: number;
  27542. };
  27543. }
  27544. /** Interface defining initialization parameters for Engine class */
  27545. export interface EngineOptions extends WebGLContextAttributes {
  27546. /**
  27547. * Defines if the engine should no exceed a specified device ratio
  27548. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27549. */
  27550. limitDeviceRatio?: number;
  27551. /**
  27552. * Defines if webvr should be enabled automatically
  27553. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27554. */
  27555. autoEnableWebVR?: boolean;
  27556. /**
  27557. * Defines if webgl2 should be turned off even if supported
  27558. * @see http://doc.babylonjs.com/features/webgl2
  27559. */
  27560. disableWebGL2Support?: boolean;
  27561. /**
  27562. * Defines if webaudio should be initialized as well
  27563. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27564. */
  27565. audioEngine?: boolean;
  27566. /**
  27567. * Defines if animations should run using a deterministic lock step
  27568. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27569. */
  27570. deterministicLockstep?: boolean;
  27571. /** Defines the maximum steps to use with deterministic lock step mode */
  27572. lockstepMaxSteps?: number;
  27573. /**
  27574. * Defines that engine should ignore context lost events
  27575. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27576. */
  27577. doNotHandleContextLost?: boolean;
  27578. /**
  27579. * Defines that engine should ignore modifying touch action attribute and style
  27580. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27581. */
  27582. doNotHandleTouchAction?: boolean;
  27583. /**
  27584. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27585. */
  27586. useHighPrecisionFloats?: boolean;
  27587. }
  27588. /**
  27589. * Defines the interface used by display changed events
  27590. */
  27591. export interface IDisplayChangedEventArgs {
  27592. /** Gets the vrDisplay object (if any) */
  27593. vrDisplay: Nullable<any>;
  27594. /** Gets a boolean indicating if webVR is supported */
  27595. vrSupported: boolean;
  27596. }
  27597. /**
  27598. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27599. */
  27600. export class Engine {
  27601. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27602. static ExceptionList: ({
  27603. key: string;
  27604. capture: string;
  27605. captureConstraint: number;
  27606. targets: string[];
  27607. } | {
  27608. key: string;
  27609. capture: null;
  27610. captureConstraint: null;
  27611. targets: string[];
  27612. })[];
  27613. /** Gets the list of created engines */
  27614. static readonly Instances: Engine[];
  27615. /**
  27616. * Gets the latest created engine
  27617. */
  27618. static readonly LastCreatedEngine: Nullable<Engine>;
  27619. /**
  27620. * Gets the latest created scene
  27621. */
  27622. static readonly LastCreatedScene: Nullable<Scene>;
  27623. /**
  27624. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27625. * @param flag defines which part of the materials must be marked as dirty
  27626. * @param predicate defines a predicate used to filter which materials should be affected
  27627. */
  27628. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27629. /**
  27630. * Hidden
  27631. */
  27632. static _TextureLoaders: IInternalTextureLoader[];
  27633. /** Defines that alpha blending is disabled */
  27634. static readonly ALPHA_DISABLE: number;
  27635. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27636. static readonly ALPHA_ADD: number;
  27637. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27638. static readonly ALPHA_COMBINE: number;
  27639. /** Defines that alpha blending to DEST - SRC * DEST */
  27640. static readonly ALPHA_SUBTRACT: number;
  27641. /** Defines that alpha blending to SRC * DEST */
  27642. static readonly ALPHA_MULTIPLY: number;
  27643. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27644. static readonly ALPHA_MAXIMIZED: number;
  27645. /** Defines that alpha blending to SRC + DEST */
  27646. static readonly ALPHA_ONEONE: number;
  27647. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27648. static readonly ALPHA_PREMULTIPLIED: number;
  27649. /**
  27650. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27651. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27652. */
  27653. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27654. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27655. static readonly ALPHA_INTERPOLATE: number;
  27656. /**
  27657. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27658. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27659. */
  27660. static readonly ALPHA_SCREENMODE: number;
  27661. /** Defines that the ressource is not delayed*/
  27662. static readonly DELAYLOADSTATE_NONE: number;
  27663. /** Defines that the ressource was successfully delay loaded */
  27664. static readonly DELAYLOADSTATE_LOADED: number;
  27665. /** Defines that the ressource is currently delay loading */
  27666. static readonly DELAYLOADSTATE_LOADING: number;
  27667. /** Defines that the ressource is delayed and has not started loading */
  27668. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27669. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27670. static readonly NEVER: number;
  27671. /** 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 */
  27672. static readonly ALWAYS: number;
  27673. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27674. static readonly LESS: number;
  27675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27676. static readonly EQUAL: number;
  27677. /** 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 */
  27678. static readonly LEQUAL: number;
  27679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27680. static readonly GREATER: number;
  27681. /** 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 */
  27682. static readonly GEQUAL: number;
  27683. /** 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 */
  27684. static readonly NOTEQUAL: number;
  27685. /** Passed to stencilOperation to specify that stencil value must be kept */
  27686. static readonly KEEP: number;
  27687. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27688. static readonly REPLACE: number;
  27689. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27690. static readonly INCR: number;
  27691. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27692. static readonly DECR: number;
  27693. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27694. static readonly INVERT: number;
  27695. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27696. static readonly INCR_WRAP: number;
  27697. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27698. static readonly DECR_WRAP: number;
  27699. /** Texture is not repeating outside of 0..1 UVs */
  27700. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27701. /** Texture is repeating outside of 0..1 UVs */
  27702. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27703. /** Texture is repeating and mirrored */
  27704. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27705. /** ALPHA */
  27706. static readonly TEXTUREFORMAT_ALPHA: number;
  27707. /** LUMINANCE */
  27708. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27709. /** LUMINANCE_ALPHA */
  27710. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27711. /** RGB */
  27712. static readonly TEXTUREFORMAT_RGB: number;
  27713. /** RGBA */
  27714. static readonly TEXTUREFORMAT_RGBA: number;
  27715. /** RED */
  27716. static readonly TEXTUREFORMAT_RED: number;
  27717. /** RED (2nd reference) */
  27718. static readonly TEXTUREFORMAT_R: number;
  27719. /** RG */
  27720. static readonly TEXTUREFORMAT_RG: number;
  27721. /** RED_INTEGER */
  27722. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27723. /** RED_INTEGER (2nd reference) */
  27724. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27725. /** RG_INTEGER */
  27726. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27727. /** RGB_INTEGER */
  27728. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27729. /** RGBA_INTEGER */
  27730. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27731. /** UNSIGNED_BYTE */
  27732. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27733. /** UNSIGNED_BYTE (2nd reference) */
  27734. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27735. /** FLOAT */
  27736. static readonly TEXTURETYPE_FLOAT: number;
  27737. /** HALF_FLOAT */
  27738. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27739. /** BYTE */
  27740. static readonly TEXTURETYPE_BYTE: number;
  27741. /** SHORT */
  27742. static readonly TEXTURETYPE_SHORT: number;
  27743. /** UNSIGNED_SHORT */
  27744. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27745. /** INT */
  27746. static readonly TEXTURETYPE_INT: number;
  27747. /** UNSIGNED_INT */
  27748. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27749. /** UNSIGNED_SHORT_4_4_4_4 */
  27750. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27751. /** UNSIGNED_SHORT_5_5_5_1 */
  27752. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27753. /** UNSIGNED_SHORT_5_6_5 */
  27754. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27755. /** UNSIGNED_INT_2_10_10_10_REV */
  27756. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27757. /** UNSIGNED_INT_24_8 */
  27758. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27759. /** UNSIGNED_INT_10F_11F_11F_REV */
  27760. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27761. /** UNSIGNED_INT_5_9_9_9_REV */
  27762. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27763. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27764. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27765. /** nearest is mag = nearest and min = nearest and mip = linear */
  27766. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27767. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27768. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27769. /** Trilinear is mag = linear and min = linear and mip = linear */
  27770. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27771. /** nearest is mag = nearest and min = nearest and mip = linear */
  27772. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27773. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27774. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27775. /** Trilinear is mag = linear and min = linear and mip = linear */
  27776. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27777. /** mag = nearest and min = nearest and mip = nearest */
  27778. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27779. /** mag = nearest and min = linear and mip = nearest */
  27780. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27781. /** mag = nearest and min = linear and mip = linear */
  27782. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27783. /** mag = nearest and min = linear and mip = none */
  27784. static readonly TEXTURE_NEAREST_LINEAR: number;
  27785. /** mag = nearest and min = nearest and mip = none */
  27786. static readonly TEXTURE_NEAREST_NEAREST: number;
  27787. /** mag = linear and min = nearest and mip = nearest */
  27788. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27789. /** mag = linear and min = nearest and mip = linear */
  27790. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27791. /** mag = linear and min = linear and mip = none */
  27792. static readonly TEXTURE_LINEAR_LINEAR: number;
  27793. /** mag = linear and min = nearest and mip = none */
  27794. static readonly TEXTURE_LINEAR_NEAREST: number;
  27795. /** Explicit coordinates mode */
  27796. static readonly TEXTURE_EXPLICIT_MODE: number;
  27797. /** Spherical coordinates mode */
  27798. static readonly TEXTURE_SPHERICAL_MODE: number;
  27799. /** Planar coordinates mode */
  27800. static readonly TEXTURE_PLANAR_MODE: number;
  27801. /** Cubic coordinates mode */
  27802. static readonly TEXTURE_CUBIC_MODE: number;
  27803. /** Projection coordinates mode */
  27804. static readonly TEXTURE_PROJECTION_MODE: number;
  27805. /** Skybox coordinates mode */
  27806. static readonly TEXTURE_SKYBOX_MODE: number;
  27807. /** Inverse Cubic coordinates mode */
  27808. static readonly TEXTURE_INVCUBIC_MODE: number;
  27809. /** Equirectangular coordinates mode */
  27810. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27811. /** Equirectangular Fixed coordinates mode */
  27812. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27813. /** Equirectangular Fixed Mirrored coordinates mode */
  27814. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27815. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27816. static readonly SCALEMODE_FLOOR: number;
  27817. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27818. static readonly SCALEMODE_NEAREST: number;
  27819. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27820. static readonly SCALEMODE_CEILING: number;
  27821. /**
  27822. * Returns the current npm package of the sdk
  27823. */
  27824. static readonly NpmPackage: string;
  27825. /**
  27826. * Returns the current version of the framework
  27827. */
  27828. static readonly Version: string;
  27829. /**
  27830. * Returns a string describing the current engine
  27831. */
  27832. readonly description: string;
  27833. /**
  27834. * Gets or sets the epsilon value used by collision engine
  27835. */
  27836. static CollisionsEpsilon: number;
  27837. /**
  27838. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27839. */
  27840. static ShadersRepository: string;
  27841. /**
  27842. * Method called to create the default loading screen.
  27843. * This can be overriden in your own app.
  27844. * @param canvas The rendering canvas element
  27845. * @returns The loading screen
  27846. */
  27847. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27848. /**
  27849. * Method called to create the default rescale post process on each engine.
  27850. */
  27851. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27852. /**
  27853. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27854. */
  27855. forcePOTTextures: boolean;
  27856. /**
  27857. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27858. */
  27859. isFullscreen: boolean;
  27860. /**
  27861. * Gets a boolean indicating if the pointer is currently locked
  27862. */
  27863. isPointerLock: boolean;
  27864. /**
  27865. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27866. */
  27867. cullBackFaces: boolean;
  27868. /**
  27869. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27870. */
  27871. renderEvenInBackground: boolean;
  27872. /**
  27873. * Gets or sets a boolean indicating that cache can be kept between frames
  27874. */
  27875. preventCacheWipeBetweenFrames: boolean;
  27876. /**
  27877. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27878. **/
  27879. enableOfflineSupport: boolean;
  27880. /**
  27881. * 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)
  27882. **/
  27883. disableManifestCheck: boolean;
  27884. /**
  27885. * Gets the list of created scenes
  27886. */
  27887. scenes: Scene[];
  27888. /**
  27889. * Event raised when a new scene is created
  27890. */
  27891. onNewSceneAddedObservable: Observable<Scene>;
  27892. /**
  27893. * Gets the list of created postprocesses
  27894. */
  27895. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27896. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27897. validateShaderPrograms: boolean;
  27898. /**
  27899. * Observable event triggered each time the rendering canvas is resized
  27900. */
  27901. onResizeObservable: Observable<Engine>;
  27902. /**
  27903. * Observable event triggered each time the canvas loses focus
  27904. */
  27905. onCanvasBlurObservable: Observable<Engine>;
  27906. /**
  27907. * Observable event triggered each time the canvas gains focus
  27908. */
  27909. onCanvasFocusObservable: Observable<Engine>;
  27910. /**
  27911. * Observable event triggered each time the canvas receives pointerout event
  27912. */
  27913. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27914. /**
  27915. * Observable event triggered before each texture is initialized
  27916. */
  27917. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27918. private _vrDisplay;
  27919. private _vrSupported;
  27920. private _oldSize;
  27921. private _oldHardwareScaleFactor;
  27922. private _vrExclusivePointerMode;
  27923. private _webVRInitPromise;
  27924. /**
  27925. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27926. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27927. */
  27928. readonly isInVRExclusivePointerMode: boolean;
  27929. /**
  27930. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27931. */
  27932. disableUniformBuffers: boolean;
  27933. /** @hidden */
  27934. _uniformBuffers: UniformBuffer[];
  27935. /**
  27936. * Gets a boolean indicating that the engine supports uniform buffers
  27937. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27938. */
  27939. readonly supportsUniformBuffers: boolean;
  27940. /**
  27941. * Observable raised when the engine begins a new frame
  27942. */
  27943. onBeginFrameObservable: Observable<Engine>;
  27944. /**
  27945. * If set, will be used to request the next animation frame for the render loop
  27946. */
  27947. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27948. /**
  27949. * Observable raised when the engine ends the current frame
  27950. */
  27951. onEndFrameObservable: Observable<Engine>;
  27952. /**
  27953. * Observable raised when the engine is about to compile a shader
  27954. */
  27955. onBeforeShaderCompilationObservable: Observable<Engine>;
  27956. /**
  27957. * Observable raised when the engine has jsut compiled a shader
  27958. */
  27959. onAfterShaderCompilationObservable: Observable<Engine>;
  27960. /** @hidden */
  27961. _gl: WebGLRenderingContext;
  27962. private _renderingCanvas;
  27963. private _windowIsBackground;
  27964. private _webGLVersion;
  27965. protected _highPrecisionShadersAllowed: boolean;
  27966. /** @hidden */
  27967. readonly _shouldUseHighPrecisionShader: boolean;
  27968. /**
  27969. * Gets a boolean indicating that only power of 2 textures are supported
  27970. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27971. */
  27972. readonly needPOTTextures: boolean;
  27973. /** @hidden */
  27974. _badOS: boolean;
  27975. /** @hidden */
  27976. _badDesktopOS: boolean;
  27977. /**
  27978. * Gets the audio engine
  27979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27980. * @ignorenaming
  27981. */
  27982. static audioEngine: IAudioEngine;
  27983. /**
  27984. * Default AudioEngine factory responsible of creating the Audio Engine.
  27985. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27986. */
  27987. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27988. /**
  27989. * Default offline support factory responsible of creating a tool used to store data locally.
  27990. * By default, this will create a Database object if the workload has been embedded.
  27991. */
  27992. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27993. private _onFocus;
  27994. private _onBlur;
  27995. private _onCanvasPointerOut;
  27996. private _onCanvasBlur;
  27997. private _onCanvasFocus;
  27998. private _onFullscreenChange;
  27999. private _onPointerLockChange;
  28000. private _onVRDisplayPointerRestricted;
  28001. private _onVRDisplayPointerUnrestricted;
  28002. private _onVrDisplayConnect;
  28003. private _onVrDisplayDisconnect;
  28004. private _onVrDisplayPresentChange;
  28005. /**
  28006. * Observable signaled when VR display mode changes
  28007. */
  28008. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  28009. /**
  28010. * Observable signaled when VR request present is complete
  28011. */
  28012. onVRRequestPresentComplete: Observable<boolean>;
  28013. /**
  28014. * Observable signaled when VR request present starts
  28015. */
  28016. onVRRequestPresentStart: Observable<Engine>;
  28017. private _hardwareScalingLevel;
  28018. /** @hidden */
  28019. protected _caps: EngineCapabilities;
  28020. private _pointerLockRequested;
  28021. private _isStencilEnable;
  28022. private _colorWrite;
  28023. private _loadingScreen;
  28024. /** @hidden */
  28025. _drawCalls: PerfCounter;
  28026. private _glVersion;
  28027. private _glRenderer;
  28028. private _glVendor;
  28029. private _videoTextureSupported;
  28030. private _renderingQueueLaunched;
  28031. private _activeRenderLoops;
  28032. private _deterministicLockstep;
  28033. private _lockstepMaxSteps;
  28034. /**
  28035. * Observable signaled when a context lost event is raised
  28036. */
  28037. onContextLostObservable: Observable<Engine>;
  28038. /**
  28039. * Observable signaled when a context restored event is raised
  28040. */
  28041. onContextRestoredObservable: Observable<Engine>;
  28042. private _onContextLost;
  28043. private _onContextRestored;
  28044. private _contextWasLost;
  28045. private _doNotHandleContextLost;
  28046. /**
  28047. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28048. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28049. */
  28050. doNotHandleContextLost: boolean;
  28051. private _performanceMonitor;
  28052. private _fps;
  28053. private _deltaTime;
  28054. /**
  28055. * Turn this value on if you want to pause FPS computation when in background
  28056. */
  28057. disablePerformanceMonitorInBackground: boolean;
  28058. /**
  28059. * Gets the performance monitor attached to this engine
  28060. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28061. */
  28062. readonly performanceMonitor: PerformanceMonitor;
  28063. /**
  28064. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28065. */
  28066. disableVertexArrayObjects: boolean;
  28067. /** @hidden */
  28068. protected _depthCullingState: _DepthCullingState;
  28069. /** @hidden */
  28070. protected _stencilState: _StencilState;
  28071. /** @hidden */
  28072. protected _alphaState: _AlphaState;
  28073. /** @hidden */
  28074. protected _alphaMode: number;
  28075. protected _internalTexturesCache: InternalTexture[];
  28076. /** @hidden */
  28077. protected _activeChannel: number;
  28078. private _currentTextureChannel;
  28079. /** @hidden */
  28080. protected _boundTexturesCache: {
  28081. [key: string]: Nullable<InternalTexture>;
  28082. };
  28083. /** @hidden */
  28084. protected _currentEffect: Nullable<Effect>;
  28085. /** @hidden */
  28086. protected _currentProgram: Nullable<WebGLProgram>;
  28087. private _compiledEffects;
  28088. private _vertexAttribArraysEnabled;
  28089. /** @hidden */
  28090. protected _cachedViewport: Nullable<Viewport>;
  28091. private _cachedVertexArrayObject;
  28092. /** @hidden */
  28093. protected _cachedVertexBuffers: any;
  28094. /** @hidden */
  28095. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  28096. /** @hidden */
  28097. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28098. /** @hidden */
  28099. protected _currentRenderTarget: Nullable<InternalTexture>;
  28100. private _uintIndicesCurrentlySet;
  28101. private _currentBoundBuffer;
  28102. /** @hidden */
  28103. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28104. private _currentBufferPointers;
  28105. private _currentInstanceLocations;
  28106. private _currentInstanceBuffers;
  28107. private _textureUnits;
  28108. private _workingCanvas;
  28109. private _workingContext;
  28110. private _rescalePostProcess;
  28111. private _dummyFramebuffer;
  28112. private _externalData;
  28113. private _bindedRenderFunction;
  28114. private _vaoRecordInProgress;
  28115. private _mustWipeVertexAttributes;
  28116. private _emptyTexture;
  28117. private _emptyCubeTexture;
  28118. private _emptyTexture3D;
  28119. /** @hidden */
  28120. _frameHandler: number;
  28121. private _nextFreeTextureSlots;
  28122. private _maxSimultaneousTextures;
  28123. private _activeRequests;
  28124. private _texturesSupported;
  28125. private _textureFormatInUse;
  28126. /**
  28127. * Gets the list of texture formats supported
  28128. */
  28129. readonly texturesSupported: Array<string>;
  28130. /**
  28131. * Gets the list of texture formats in use
  28132. */
  28133. readonly textureFormatInUse: Nullable<string>;
  28134. /**
  28135. * Gets the current viewport
  28136. */
  28137. readonly currentViewport: Nullable<Viewport>;
  28138. /**
  28139. * Gets the default empty texture
  28140. */
  28141. readonly emptyTexture: InternalTexture;
  28142. /**
  28143. * Gets the default empty 3D texture
  28144. */
  28145. readonly emptyTexture3D: InternalTexture;
  28146. /**
  28147. * Gets the default empty cube texture
  28148. */
  28149. readonly emptyCubeTexture: InternalTexture;
  28150. /**
  28151. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28152. */
  28153. readonly premultipliedAlpha: boolean;
  28154. /**
  28155. * Creates a new engine
  28156. * @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
  28157. * @param antialias defines enable antialiasing (default: false)
  28158. * @param options defines further options to be sent to the getContext() function
  28159. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28160. */
  28161. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28162. private _disableTouchAction;
  28163. private _rebuildInternalTextures;
  28164. private _rebuildEffects;
  28165. /**
  28166. * Gets a boolean indicating if all created effects are ready
  28167. * @returns true if all effects are ready
  28168. */
  28169. areAllEffectsReady(): boolean;
  28170. private _rebuildBuffers;
  28171. private _initGLContext;
  28172. /**
  28173. * Gets version of the current webGL context
  28174. */
  28175. readonly webGLVersion: number;
  28176. /**
  28177. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28178. */
  28179. readonly isStencilEnable: boolean;
  28180. private _prepareWorkingCanvas;
  28181. /**
  28182. * Reset the texture cache to empty state
  28183. */
  28184. resetTextureCache(): void;
  28185. /**
  28186. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28187. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28188. * @returns true if engine is in deterministic lock step mode
  28189. */
  28190. isDeterministicLockStep(): boolean;
  28191. /**
  28192. * Gets the max steps when engine is running in deterministic lock step
  28193. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28194. * @returns the max steps
  28195. */
  28196. getLockstepMaxSteps(): number;
  28197. /**
  28198. * Gets an object containing information about the current webGL context
  28199. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28200. */
  28201. getGlInfo(): {
  28202. vendor: string;
  28203. renderer: string;
  28204. version: string;
  28205. };
  28206. /**
  28207. * Gets current aspect ratio
  28208. * @param camera defines the camera to use to get the aspect ratio
  28209. * @param useScreen defines if screen size must be used (or the current render target if any)
  28210. * @returns a number defining the aspect ratio
  28211. */
  28212. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28213. /**
  28214. * Gets current screen aspect ratio
  28215. * @returns a number defining the aspect ratio
  28216. */
  28217. getScreenAspectRatio(): number;
  28218. /**
  28219. * Gets the current render width
  28220. * @param useScreen defines if screen size must be used (or the current render target if any)
  28221. * @returns a number defining the current render width
  28222. */
  28223. getRenderWidth(useScreen?: boolean): number;
  28224. /**
  28225. * Gets the current render height
  28226. * @param useScreen defines if screen size must be used (or the current render target if any)
  28227. * @returns a number defining the current render height
  28228. */
  28229. getRenderHeight(useScreen?: boolean): number;
  28230. /**
  28231. * Gets the HTML canvas attached with the current webGL context
  28232. * @returns a HTML canvas
  28233. */
  28234. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28235. /**
  28236. * Gets the client rect of the HTML canvas attached with the current webGL context
  28237. * @returns a client rectanglee
  28238. */
  28239. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28240. /**
  28241. * Defines the 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. * @param level defines the level to use
  28245. */
  28246. setHardwareScalingLevel(level: number): void;
  28247. /**
  28248. * Gets the current hardware scaling level.
  28249. * By default the hardware scaling level is computed from the window device ratio.
  28250. * 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.
  28251. * @returns a number indicating the current hardware scaling level
  28252. */
  28253. getHardwareScalingLevel(): number;
  28254. /**
  28255. * Gets the list of loaded textures
  28256. * @returns an array containing all loaded textures
  28257. */
  28258. getLoadedTexturesCache(): InternalTexture[];
  28259. /**
  28260. * Gets the object containing all engine capabilities
  28261. * @returns the EngineCapabilities object
  28262. */
  28263. getCaps(): EngineCapabilities;
  28264. /**
  28265. * Gets the current depth function
  28266. * @returns a number defining the depth function
  28267. */
  28268. getDepthFunction(): Nullable<number>;
  28269. /**
  28270. * Sets the current depth function
  28271. * @param depthFunc defines the function to use
  28272. */
  28273. setDepthFunction(depthFunc: number): void;
  28274. /**
  28275. * Sets the current depth function to GREATER
  28276. */
  28277. setDepthFunctionToGreater(): void;
  28278. /**
  28279. * Sets the current depth function to GEQUAL
  28280. */
  28281. setDepthFunctionToGreaterOrEqual(): void;
  28282. /**
  28283. * Sets the current depth function to LESS
  28284. */
  28285. setDepthFunctionToLess(): void;
  28286. private _cachedStencilBuffer;
  28287. private _cachedStencilFunction;
  28288. private _cachedStencilMask;
  28289. private _cachedStencilOperationPass;
  28290. private _cachedStencilOperationFail;
  28291. private _cachedStencilOperationDepthFail;
  28292. private _cachedStencilReference;
  28293. /**
  28294. * Caches the the state of the stencil buffer
  28295. */
  28296. cacheStencilState(): void;
  28297. /**
  28298. * Restores the state of the stencil buffer
  28299. */
  28300. restoreStencilState(): void;
  28301. /**
  28302. * Sets the current depth function to LEQUAL
  28303. */
  28304. setDepthFunctionToLessOrEqual(): void;
  28305. /**
  28306. * Gets a boolean indicating if stencil buffer is enabled
  28307. * @returns the current stencil buffer state
  28308. */
  28309. getStencilBuffer(): boolean;
  28310. /**
  28311. * Enable or disable the stencil buffer
  28312. * @param enable defines if the stencil buffer must be enabled or disabled
  28313. */
  28314. setStencilBuffer(enable: boolean): void;
  28315. /**
  28316. * Gets the current stencil mask
  28317. * @returns a number defining the new stencil mask to use
  28318. */
  28319. getStencilMask(): number;
  28320. /**
  28321. * Sets the current stencil mask
  28322. * @param mask defines the new stencil mask to use
  28323. */
  28324. setStencilMask(mask: number): void;
  28325. /**
  28326. * Gets the current stencil function
  28327. * @returns a number defining the stencil function to use
  28328. */
  28329. getStencilFunction(): number;
  28330. /**
  28331. * Gets the current stencil reference value
  28332. * @returns a number defining the stencil reference value to use
  28333. */
  28334. getStencilFunctionReference(): number;
  28335. /**
  28336. * Gets the current stencil mask
  28337. * @returns a number defining the stencil mask to use
  28338. */
  28339. getStencilFunctionMask(): number;
  28340. /**
  28341. * Sets the current stencil function
  28342. * @param stencilFunc defines the new stencil function to use
  28343. */
  28344. setStencilFunction(stencilFunc: number): void;
  28345. /**
  28346. * Sets the current stencil reference
  28347. * @param reference defines the new stencil reference to use
  28348. */
  28349. setStencilFunctionReference(reference: number): void;
  28350. /**
  28351. * Sets the current stencil mask
  28352. * @param mask defines the new stencil mask to use
  28353. */
  28354. setStencilFunctionMask(mask: number): void;
  28355. /**
  28356. * Gets the current stencil operation when stencil fails
  28357. * @returns a number defining stencil operation to use when stencil fails
  28358. */
  28359. getStencilOperationFail(): number;
  28360. /**
  28361. * Gets the current stencil operation when depth fails
  28362. * @returns a number defining stencil operation to use when depth fails
  28363. */
  28364. getStencilOperationDepthFail(): number;
  28365. /**
  28366. * Gets the current stencil operation when stencil passes
  28367. * @returns a number defining stencil operation to use when stencil passes
  28368. */
  28369. getStencilOperationPass(): number;
  28370. /**
  28371. * Sets the stencil operation to use when stencil fails
  28372. * @param operation defines the stencil operation to use when stencil fails
  28373. */
  28374. setStencilOperationFail(operation: number): void;
  28375. /**
  28376. * Sets the stencil operation to use when depth fails
  28377. * @param operation defines the stencil operation to use when depth fails
  28378. */
  28379. setStencilOperationDepthFail(operation: number): void;
  28380. /**
  28381. * Sets the stencil operation to use when stencil passes
  28382. * @param operation defines the stencil operation to use when stencil passes
  28383. */
  28384. setStencilOperationPass(operation: number): void;
  28385. /**
  28386. * Sets a boolean indicating if the dithering state is enabled or disabled
  28387. * @param value defines the dithering state
  28388. */
  28389. setDitheringState(value: boolean): void;
  28390. /**
  28391. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28392. * @param value defines the rasterizer state
  28393. */
  28394. setRasterizerState(value: boolean): void;
  28395. /**
  28396. * stop executing a render loop function and remove it from the execution array
  28397. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28398. */
  28399. stopRenderLoop(renderFunction?: () => void): void;
  28400. /** @hidden */
  28401. _renderLoop(): void;
  28402. /**
  28403. * Register and execute a render loop. The engine can have more than one render function
  28404. * @param renderFunction defines the function to continuously execute
  28405. */
  28406. runRenderLoop(renderFunction: () => void): void;
  28407. /**
  28408. * Toggle full screen mode
  28409. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28410. */
  28411. switchFullscreen(requestPointerLock: boolean): void;
  28412. /**
  28413. * Enters full screen mode
  28414. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28415. */
  28416. enterFullscreen(requestPointerLock: boolean): void;
  28417. /**
  28418. * Exits full screen mode
  28419. */
  28420. exitFullscreen(): void;
  28421. /**
  28422. * Clear the current render buffer or the current render target (if any is set up)
  28423. * @param color defines the color to use
  28424. * @param backBuffer defines if the back buffer must be cleared
  28425. * @param depth defines if the depth buffer must be cleared
  28426. * @param stencil defines if the stencil buffer must be cleared
  28427. */
  28428. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28429. /**
  28430. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28431. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28432. * @param y defines the y-coordinate of the corner of the clear rectangle
  28433. * @param width defines the width of the clear rectangle
  28434. * @param height defines the height of the clear rectangle
  28435. * @param clearColor defines the clear color
  28436. */
  28437. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28438. /**
  28439. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28440. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28441. * @param y defines the y-coordinate of the corner of the clear rectangle
  28442. * @param width defines the width of the clear rectangle
  28443. * @param height defines the height of the clear rectangle
  28444. */
  28445. enableScissor(x: number, y: number, width: number, height: number): void;
  28446. /**
  28447. * Disable previously set scissor test rectangle
  28448. */
  28449. disableScissor(): void;
  28450. private _viewportCached;
  28451. /** @hidden */
  28452. _viewport(x: number, y: number, width: number, height: number): void;
  28453. /**
  28454. * Set the WebGL's viewport
  28455. * @param viewport defines the viewport element to be used
  28456. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28457. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28458. */
  28459. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28460. /**
  28461. * Directly set the WebGL Viewport
  28462. * @param x defines the x coordinate of the viewport (in screen space)
  28463. * @param y defines the y coordinate of the viewport (in screen space)
  28464. * @param width defines the width of the viewport (in screen space)
  28465. * @param height defines the height of the viewport (in screen space)
  28466. * @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
  28467. */
  28468. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28469. /**
  28470. * Begin a new frame
  28471. */
  28472. beginFrame(): void;
  28473. /**
  28474. * Enf the current frame
  28475. */
  28476. endFrame(): void;
  28477. /**
  28478. * Resize the view according to the canvas' size
  28479. */
  28480. resize(): void;
  28481. /**
  28482. * Force a specific size of the canvas
  28483. * @param width defines the new canvas' width
  28484. * @param height defines the new canvas' height
  28485. */
  28486. setSize(width: number, height: number): void;
  28487. /**
  28488. * Gets a boolean indicating if a webVR device was detected
  28489. * @returns true if a webVR device was detected
  28490. */
  28491. isVRDevicePresent(): boolean;
  28492. /**
  28493. * Gets the current webVR device
  28494. * @returns the current webVR device (or null)
  28495. */
  28496. getVRDevice(): any;
  28497. /**
  28498. * Initializes a webVR display and starts listening to display change events
  28499. * The onVRDisplayChangedObservable will be notified upon these changes
  28500. * @returns The onVRDisplayChangedObservable
  28501. */
  28502. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28503. /**
  28504. * Initializes a webVR display and starts listening to display change events
  28505. * The onVRDisplayChangedObservable will be notified upon these changes
  28506. * @returns A promise containing a VRDisplay and if vr is supported
  28507. */
  28508. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28509. /**
  28510. * Call this function to switch to webVR mode
  28511. * Will do nothing if webVR is not supported or if there is no webVR device
  28512. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28513. */
  28514. enableVR(): void;
  28515. /**
  28516. * Call this function to leave webVR mode
  28517. * Will do nothing if webVR is not supported or if there is no webVR device
  28518. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28519. */
  28520. disableVR(): void;
  28521. private _onVRFullScreenTriggered;
  28522. private _getVRDisplaysAsync;
  28523. /**
  28524. * Binds the frame buffer to the specified texture.
  28525. * @param texture The texture to render to or null for the default canvas
  28526. * @param faceIndex The face of the texture to render to in case of cube texture
  28527. * @param requiredWidth The width of the target to render to
  28528. * @param requiredHeight The height of the target to render to
  28529. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28530. * @param depthStencilTexture The depth stencil texture to use to render
  28531. * @param lodLevel defines le lod level to bind to the frame buffer
  28532. */
  28533. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28534. private bindUnboundFramebuffer;
  28535. /**
  28536. * Unbind the current render target texture from the webGL context
  28537. * @param texture defines the render target texture to unbind
  28538. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28539. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28540. */
  28541. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28542. /**
  28543. * Unbind a list of render target textures from the webGL context
  28544. * This is used only when drawBuffer extension or webGL2 are active
  28545. * @param textures defines the render target textures to unbind
  28546. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28547. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28548. */
  28549. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28550. /**
  28551. * Force the mipmap generation for the given render target texture
  28552. * @param texture defines the render target texture to use
  28553. */
  28554. generateMipMapsForCubemap(texture: InternalTexture): void;
  28555. /**
  28556. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28557. */
  28558. flushFramebuffer(): void;
  28559. /**
  28560. * Unbind the current render target and bind the default framebuffer
  28561. */
  28562. restoreDefaultFramebuffer(): void;
  28563. /**
  28564. * Create an 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. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28570. /**
  28571. * Create a dynamic uniform buffer
  28572. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28573. * @param elements defines the content of the uniform buffer
  28574. * @returns the webGL uniform buffer
  28575. */
  28576. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28577. /**
  28578. * Update an existing uniform buffer
  28579. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28580. * @param uniformBuffer defines the target uniform buffer
  28581. * @param elements defines the content to update
  28582. * @param offset defines the offset in the uniform buffer where update should start
  28583. * @param count defines the size of the data to update
  28584. */
  28585. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28586. private _resetVertexBufferBinding;
  28587. /**
  28588. * Creates a vertex buffer
  28589. * @param data the data for the vertex buffer
  28590. * @returns the new WebGL static buffer
  28591. */
  28592. createVertexBuffer(data: DataArray): WebGLBuffer;
  28593. /**
  28594. * Creates a dynamic vertex buffer
  28595. * @param data the data for the dynamic vertex buffer
  28596. * @returns the new WebGL dynamic buffer
  28597. */
  28598. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28599. /**
  28600. * Update a dynamic index buffer
  28601. * @param indexBuffer defines the target index buffer
  28602. * @param indices defines the data to update
  28603. * @param offset defines the offset in the target index buffer where update should start
  28604. */
  28605. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28606. /**
  28607. * Updates a dynamic vertex buffer.
  28608. * @param vertexBuffer the vertex buffer to update
  28609. * @param data the data used to update the vertex buffer
  28610. * @param byteOffset the byte offset of the data
  28611. * @param byteLength the byte length of the data
  28612. */
  28613. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28614. private _resetIndexBufferBinding;
  28615. /**
  28616. * Creates a new index buffer
  28617. * @param indices defines the content of the index buffer
  28618. * @param updatable defines if the index buffer must be updatable
  28619. * @returns a new webGL buffer
  28620. */
  28621. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28622. /**
  28623. * Bind a webGL buffer to the webGL context
  28624. * @param buffer defines the buffer to bind
  28625. */
  28626. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28627. /**
  28628. * Bind an uniform buffer to the current webGL context
  28629. * @param buffer defines the buffer to bind
  28630. */
  28631. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28632. /**
  28633. * Bind a buffer to the current webGL context at a given location
  28634. * @param buffer defines the buffer to bind
  28635. * @param location defines the index where to bind the buffer
  28636. */
  28637. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28638. /**
  28639. * Bind a specific block at a given index in a specific shader program
  28640. * @param shaderProgram defines the shader program
  28641. * @param blockName defines the block name
  28642. * @param index defines the index where to bind the block
  28643. */
  28644. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28645. private bindIndexBuffer;
  28646. private bindBuffer;
  28647. /**
  28648. * update the bound buffer with the given data
  28649. * @param data defines the data to update
  28650. */
  28651. updateArrayBuffer(data: Float32Array): void;
  28652. private _vertexAttribPointer;
  28653. private _bindIndexBufferWithCache;
  28654. private _bindVertexBuffersAttributes;
  28655. /**
  28656. * Records a vertex array object
  28657. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28658. * @param vertexBuffers defines the list of vertex buffers to store
  28659. * @param indexBuffer defines the index buffer to store
  28660. * @param effect defines the effect to store
  28661. * @returns the new vertex array object
  28662. */
  28663. recordVertexArrayObject(vertexBuffers: {
  28664. [key: string]: VertexBuffer;
  28665. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28666. /**
  28667. * Bind a specific vertex array object
  28668. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28669. * @param vertexArrayObject defines the vertex array object to bind
  28670. * @param indexBuffer defines the index buffer to bind
  28671. */
  28672. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28673. /**
  28674. * Bind webGl buffers directly to the webGL context
  28675. * @param vertexBuffer defines the vertex buffer to bind
  28676. * @param indexBuffer defines the index buffer to bind
  28677. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28678. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28679. * @param effect defines the effect associated with the vertex buffer
  28680. */
  28681. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28682. private _unbindVertexArrayObject;
  28683. /**
  28684. * Bind a list of vertex buffers to the webGL context
  28685. * @param vertexBuffers defines the list of vertex buffers to bind
  28686. * @param indexBuffer defines the index buffer to bind
  28687. * @param effect defines the effect associated with the vertex buffers
  28688. */
  28689. bindBuffers(vertexBuffers: {
  28690. [key: string]: Nullable<VertexBuffer>;
  28691. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28692. /**
  28693. * Unbind all instance attributes
  28694. */
  28695. unbindInstanceAttributes(): void;
  28696. /**
  28697. * Release and free the memory of a vertex array object
  28698. * @param vao defines the vertex array object to delete
  28699. */
  28700. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28701. /** @hidden */
  28702. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28703. /**
  28704. * Creates a webGL buffer to use with instanciation
  28705. * @param capacity defines the size of the buffer
  28706. * @returns the webGL buffer
  28707. */
  28708. createInstancesBuffer(capacity: number): WebGLBuffer;
  28709. /**
  28710. * Delete a webGL buffer used with instanciation
  28711. * @param buffer defines the webGL buffer to delete
  28712. */
  28713. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28714. /**
  28715. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28716. * @param instancesBuffer defines the webGL buffer to update and bind
  28717. * @param data defines the data to store in the buffer
  28718. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28719. */
  28720. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28721. /**
  28722. * Apply all cached states (depth, culling, stencil and alpha)
  28723. */
  28724. applyStates(): void;
  28725. /**
  28726. * Send a draw order
  28727. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28728. * @param indexStart defines the starting index
  28729. * @param indexCount defines the number of index to draw
  28730. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28731. */
  28732. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28733. /**
  28734. * Draw a list of points
  28735. * @param verticesStart defines the index of first vertex to draw
  28736. * @param verticesCount defines the count of vertices to draw
  28737. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28738. */
  28739. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28740. /**
  28741. * Draw a list of unindexed primitives
  28742. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28743. * @param verticesStart defines the index of first vertex to draw
  28744. * @param verticesCount defines the count of vertices to draw
  28745. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28746. */
  28747. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28748. /**
  28749. * Draw a list of indexed primitives
  28750. * @param fillMode defines the primitive to use
  28751. * @param indexStart defines the starting index
  28752. * @param indexCount defines the number of index to draw
  28753. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28754. */
  28755. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28756. /**
  28757. * Draw a list of unindexed primitives
  28758. * @param fillMode defines the primitive to use
  28759. * @param verticesStart defines the index of first vertex to draw
  28760. * @param verticesCount defines the count of vertices to draw
  28761. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28762. */
  28763. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28764. private _drawMode;
  28765. /** @hidden */
  28766. _releaseEffect(effect: Effect): void;
  28767. /** @hidden */
  28768. _deleteProgram(program: WebGLProgram): void;
  28769. /**
  28770. * Create a new effect (used to store vertex/fragment shaders)
  28771. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28772. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28773. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28774. * @param samplers defines an array of string used to represent textures
  28775. * @param defines defines the string containing the defines to use to compile the shaders
  28776. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28777. * @param onCompiled defines a function to call when the effect creation is successful
  28778. * @param onError defines a function to call when the effect creation has failed
  28779. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28780. * @returns the new Effect
  28781. */
  28782. 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;
  28783. private _compileShader;
  28784. private _compileRawShader;
  28785. /**
  28786. * Directly creates a webGL program
  28787. * @param vertexCode defines the vertex shader code to use
  28788. * @param fragmentCode defines the fragment shader code to use
  28789. * @param context defines the webGL context to use (if not set, the current one will be used)
  28790. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28791. * @returns the new webGL program
  28792. */
  28793. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28794. /**
  28795. * Creates a webGL program
  28796. * @param vertexCode defines the vertex shader code to use
  28797. * @param fragmentCode defines the fragment shader code to use
  28798. * @param defines defines the string containing the defines to use to compile the shaders
  28799. * @param context defines the webGL context to use (if not set, the current one will be used)
  28800. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28801. * @returns the new webGL program
  28802. */
  28803. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28804. private _createShaderProgram;
  28805. private _finalizeProgram;
  28806. /** @hidden */
  28807. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28808. /** @hidden */
  28809. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28810. /**
  28811. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28812. * @param shaderProgram defines the webGL program to use
  28813. * @param uniformsNames defines the list of uniform names
  28814. * @returns an array of webGL uniform locations
  28815. */
  28816. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28817. /**
  28818. * Gets the lsit of active attributes for a given webGL program
  28819. * @param shaderProgram defines the webGL program to use
  28820. * @param attributesNames defines the list of attribute names to get
  28821. * @returns an array of indices indicating the offset of each attribute
  28822. */
  28823. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28824. /**
  28825. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28826. * @param effect defines the effect to activate
  28827. */
  28828. enableEffect(effect: Nullable<Effect>): void;
  28829. /**
  28830. * Set the value of an uniform to an array of int32
  28831. * @param uniform defines the webGL uniform location where to store the value
  28832. * @param array defines the array of int32 to store
  28833. */
  28834. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28835. /**
  28836. * Set the value of an uniform to an array of int32 (stored as vec2)
  28837. * @param uniform defines the webGL uniform location where to store the value
  28838. * @param array defines the array of int32 to store
  28839. */
  28840. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28841. /**
  28842. * Set the value of an uniform to an array of int32 (stored as vec3)
  28843. * @param uniform defines the webGL uniform location where to store the value
  28844. * @param array defines the array of int32 to store
  28845. */
  28846. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28847. /**
  28848. * Set the value of an uniform to an array of int32 (stored as vec4)
  28849. * @param uniform defines the webGL uniform location where to store the value
  28850. * @param array defines the array of int32 to store
  28851. */
  28852. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28853. /**
  28854. * Set the value of an uniform to an array of float32
  28855. * @param uniform defines the webGL uniform location where to store the value
  28856. * @param array defines the array of float32 to store
  28857. */
  28858. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28859. /**
  28860. * Set the value of an uniform to an array of float32 (stored as vec2)
  28861. * @param uniform defines the webGL uniform location where to store the value
  28862. * @param array defines the array of float32 to store
  28863. */
  28864. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28865. /**
  28866. * Set the value of an uniform to an array of float32 (stored as vec3)
  28867. * @param uniform defines the webGL uniform location where to store the value
  28868. * @param array defines the array of float32 to store
  28869. */
  28870. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28871. /**
  28872. * Set the value of an uniform to an array of float32 (stored as vec4)
  28873. * @param uniform defines the webGL uniform location where to store the value
  28874. * @param array defines the array of float32 to store
  28875. */
  28876. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28877. /**
  28878. * Set the value of an uniform to an array of number
  28879. * @param uniform defines the webGL uniform location where to store the value
  28880. * @param array defines the array of number to store
  28881. */
  28882. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28883. /**
  28884. * Set the value of an uniform to an array of number (stored as vec2)
  28885. * @param uniform defines the webGL uniform location where to store the value
  28886. * @param array defines the array of number to store
  28887. */
  28888. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28889. /**
  28890. * Set the value of an uniform to an array of number (stored as vec3)
  28891. * @param uniform defines the webGL uniform location where to store the value
  28892. * @param array defines the array of number to store
  28893. */
  28894. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28895. /**
  28896. * Set the value of an uniform to an array of number (stored as vec4)
  28897. * @param uniform defines the webGL uniform location where to store the value
  28898. * @param array defines the array of number to store
  28899. */
  28900. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28901. /**
  28902. * Set the value of an uniform to an array of float32 (stored as matrices)
  28903. * @param uniform defines the webGL uniform location where to store the value
  28904. * @param matrices defines the array of float32 to store
  28905. */
  28906. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28907. /**
  28908. * Set the value of an uniform to a matrix
  28909. * @param uniform defines the webGL uniform location where to store the value
  28910. * @param matrix defines the matrix to store
  28911. */
  28912. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28913. /**
  28914. * Set the value of an uniform to a matrix (3x3)
  28915. * @param uniform defines the webGL uniform location where to store the value
  28916. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28917. */
  28918. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28919. /**
  28920. * Set the value of an uniform to a matrix (2x2)
  28921. * @param uniform defines the webGL uniform location where to store the value
  28922. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28923. */
  28924. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28925. /**
  28926. * Set the value of an uniform to a number (int)
  28927. * @param uniform defines the webGL uniform location where to store the value
  28928. * @param value defines the int number to store
  28929. */
  28930. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28931. /**
  28932. * Set the value of an uniform to a number (float)
  28933. * @param uniform defines the webGL uniform location where to store the value
  28934. * @param value defines the float number to store
  28935. */
  28936. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28937. /**
  28938. * Set the value of an uniform to a vec2
  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. */
  28943. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28944. /**
  28945. * Set the value of an uniform to a vec3
  28946. * @param uniform defines the webGL uniform location where to store the value
  28947. * @param x defines the 1st component of the value
  28948. * @param y defines the 2nd component of the value
  28949. * @param z defines the 3rd component of the value
  28950. */
  28951. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28952. /**
  28953. * Set the value of an uniform to a boolean
  28954. * @param uniform defines the webGL uniform location where to store the value
  28955. * @param bool defines the boolean to store
  28956. */
  28957. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28958. /**
  28959. * Set the value of an uniform to a vec4
  28960. * @param uniform defines the webGL uniform location where to store the value
  28961. * @param x defines the 1st component of the value
  28962. * @param y defines the 2nd component of the value
  28963. * @param z defines the 3rd component of the value
  28964. * @param w defines the 4th component of the value
  28965. */
  28966. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28967. /**
  28968. * Set the value of an uniform to a Color3
  28969. * @param uniform defines the webGL uniform location where to store the value
  28970. * @param color3 defines the color to store
  28971. */
  28972. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28973. /**
  28974. * Set the value of an uniform to a Color3 and an alpha value
  28975. * @param uniform defines the webGL uniform location where to store the value
  28976. * @param color3 defines the color to store
  28977. * @param alpha defines the alpha component to store
  28978. */
  28979. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28980. /**
  28981. * Sets a Color4 on a uniform variable
  28982. * @param uniform defines the uniform location
  28983. * @param color4 defines the value to be set
  28984. */
  28985. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28986. /**
  28987. * Set various states to the webGL context
  28988. * @param culling defines backface culling state
  28989. * @param zOffset defines the value to apply to zOffset (0 by default)
  28990. * @param force defines if states must be applied even if cache is up to date
  28991. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28992. */
  28993. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28994. /**
  28995. * Set the z offset to apply to current rendering
  28996. * @param value defines the offset to apply
  28997. */
  28998. setZOffset(value: number): void;
  28999. /**
  29000. * Gets the current value of the zOffset
  29001. * @returns the current zOffset state
  29002. */
  29003. getZOffset(): number;
  29004. /**
  29005. * Enable or disable depth buffering
  29006. * @param enable defines the state to set
  29007. */
  29008. setDepthBuffer(enable: boolean): void;
  29009. /**
  29010. * Gets a boolean indicating if depth writing is enabled
  29011. * @returns the current depth writing state
  29012. */
  29013. getDepthWrite(): boolean;
  29014. /**
  29015. * Enable or disable depth writing
  29016. * @param enable defines the state to set
  29017. */
  29018. setDepthWrite(enable: boolean): void;
  29019. /**
  29020. * Enable or disable color writing
  29021. * @param enable defines the state to set
  29022. */
  29023. setColorWrite(enable: boolean): void;
  29024. /**
  29025. * Gets a boolean indicating if color writing is enabled
  29026. * @returns the current color writing state
  29027. */
  29028. getColorWrite(): boolean;
  29029. /**
  29030. * Sets alpha constants used by some alpha blending modes
  29031. * @param r defines the red component
  29032. * @param g defines the green component
  29033. * @param b defines the blue component
  29034. * @param a defines the alpha component
  29035. */
  29036. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29037. /**
  29038. * Sets the current alpha mode
  29039. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29040. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29041. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29042. */
  29043. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29044. /**
  29045. * Gets the current alpha mode
  29046. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29047. * @returns the current alpha mode
  29048. */
  29049. getAlphaMode(): number;
  29050. /**
  29051. * Clears the list of texture accessible through engine.
  29052. * This can help preventing texture load conflict due to name collision.
  29053. */
  29054. clearInternalTexturesCache(): void;
  29055. /**
  29056. * Force the entire cache to be cleared
  29057. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29058. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29059. */
  29060. wipeCaches(bruteForce?: boolean): void;
  29061. /**
  29062. * Set the compressed texture format to use, based on the formats you have, and the formats
  29063. * supported by the hardware / browser.
  29064. *
  29065. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29066. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29067. * to API arguments needed to compressed textures. This puts the burden on the container
  29068. * generator to house the arcane code for determining these for current & future formats.
  29069. *
  29070. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29071. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29072. *
  29073. * Note: The result of this call is not taken into account when a texture is base64.
  29074. *
  29075. * @param formatsAvailable defines the list of those format families you have created
  29076. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29077. *
  29078. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29079. * @returns The extension selected.
  29080. */
  29081. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29082. private _getSamplingParameters;
  29083. private _partialLoadImg;
  29084. private _cascadeLoadImgs;
  29085. /** @hidden */
  29086. _createTexture(): WebGLTexture;
  29087. /**
  29088. * Usually called from Texture.ts.
  29089. * Passed information to create a WebGLTexture
  29090. * @param urlArg defines a value which contains one of the following:
  29091. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29092. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29093. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29094. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29095. * @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)
  29096. * @param scene needed for loading to the correct scene
  29097. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29098. * @param onLoad optional callback to be called upon successful completion
  29099. * @param onError optional callback to be called upon failure
  29100. * @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
  29101. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29102. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29103. * @param forcedExtension defines the extension to use to pick the right loader
  29104. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29105. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29106. */
  29107. 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;
  29108. private _rescaleTexture;
  29109. /**
  29110. * Update a raw texture
  29111. * @param texture defines the texture to update
  29112. * @param data defines the data to store in the texture
  29113. * @param format defines the format of the data
  29114. * @param invertY defines if data must be stored with Y axis inverted
  29115. * @param compression defines the compression used (null by default)
  29116. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29117. */
  29118. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  29119. /**
  29120. * Creates a raw texture
  29121. * @param data defines the data to store in the texture
  29122. * @param width defines the width of the texture
  29123. * @param height defines the height of the texture
  29124. * @param format defines the format of the data
  29125. * @param generateMipMaps defines if the engine should generate the mip levels
  29126. * @param invertY defines if data must be stored with Y axis inverted
  29127. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29128. * @param compression defines the compression used (null by default)
  29129. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29130. * @returns the raw texture inside an InternalTexture
  29131. */
  29132. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29133. private _unpackFlipYCached;
  29134. /**
  29135. * In case you are sharing the context with other applications, it might
  29136. * be interested to not cache the unpack flip y state to ensure a consistent
  29137. * value would be set.
  29138. */
  29139. enableUnpackFlipYCached: boolean;
  29140. /** @hidden */
  29141. _unpackFlipY(value: boolean): void;
  29142. /** @hidden */
  29143. _getUnpackAlignement(): number;
  29144. /**
  29145. * Creates a dynamic texture
  29146. * @param width defines the width of the texture
  29147. * @param height defines the height of the texture
  29148. * @param generateMipMaps defines if the engine should generate the mip levels
  29149. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29150. * @returns the dynamic texture inside an InternalTexture
  29151. */
  29152. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29153. /**
  29154. * Update the sampling mode of a given texture
  29155. * @param samplingMode defines the required sampling mode
  29156. * @param texture defines the texture to update
  29157. */
  29158. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29159. /**
  29160. * Update the content of a dynamic texture
  29161. * @param texture defines the texture to update
  29162. * @param canvas defines the canvas containing the source
  29163. * @param invertY defines if data must be stored with Y axis inverted
  29164. * @param premulAlpha defines if alpha is stored as premultiplied
  29165. * @param format defines the format of the data
  29166. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29167. */
  29168. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29169. /**
  29170. * Update a video texture
  29171. * @param texture defines the texture to update
  29172. * @param video defines the video element to use
  29173. * @param invertY defines if data must be stored with Y axis inverted
  29174. */
  29175. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29176. /**
  29177. * Updates a depth texture Comparison Mode and Function.
  29178. * If the comparison Function is equal to 0, the mode will be set to none.
  29179. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29180. * @param texture The texture to set the comparison function for
  29181. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29182. */
  29183. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29184. private _setupDepthStencilTexture;
  29185. /**
  29186. * Creates a depth stencil texture.
  29187. * This is only available in WebGL 2 or with the depth texture extension available.
  29188. * @param size The size of face edge in the texture.
  29189. * @param options The options defining the texture.
  29190. * @returns The texture
  29191. */
  29192. createDepthStencilTexture(size: number | {
  29193. width: number;
  29194. height: number;
  29195. }, options: DepthTextureCreationOptions): InternalTexture;
  29196. /**
  29197. * Creates a depth stencil texture.
  29198. * This is only available in WebGL 2 or with the depth texture extension available.
  29199. * @param size The size of face edge in the texture.
  29200. * @param options The options defining the texture.
  29201. * @returns The texture
  29202. */
  29203. private _createDepthStencilTexture;
  29204. /**
  29205. * Creates a depth stencil cube texture.
  29206. * This is only available in WebGL 2.
  29207. * @param size The size of face edge in the cube texture.
  29208. * @param options The options defining the cube texture.
  29209. * @returns The cube texture
  29210. */
  29211. private _createDepthStencilCubeTexture;
  29212. /**
  29213. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29214. * @param renderTarget The render target to set the frame buffer for
  29215. */
  29216. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29217. /**
  29218. * Creates a new render target texture
  29219. * @param size defines the size of the texture
  29220. * @param options defines the options used to create the texture
  29221. * @returns a new render target texture stored in an InternalTexture
  29222. */
  29223. createRenderTargetTexture(size: number | {
  29224. width: number;
  29225. height: number;
  29226. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29227. /**
  29228. * Create a multi render target texture
  29229. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  29230. * @param size defines the size of the texture
  29231. * @param options defines the creation options
  29232. * @returns the cube texture as an InternalTexture
  29233. */
  29234. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  29235. private _setupFramebufferDepthAttachments;
  29236. /**
  29237. * Updates the sample count of a render target texture
  29238. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29239. * @param texture defines the texture to update
  29240. * @param samples defines the sample count to set
  29241. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29242. */
  29243. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29244. /**
  29245. * Update the sample count for a given multiple render target texture
  29246. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29247. * @param textures defines the textures to update
  29248. * @param samples defines the sample count to set
  29249. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29250. */
  29251. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  29252. /** @hidden */
  29253. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29254. /** @hidden */
  29255. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29256. /** @hidden */
  29257. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29258. /** @hidden */
  29259. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29260. /**
  29261. * Creates a new render target cube texture
  29262. * @param size defines the size of the texture
  29263. * @param options defines the options used to create the texture
  29264. * @returns a new render target cube texture stored in an InternalTexture
  29265. */
  29266. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  29267. /**
  29268. * Creates a cube texture
  29269. * @param rootUrl defines the url where the files to load is located
  29270. * @param scene defines the current scene
  29271. * @param files defines the list of files to load (1 per face)
  29272. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  29273. * @param onLoad defines an optional callback raised when the texture is loaded
  29274. * @param onError defines an optional callback raised if there is an issue to load the texture
  29275. * @param format defines the format of the data
  29276. * @param forcedExtension defines the extension to use to pick the right loader
  29277. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  29278. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  29279. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  29280. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  29281. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  29282. * @returns the cube texture as an InternalTexture
  29283. */
  29284. 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;
  29285. /**
  29286. * @hidden
  29287. */
  29288. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29289. /**
  29290. * Update a raw cube texture
  29291. * @param texture defines the texture to udpdate
  29292. * @param data defines the data to store
  29293. * @param format defines the data format
  29294. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29295. * @param invertY defines if data must be stored with Y axis inverted
  29296. * @param compression defines the compression used (null by default)
  29297. * @param level defines which level of the texture to update
  29298. */
  29299. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  29300. /**
  29301. * Creates a new raw cube texture
  29302. * @param data defines the array of data to use to create each face
  29303. * @param size defines the size of the textures
  29304. * @param format defines the format of the data
  29305. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29306. * @param generateMipMaps defines if the engine should generate the mip levels
  29307. * @param invertY defines if data must be stored with Y axis inverted
  29308. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29309. * @param compression defines the compression used (null by default)
  29310. * @returns the cube texture as an InternalTexture
  29311. */
  29312. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29313. /**
  29314. * Creates a new raw cube texture from a specified url
  29315. * @param url defines the url where the data is located
  29316. * @param scene defines the current scene
  29317. * @param size defines the size of the textures
  29318. * @param format defines the format of the data
  29319. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29320. * @param noMipmap defines if the engine should avoid generating the mip levels
  29321. * @param callback defines a callback used to extract texture data from loaded data
  29322. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  29323. * @param onLoad defines a callback called when texture is loaded
  29324. * @param onError defines a callback called if there is an error
  29325. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29326. * @param invertY defines if data must be stored with Y axis inverted
  29327. * @returns the cube texture as an InternalTexture
  29328. */
  29329. 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;
  29330. /**
  29331. * Update a raw 3D texture
  29332. * @param texture defines the texture to update
  29333. * @param data defines the data to store
  29334. * @param format defines the data format
  29335. * @param invertY defines if data must be stored with Y axis inverted
  29336. * @param compression defines the used compression (can be null)
  29337. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  29338. */
  29339. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  29340. /**
  29341. * Creates a new raw 3D texture
  29342. * @param data defines the data used to create the texture
  29343. * @param width defines the width of the texture
  29344. * @param height defines the height of the texture
  29345. * @param depth defines the depth of the texture
  29346. * @param format defines the format of the texture
  29347. * @param generateMipMaps defines if the engine must generate mip levels
  29348. * @param invertY defines if data must be stored with Y axis inverted
  29349. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29350. * @param compression defines the compressed used (can be null)
  29351. * @param textureType defines the compressed used (can be null)
  29352. * @returns a new raw 3D texture (stored in an InternalTexture)
  29353. */
  29354. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29355. private _prepareWebGLTextureContinuation;
  29356. private _prepareWebGLTexture;
  29357. private _convertRGBtoRGBATextureData;
  29358. /** @hidden */
  29359. _releaseFramebufferObjects(texture: InternalTexture): void;
  29360. /** @hidden */
  29361. _releaseTexture(texture: InternalTexture): void;
  29362. private setProgram;
  29363. private _boundUniforms;
  29364. /**
  29365. * Binds an effect to the webGL context
  29366. * @param effect defines the effect to bind
  29367. */
  29368. bindSamplers(effect: Effect): void;
  29369. private _activateCurrentTexture;
  29370. /** @hidden */
  29371. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29372. /** @hidden */
  29373. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29374. /**
  29375. * Sets a texture to the webGL context from a postprocess
  29376. * @param channel defines the channel to use
  29377. * @param postProcess defines the source postprocess
  29378. */
  29379. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29380. /**
  29381. * Binds the output of the passed in post process to the texture channel specified
  29382. * @param channel The channel the texture should be bound to
  29383. * @param postProcess The post process which's output should be bound
  29384. */
  29385. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29386. /**
  29387. * Unbind all textures from the webGL context
  29388. */
  29389. unbindAllTextures(): void;
  29390. /**
  29391. * Sets a texture to the according uniform.
  29392. * @param channel The texture channel
  29393. * @param uniform The uniform to set
  29394. * @param texture The texture to apply
  29395. */
  29396. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29397. /**
  29398. * Sets a depth stencil texture from a render target to the according uniform.
  29399. * @param channel The texture channel
  29400. * @param uniform The uniform to set
  29401. * @param texture The render target texture containing the depth stencil texture to apply
  29402. */
  29403. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29404. private _bindSamplerUniformToChannel;
  29405. private _getTextureWrapMode;
  29406. private _setTexture;
  29407. /**
  29408. * Sets an array of texture to the webGL context
  29409. * @param channel defines the channel where the texture array must be set
  29410. * @param uniform defines the associated uniform location
  29411. * @param textures defines the array of textures to bind
  29412. */
  29413. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29414. /** @hidden */
  29415. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29416. private _setTextureParameterFloat;
  29417. private _setTextureParameterInteger;
  29418. /**
  29419. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29420. * @param x defines the x coordinate of the rectangle where pixels must be read
  29421. * @param y defines the y coordinate of the rectangle where pixels must be read
  29422. * @param width defines the width of the rectangle where pixels must be read
  29423. * @param height defines the height of the rectangle where pixels must be read
  29424. * @returns a Uint8Array containing RGBA colors
  29425. */
  29426. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29427. /**
  29428. * Add an externaly attached data from its key.
  29429. * This method call will fail and return false, if such key already exists.
  29430. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29431. * @param key the unique key that identifies the data
  29432. * @param data the data object to associate to the key for this Engine instance
  29433. * @return true if no such key were already present and the data was added successfully, false otherwise
  29434. */
  29435. addExternalData<T>(key: string, data: T): boolean;
  29436. /**
  29437. * Get an externaly attached data from its key
  29438. * @param key the unique key that identifies the data
  29439. * @return the associated data, if present (can be null), or undefined if not present
  29440. */
  29441. getExternalData<T>(key: string): T;
  29442. /**
  29443. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29444. * @param key the unique key that identifies the data
  29445. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29446. * @return the associated data, can be null if the factory returned null.
  29447. */
  29448. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29449. /**
  29450. * Remove an externaly attached data from the Engine instance
  29451. * @param key the unique key that identifies the data
  29452. * @return true if the data was successfully removed, false if it doesn't exist
  29453. */
  29454. removeExternalData(key: string): boolean;
  29455. /**
  29456. * Unbind all vertex attributes from the webGL context
  29457. */
  29458. unbindAllAttributes(): void;
  29459. /**
  29460. * 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
  29461. */
  29462. releaseEffects(): void;
  29463. /**
  29464. * Dispose and release all associated resources
  29465. */
  29466. dispose(): void;
  29467. /**
  29468. * Display the loading screen
  29469. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29470. */
  29471. displayLoadingUI(): void;
  29472. /**
  29473. * Hide the loading screen
  29474. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29475. */
  29476. hideLoadingUI(): void;
  29477. /**
  29478. * Gets the current loading screen object
  29479. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29480. */
  29481. /**
  29482. * Sets the current loading screen object
  29483. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29484. */
  29485. loadingScreen: ILoadingScreen;
  29486. /**
  29487. * Sets the current loading screen text
  29488. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29489. */
  29490. loadingUIText: string;
  29491. /**
  29492. * Sets the current loading screen background color
  29493. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29494. */
  29495. loadingUIBackgroundColor: string;
  29496. /**
  29497. * Attach a new callback raised when context lost event is fired
  29498. * @param callback defines the callback to call
  29499. */
  29500. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29501. /**
  29502. * Attach a new callback raised when context restored event is fired
  29503. * @param callback defines the callback to call
  29504. */
  29505. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29506. /**
  29507. * Gets the source code of the vertex shader associated with a specific webGL program
  29508. * @param program defines the program to use
  29509. * @returns a string containing the source code of the vertex shader associated with the program
  29510. */
  29511. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29512. /**
  29513. * Gets the source code of the fragment shader associated with a specific webGL program
  29514. * @param program defines the program to use
  29515. * @returns a string containing the source code of the fragment shader associated with the program
  29516. */
  29517. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29518. /**
  29519. * Get the current error code of the webGL context
  29520. * @returns the error code
  29521. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29522. */
  29523. getError(): number;
  29524. /**
  29525. * Gets the current framerate
  29526. * @returns a number representing the framerate
  29527. */
  29528. getFps(): number;
  29529. /**
  29530. * Gets the time spent between current and previous frame
  29531. * @returns a number representing the delta time in ms
  29532. */
  29533. getDeltaTime(): number;
  29534. private _measureFps;
  29535. /** @hidden */
  29536. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29537. private _canRenderToFloatFramebuffer;
  29538. private _canRenderToHalfFloatFramebuffer;
  29539. private _canRenderToFramebuffer;
  29540. /** @hidden */
  29541. _getWebGLTextureType(type: number): number;
  29542. private _getInternalFormat;
  29543. /** @hidden */
  29544. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29545. /** @hidden */
  29546. _getRGBAMultiSampleBufferFormat(type: number): number;
  29547. /** @hidden */
  29548. _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;
  29549. /** @hidden */
  29550. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29551. private _partialLoadFile;
  29552. private _cascadeLoadFiles;
  29553. /**
  29554. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29555. * @returns true if the engine can be created
  29556. * @ignorenaming
  29557. */
  29558. static isSupported(): boolean;
  29559. }
  29560. }
  29561. declare module "babylonjs/Materials/effect" {
  29562. import { Observable } from "babylonjs/Misc/observable";
  29563. import { Nullable } from "babylonjs/types";
  29564. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29565. import { Engine } from "babylonjs/Engines/engine";
  29566. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29567. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29568. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29569. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29571. /**
  29572. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29573. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29574. */
  29575. export class EffectFallbacks {
  29576. private _defines;
  29577. private _currentRank;
  29578. private _maxRank;
  29579. private _mesh;
  29580. /**
  29581. * Removes the fallback from the bound mesh.
  29582. */
  29583. unBindMesh(): void;
  29584. /**
  29585. * Adds a fallback on the specified property.
  29586. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29587. * @param define The name of the define in the shader
  29588. */
  29589. addFallback(rank: number, define: string): void;
  29590. /**
  29591. * Sets the mesh to use CPU skinning when needing to fallback.
  29592. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29593. * @param mesh The mesh to use the fallbacks.
  29594. */
  29595. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29596. /**
  29597. * Checks to see if more fallbacks are still availible.
  29598. */
  29599. readonly isMoreFallbacks: boolean;
  29600. /**
  29601. * Removes the defines that shoould be removed when falling back.
  29602. * @param currentDefines defines the current define statements for the shader.
  29603. * @param effect defines the current effect we try to compile
  29604. * @returns The resulting defines with defines of the current rank removed.
  29605. */
  29606. reduce(currentDefines: string, effect: Effect): string;
  29607. }
  29608. /**
  29609. * Options to be used when creating an effect.
  29610. */
  29611. export class EffectCreationOptions {
  29612. /**
  29613. * Atrributes that will be used in the shader.
  29614. */
  29615. attributes: string[];
  29616. /**
  29617. * Uniform varible names that will be set in the shader.
  29618. */
  29619. uniformsNames: string[];
  29620. /**
  29621. * Uniform buffer varible names that will be set in the shader.
  29622. */
  29623. uniformBuffersNames: string[];
  29624. /**
  29625. * Sampler texture variable names that will be set in the shader.
  29626. */
  29627. samplers: string[];
  29628. /**
  29629. * Define statements that will be set in the shader.
  29630. */
  29631. defines: any;
  29632. /**
  29633. * Possible fallbacks for this effect to improve performance when needed.
  29634. */
  29635. fallbacks: Nullable<EffectFallbacks>;
  29636. /**
  29637. * Callback that will be called when the shader is compiled.
  29638. */
  29639. onCompiled: Nullable<(effect: Effect) => void>;
  29640. /**
  29641. * Callback that will be called if an error occurs during shader compilation.
  29642. */
  29643. onError: Nullable<(effect: Effect, errors: string) => void>;
  29644. /**
  29645. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29646. */
  29647. indexParameters: any;
  29648. /**
  29649. * Max number of lights that can be used in the shader.
  29650. */
  29651. maxSimultaneousLights: number;
  29652. /**
  29653. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29654. */
  29655. transformFeedbackVaryings: Nullable<string[]>;
  29656. }
  29657. /**
  29658. * Effect containing vertex and fragment shader that can be executed on an object.
  29659. */
  29660. export class Effect {
  29661. /**
  29662. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29663. */
  29664. static ShadersRepository: string;
  29665. /**
  29666. * Name of the effect.
  29667. */
  29668. name: any;
  29669. /**
  29670. * String container all the define statements that should be set on the shader.
  29671. */
  29672. defines: string;
  29673. /**
  29674. * Callback that will be called when the shader is compiled.
  29675. */
  29676. onCompiled: Nullable<(effect: Effect) => void>;
  29677. /**
  29678. * Callback that will be called if an error occurs during shader compilation.
  29679. */
  29680. onError: Nullable<(effect: Effect, errors: string) => void>;
  29681. /**
  29682. * Callback that will be called when effect is bound.
  29683. */
  29684. onBind: Nullable<(effect: Effect) => void>;
  29685. /**
  29686. * Unique ID of the effect.
  29687. */
  29688. uniqueId: number;
  29689. /**
  29690. * Observable that will be called when the shader is compiled.
  29691. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29692. */
  29693. onCompileObservable: Observable<Effect>;
  29694. /**
  29695. * Observable that will be called if an error occurs during shader compilation.
  29696. */
  29697. onErrorObservable: Observable<Effect>;
  29698. /** @hidden */
  29699. _onBindObservable: Nullable<Observable<Effect>>;
  29700. /**
  29701. * Observable that will be called when effect is bound.
  29702. */
  29703. readonly onBindObservable: Observable<Effect>;
  29704. /** @hidden */
  29705. _bonesComputationForcedToCPU: boolean;
  29706. private static _uniqueIdSeed;
  29707. private _engine;
  29708. private _uniformBuffersNames;
  29709. private _uniformsNames;
  29710. private _samplers;
  29711. private _isReady;
  29712. private _compilationError;
  29713. private _attributesNames;
  29714. private _attributes;
  29715. private _uniforms;
  29716. /**
  29717. * Key for the effect.
  29718. * @hidden
  29719. */
  29720. _key: string;
  29721. private _indexParameters;
  29722. private _fallbacks;
  29723. private _vertexSourceCode;
  29724. private _fragmentSourceCode;
  29725. private _vertexSourceCodeOverride;
  29726. private _fragmentSourceCodeOverride;
  29727. private _transformFeedbackVaryings;
  29728. /**
  29729. * Compiled shader to webGL program.
  29730. * @hidden
  29731. */
  29732. _program: WebGLProgram;
  29733. private _valueCache;
  29734. private static _baseCache;
  29735. /**
  29736. * Instantiates an effect.
  29737. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29738. * @param baseName Name of the effect.
  29739. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29740. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29741. * @param samplers List of sampler variables that will be passed to the shader.
  29742. * @param engine Engine to be used to render the effect
  29743. * @param defines Define statements to be added to the shader.
  29744. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29745. * @param onCompiled Callback that will be called when the shader is compiled.
  29746. * @param onError Callback that will be called if an error occurs during shader compilation.
  29747. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29748. */
  29749. 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);
  29750. /**
  29751. * Unique key for this effect
  29752. */
  29753. readonly key: string;
  29754. /**
  29755. * If the effect has been compiled and prepared.
  29756. * @returns if the effect is compiled and prepared.
  29757. */
  29758. isReady(): boolean;
  29759. /**
  29760. * The engine the effect was initialized with.
  29761. * @returns the engine.
  29762. */
  29763. getEngine(): Engine;
  29764. /**
  29765. * The compiled webGL program for the effect
  29766. * @returns the webGL program.
  29767. */
  29768. getProgram(): WebGLProgram;
  29769. /**
  29770. * The set of names of attribute variables for the shader.
  29771. * @returns An array of attribute names.
  29772. */
  29773. getAttributesNames(): string[];
  29774. /**
  29775. * Returns the attribute at the given index.
  29776. * @param index The index of the attribute.
  29777. * @returns The location of the attribute.
  29778. */
  29779. getAttributeLocation(index: number): number;
  29780. /**
  29781. * Returns the attribute based on the name of the variable.
  29782. * @param name of the attribute to look up.
  29783. * @returns the attribute location.
  29784. */
  29785. getAttributeLocationByName(name: string): number;
  29786. /**
  29787. * The number of attributes.
  29788. * @returns the numnber of attributes.
  29789. */
  29790. getAttributesCount(): number;
  29791. /**
  29792. * Gets the index of a uniform variable.
  29793. * @param uniformName of the uniform to look up.
  29794. * @returns the index.
  29795. */
  29796. getUniformIndex(uniformName: string): number;
  29797. /**
  29798. * Returns the attribute based on the name of the variable.
  29799. * @param uniformName of the uniform to look up.
  29800. * @returns the location of the uniform.
  29801. */
  29802. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29803. /**
  29804. * Returns an array of sampler variable names
  29805. * @returns The array of sampler variable neames.
  29806. */
  29807. getSamplers(): string[];
  29808. /**
  29809. * The error from the last compilation.
  29810. * @returns the error string.
  29811. */
  29812. getCompilationError(): string;
  29813. /**
  29814. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29815. * @param func The callback to be used.
  29816. */
  29817. executeWhenCompiled(func: (effect: Effect) => void): void;
  29818. private _checkIsReady;
  29819. /** @hidden */
  29820. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29821. /** @hidden */
  29822. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29823. /** @hidden */
  29824. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29825. private _processShaderConversion;
  29826. private _processIncludes;
  29827. private _processPrecision;
  29828. /**
  29829. * Recompiles the webGL program
  29830. * @param vertexSourceCode The source code for the vertex shader.
  29831. * @param fragmentSourceCode The source code for the fragment shader.
  29832. * @param onCompiled Callback called when completed.
  29833. * @param onError Callback called on error.
  29834. * @hidden
  29835. */
  29836. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29837. /**
  29838. * Gets the uniform locations of the the specified variable names
  29839. * @param names THe names of the variables to lookup.
  29840. * @returns Array of locations in the same order as variable names.
  29841. */
  29842. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29843. /**
  29844. * Prepares the effect
  29845. * @hidden
  29846. */
  29847. _prepareEffect(): void;
  29848. /**
  29849. * Checks if the effect is supported. (Must be called after compilation)
  29850. */
  29851. readonly isSupported: boolean;
  29852. /**
  29853. * Binds a texture to the engine to be used as output of the shader.
  29854. * @param channel Name of the output variable.
  29855. * @param texture Texture to bind.
  29856. * @hidden
  29857. */
  29858. _bindTexture(channel: string, texture: InternalTexture): void;
  29859. /**
  29860. * Sets a texture on the engine to be used in the shader.
  29861. * @param channel Name of the sampler variable.
  29862. * @param texture Texture to set.
  29863. */
  29864. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29865. /**
  29866. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29867. * @param channel Name of the sampler variable.
  29868. * @param texture Texture to set.
  29869. */
  29870. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29871. /**
  29872. * Sets an array of textures on the engine to be used in the shader.
  29873. * @param channel Name of the variable.
  29874. * @param textures Textures to set.
  29875. */
  29876. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29877. /**
  29878. * 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)
  29879. * @param channel Name of the sampler variable.
  29880. * @param postProcess Post process to get the input texture from.
  29881. */
  29882. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29883. /**
  29884. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29885. * 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)
  29886. * @param channel Name of the sampler variable.
  29887. * @param postProcess Post process to get the output texture from.
  29888. */
  29889. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29890. /** @hidden */
  29891. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29892. /** @hidden */
  29893. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29894. /** @hidden */
  29895. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29896. /** @hidden */
  29897. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29898. /**
  29899. * Binds a buffer to a uniform.
  29900. * @param buffer Buffer to bind.
  29901. * @param name Name of the uniform variable to bind to.
  29902. */
  29903. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29904. /**
  29905. * Binds block to a uniform.
  29906. * @param blockName Name of the block to bind.
  29907. * @param index Index to bind.
  29908. */
  29909. bindUniformBlock(blockName: string, index: number): void;
  29910. /**
  29911. * Sets an interger value on a uniform variable.
  29912. * @param uniformName Name of the variable.
  29913. * @param value Value to be set.
  29914. * @returns this effect.
  29915. */
  29916. setInt(uniformName: string, value: number): Effect;
  29917. /**
  29918. * Sets an int array on a uniform variable.
  29919. * @param uniformName Name of the variable.
  29920. * @param array array to be set.
  29921. * @returns this effect.
  29922. */
  29923. setIntArray(uniformName: string, array: Int32Array): Effect;
  29924. /**
  29925. * 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)
  29926. * @param uniformName Name of the variable.
  29927. * @param array array to be set.
  29928. * @returns this effect.
  29929. */
  29930. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29931. /**
  29932. * 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)
  29933. * @param uniformName Name of the variable.
  29934. * @param array array to be set.
  29935. * @returns this effect.
  29936. */
  29937. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29938. /**
  29939. * 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)
  29940. * @param uniformName Name of the variable.
  29941. * @param array array to be set.
  29942. * @returns this effect.
  29943. */
  29944. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29945. /**
  29946. * Sets an float array on a uniform variable.
  29947. * @param uniformName Name of the variable.
  29948. * @param array array to be set.
  29949. * @returns this effect.
  29950. */
  29951. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29952. /**
  29953. * 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)
  29954. * @param uniformName Name of the variable.
  29955. * @param array array to be set.
  29956. * @returns this effect.
  29957. */
  29958. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29959. /**
  29960. * 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)
  29961. * @param uniformName Name of the variable.
  29962. * @param array array to be set.
  29963. * @returns this effect.
  29964. */
  29965. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29966. /**
  29967. * 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)
  29968. * @param uniformName Name of the variable.
  29969. * @param array array to be set.
  29970. * @returns this effect.
  29971. */
  29972. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29973. /**
  29974. * Sets an array on a uniform variable.
  29975. * @param uniformName Name of the variable.
  29976. * @param array array to be set.
  29977. * @returns this effect.
  29978. */
  29979. setArray(uniformName: string, array: number[]): Effect;
  29980. /**
  29981. * 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)
  29982. * @param uniformName Name of the variable.
  29983. * @param array array to be set.
  29984. * @returns this effect.
  29985. */
  29986. setArray2(uniformName: string, array: number[]): Effect;
  29987. /**
  29988. * 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)
  29989. * @param uniformName Name of the variable.
  29990. * @param array array to be set.
  29991. * @returns this effect.
  29992. */
  29993. setArray3(uniformName: string, array: number[]): Effect;
  29994. /**
  29995. * 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)
  29996. * @param uniformName Name of the variable.
  29997. * @param array array to be set.
  29998. * @returns this effect.
  29999. */
  30000. setArray4(uniformName: string, array: number[]): Effect;
  30001. /**
  30002. * Sets matrices on a uniform variable.
  30003. * @param uniformName Name of the variable.
  30004. * @param matrices matrices to be set.
  30005. * @returns this effect.
  30006. */
  30007. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30008. /**
  30009. * Sets matrix on a uniform variable.
  30010. * @param uniformName Name of the variable.
  30011. * @param matrix matrix to be set.
  30012. * @returns this effect.
  30013. */
  30014. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30015. /**
  30016. * 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)
  30017. * @param uniformName Name of the variable.
  30018. * @param matrix matrix to be set.
  30019. * @returns this effect.
  30020. */
  30021. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30022. /**
  30023. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30024. * @param uniformName Name of the variable.
  30025. * @param matrix matrix to be set.
  30026. * @returns this effect.
  30027. */
  30028. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30029. /**
  30030. * Sets a float on a uniform variable.
  30031. * @param uniformName Name of the variable.
  30032. * @param value value to be set.
  30033. * @returns this effect.
  30034. */
  30035. setFloat(uniformName: string, value: number): Effect;
  30036. /**
  30037. * Sets a boolean on a uniform variable.
  30038. * @param uniformName Name of the variable.
  30039. * @param bool value to be set.
  30040. * @returns this effect.
  30041. */
  30042. setBool(uniformName: string, bool: boolean): Effect;
  30043. /**
  30044. * Sets a Vector2 on a uniform variable.
  30045. * @param uniformName Name of the variable.
  30046. * @param vector2 vector2 to be set.
  30047. * @returns this effect.
  30048. */
  30049. setVector2(uniformName: string, vector2: Vector2): Effect;
  30050. /**
  30051. * Sets a float2 on a uniform variable.
  30052. * @param uniformName Name of the variable.
  30053. * @param x First float in float2.
  30054. * @param y Second float in float2.
  30055. * @returns this effect.
  30056. */
  30057. setFloat2(uniformName: string, x: number, y: number): Effect;
  30058. /**
  30059. * Sets a Vector3 on a uniform variable.
  30060. * @param uniformName Name of the variable.
  30061. * @param vector3 Value to be set.
  30062. * @returns this effect.
  30063. */
  30064. setVector3(uniformName: string, vector3: Vector3): Effect;
  30065. /**
  30066. * Sets a float3 on a uniform variable.
  30067. * @param uniformName Name of the variable.
  30068. * @param x First float in float3.
  30069. * @param y Second float in float3.
  30070. * @param z Third float in float3.
  30071. * @returns this effect.
  30072. */
  30073. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30074. /**
  30075. * Sets a Vector4 on a uniform variable.
  30076. * @param uniformName Name of the variable.
  30077. * @param vector4 Value to be set.
  30078. * @returns this effect.
  30079. */
  30080. setVector4(uniformName: string, vector4: Vector4): Effect;
  30081. /**
  30082. * Sets a float4 on a uniform variable.
  30083. * @param uniformName Name of the variable.
  30084. * @param x First float in float4.
  30085. * @param y Second float in float4.
  30086. * @param z Third float in float4.
  30087. * @param w Fourth float in float4.
  30088. * @returns this effect.
  30089. */
  30090. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30091. /**
  30092. * Sets a Color3 on a uniform variable.
  30093. * @param uniformName Name of the variable.
  30094. * @param color3 Value to be set.
  30095. * @returns this effect.
  30096. */
  30097. setColor3(uniformName: string, color3: Color3): Effect;
  30098. /**
  30099. * Sets a Color4 on a uniform variable.
  30100. * @param uniformName Name of the variable.
  30101. * @param color3 Value to be set.
  30102. * @param alpha Alpha value to be set.
  30103. * @returns this effect.
  30104. */
  30105. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30106. /**
  30107. * Sets a Color4 on a uniform variable
  30108. * @param uniformName defines the name of the variable
  30109. * @param color4 defines the value to be set
  30110. * @returns this effect.
  30111. */
  30112. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30113. /**
  30114. * This function will add a new shader to the shader store
  30115. * @param name the name of the shader
  30116. * @param pixelShader optional pixel shader content
  30117. * @param vertexShader optional vertex shader content
  30118. */
  30119. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30120. /**
  30121. * Store of each shader (The can be looked up using effect.key)
  30122. */
  30123. static ShadersStore: {
  30124. [key: string]: string;
  30125. };
  30126. /**
  30127. * Store of each included file for a shader (The can be looked up using effect.key)
  30128. */
  30129. static IncludesShadersStore: {
  30130. [key: string]: string;
  30131. };
  30132. /**
  30133. * Resets the cache of effects.
  30134. */
  30135. static ResetCache(): void;
  30136. }
  30137. }
  30138. declare module "babylonjs/Materials/colorCurves" {
  30139. import { Effect } from "babylonjs/Materials/effect";
  30140. /**
  30141. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30142. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30143. * 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;
  30144. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30145. */
  30146. export class ColorCurves {
  30147. private _dirty;
  30148. private _tempColor;
  30149. private _globalCurve;
  30150. private _highlightsCurve;
  30151. private _midtonesCurve;
  30152. private _shadowsCurve;
  30153. private _positiveCurve;
  30154. private _negativeCurve;
  30155. private _globalHue;
  30156. private _globalDensity;
  30157. private _globalSaturation;
  30158. private _globalExposure;
  30159. /**
  30160. * Gets the global Hue value.
  30161. * 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).
  30162. */
  30163. /**
  30164. * Sets the global Hue value.
  30165. * 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).
  30166. */
  30167. globalHue: number;
  30168. /**
  30169. * Gets the global Density value.
  30170. * 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.
  30171. * Values less than zero provide a filter of opposite hue.
  30172. */
  30173. /**
  30174. * Sets the global Density value.
  30175. * 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.
  30176. * Values less than zero provide a filter of opposite hue.
  30177. */
  30178. globalDensity: number;
  30179. /**
  30180. * Gets the global Saturation value.
  30181. * 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.
  30182. */
  30183. /**
  30184. * Sets the global Saturation value.
  30185. * 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.
  30186. */
  30187. globalSaturation: number;
  30188. /**
  30189. * Gets the global Exposure value.
  30190. * 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.
  30191. */
  30192. /**
  30193. * Sets the global Exposure value.
  30194. * 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.
  30195. */
  30196. globalExposure: number;
  30197. private _highlightsHue;
  30198. private _highlightsDensity;
  30199. private _highlightsSaturation;
  30200. private _highlightsExposure;
  30201. /**
  30202. * Gets the highlights Hue value.
  30203. * 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).
  30204. */
  30205. /**
  30206. * Sets the highlights Hue value.
  30207. * 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).
  30208. */
  30209. highlightsHue: number;
  30210. /**
  30211. * Gets the highlights Density value.
  30212. * 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.
  30213. * Values less than zero provide a filter of opposite hue.
  30214. */
  30215. /**
  30216. * Sets the highlights Density value.
  30217. * 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.
  30218. * Values less than zero provide a filter of opposite hue.
  30219. */
  30220. highlightsDensity: number;
  30221. /**
  30222. * Gets the highlights Saturation value.
  30223. * 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.
  30224. */
  30225. /**
  30226. * Sets the highlights Saturation value.
  30227. * 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.
  30228. */
  30229. highlightsSaturation: number;
  30230. /**
  30231. * Gets the highlights Exposure value.
  30232. * 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.
  30233. */
  30234. /**
  30235. * Sets the highlights Exposure value.
  30236. * 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.
  30237. */
  30238. highlightsExposure: number;
  30239. private _midtonesHue;
  30240. private _midtonesDensity;
  30241. private _midtonesSaturation;
  30242. private _midtonesExposure;
  30243. /**
  30244. * Gets the midtones Hue value.
  30245. * 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).
  30246. */
  30247. /**
  30248. * Sets the midtones Hue value.
  30249. * 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).
  30250. */
  30251. midtonesHue: number;
  30252. /**
  30253. * Gets the midtones Density value.
  30254. * 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.
  30255. * Values less than zero provide a filter of opposite hue.
  30256. */
  30257. /**
  30258. * Sets the midtones Density value.
  30259. * 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.
  30260. * Values less than zero provide a filter of opposite hue.
  30261. */
  30262. midtonesDensity: number;
  30263. /**
  30264. * Gets the midtones Saturation value.
  30265. * 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.
  30266. */
  30267. /**
  30268. * Sets the midtones Saturation value.
  30269. * 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.
  30270. */
  30271. midtonesSaturation: number;
  30272. /**
  30273. * Gets the midtones Exposure value.
  30274. * 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.
  30275. */
  30276. /**
  30277. * Sets the midtones Exposure value.
  30278. * 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.
  30279. */
  30280. midtonesExposure: number;
  30281. private _shadowsHue;
  30282. private _shadowsDensity;
  30283. private _shadowsSaturation;
  30284. private _shadowsExposure;
  30285. /**
  30286. * Gets the shadows Hue value.
  30287. * 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).
  30288. */
  30289. /**
  30290. * Sets the shadows Hue value.
  30291. * 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).
  30292. */
  30293. shadowsHue: number;
  30294. /**
  30295. * Gets the shadows Density value.
  30296. * 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.
  30297. * Values less than zero provide a filter of opposite hue.
  30298. */
  30299. /**
  30300. * Sets the shadows Density value.
  30301. * 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.
  30302. * Values less than zero provide a filter of opposite hue.
  30303. */
  30304. shadowsDensity: number;
  30305. /**
  30306. * Gets the shadows Saturation value.
  30307. * 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.
  30308. */
  30309. /**
  30310. * Sets the shadows Saturation value.
  30311. * 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.
  30312. */
  30313. shadowsSaturation: number;
  30314. /**
  30315. * Gets the shadows Exposure value.
  30316. * 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.
  30317. */
  30318. /**
  30319. * Sets the shadows Exposure value.
  30320. * 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.
  30321. */
  30322. shadowsExposure: number;
  30323. /**
  30324. * Returns the class name
  30325. * @returns The class name
  30326. */
  30327. getClassName(): string;
  30328. /**
  30329. * Binds the color curves to the shader.
  30330. * @param colorCurves The color curve to bind
  30331. * @param effect The effect to bind to
  30332. * @param positiveUniform The positive uniform shader parameter
  30333. * @param neutralUniform The neutral uniform shader parameter
  30334. * @param negativeUniform The negative uniform shader parameter
  30335. */
  30336. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30337. /**
  30338. * Prepare the list of uniforms associated with the ColorCurves effects.
  30339. * @param uniformsList The list of uniforms used in the effect
  30340. */
  30341. static PrepareUniforms(uniformsList: string[]): void;
  30342. /**
  30343. * Returns color grading data based on a hue, density, saturation and exposure value.
  30344. * @param filterHue The hue of the color filter.
  30345. * @param filterDensity The density of the color filter.
  30346. * @param saturation The saturation.
  30347. * @param exposure The exposure.
  30348. * @param result The result data container.
  30349. */
  30350. private getColorGradingDataToRef;
  30351. /**
  30352. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30353. * @param value The input slider value in range [-100,100].
  30354. * @returns Adjusted value.
  30355. */
  30356. private static applyColorGradingSliderNonlinear;
  30357. /**
  30358. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30359. * @param hue The hue (H) input.
  30360. * @param saturation The saturation (S) input.
  30361. * @param brightness The brightness (B) input.
  30362. * @result An RGBA color represented as Vector4.
  30363. */
  30364. private static fromHSBToRef;
  30365. /**
  30366. * Returns a value clamped between min and max
  30367. * @param value The value to clamp
  30368. * @param min The minimum of value
  30369. * @param max The maximum of value
  30370. * @returns The clamped value.
  30371. */
  30372. private static clamp;
  30373. /**
  30374. * Clones the current color curve instance.
  30375. * @return The cloned curves
  30376. */
  30377. clone(): ColorCurves;
  30378. /**
  30379. * Serializes the current color curve instance to a json representation.
  30380. * @return a JSON representation
  30381. */
  30382. serialize(): any;
  30383. /**
  30384. * Parses the color curve from a json representation.
  30385. * @param source the JSON source to parse
  30386. * @return The parsed curves
  30387. */
  30388. static Parse(source: any): ColorCurves;
  30389. }
  30390. }
  30391. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30392. import { Observable } from "babylonjs/Misc/observable";
  30393. import { Nullable } from "babylonjs/types";
  30394. import { Color4 } from "babylonjs/Maths/math";
  30395. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30396. import { Effect } from "babylonjs/Materials/effect";
  30397. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30398. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30399. /**
  30400. * Interface to follow in your material defines to integrate easily the
  30401. * Image proccessing functions.
  30402. * @hidden
  30403. */
  30404. export interface IImageProcessingConfigurationDefines {
  30405. IMAGEPROCESSING: boolean;
  30406. VIGNETTE: boolean;
  30407. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30408. VIGNETTEBLENDMODEOPAQUE: boolean;
  30409. TONEMAPPING: boolean;
  30410. TONEMAPPING_ACES: boolean;
  30411. CONTRAST: boolean;
  30412. EXPOSURE: boolean;
  30413. COLORCURVES: boolean;
  30414. COLORGRADING: boolean;
  30415. COLORGRADING3D: boolean;
  30416. SAMPLER3DGREENDEPTH: boolean;
  30417. SAMPLER3DBGRMAP: boolean;
  30418. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30419. }
  30420. /**
  30421. * @hidden
  30422. */
  30423. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30424. IMAGEPROCESSING: boolean;
  30425. VIGNETTE: boolean;
  30426. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30427. VIGNETTEBLENDMODEOPAQUE: boolean;
  30428. TONEMAPPING: boolean;
  30429. TONEMAPPING_ACES: boolean;
  30430. CONTRAST: boolean;
  30431. COLORCURVES: boolean;
  30432. COLORGRADING: boolean;
  30433. COLORGRADING3D: boolean;
  30434. SAMPLER3DGREENDEPTH: boolean;
  30435. SAMPLER3DBGRMAP: boolean;
  30436. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30437. EXPOSURE: boolean;
  30438. constructor();
  30439. }
  30440. /**
  30441. * This groups together the common properties used for image processing either in direct forward pass
  30442. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30443. * or not.
  30444. */
  30445. export class ImageProcessingConfiguration {
  30446. /**
  30447. * Default tone mapping applied in BabylonJS.
  30448. */
  30449. static readonly TONEMAPPING_STANDARD: number;
  30450. /**
  30451. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30452. * to other engines rendering to increase portability.
  30453. */
  30454. static readonly TONEMAPPING_ACES: number;
  30455. /**
  30456. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30457. */
  30458. colorCurves: Nullable<ColorCurves>;
  30459. private _colorCurvesEnabled;
  30460. /**
  30461. * Gets wether the color curves effect is enabled.
  30462. */
  30463. /**
  30464. * Sets wether the color curves effect is enabled.
  30465. */
  30466. colorCurvesEnabled: boolean;
  30467. private _colorGradingTexture;
  30468. /**
  30469. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30470. */
  30471. /**
  30472. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30473. */
  30474. colorGradingTexture: Nullable<BaseTexture>;
  30475. private _colorGradingEnabled;
  30476. /**
  30477. * Gets wether the color grading effect is enabled.
  30478. */
  30479. /**
  30480. * Sets wether the color grading effect is enabled.
  30481. */
  30482. colorGradingEnabled: boolean;
  30483. private _colorGradingWithGreenDepth;
  30484. /**
  30485. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30486. */
  30487. /**
  30488. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30489. */
  30490. colorGradingWithGreenDepth: boolean;
  30491. private _colorGradingBGR;
  30492. /**
  30493. * Gets wether the color grading texture contains BGR values.
  30494. */
  30495. /**
  30496. * Sets wether the color grading texture contains BGR values.
  30497. */
  30498. colorGradingBGR: boolean;
  30499. /** @hidden */
  30500. _exposure: number;
  30501. /**
  30502. * Gets the Exposure used in the effect.
  30503. */
  30504. /**
  30505. * Sets the Exposure used in the effect.
  30506. */
  30507. exposure: number;
  30508. private _toneMappingEnabled;
  30509. /**
  30510. * Gets wether the tone mapping effect is enabled.
  30511. */
  30512. /**
  30513. * Sets wether the tone mapping effect is enabled.
  30514. */
  30515. toneMappingEnabled: boolean;
  30516. private _toneMappingType;
  30517. /**
  30518. * Gets the type of tone mapping effect.
  30519. */
  30520. /**
  30521. * Sets the type of tone mapping effect used in BabylonJS.
  30522. */
  30523. toneMappingType: number;
  30524. protected _contrast: number;
  30525. /**
  30526. * Gets the contrast used in the effect.
  30527. */
  30528. /**
  30529. * Sets the contrast used in the effect.
  30530. */
  30531. contrast: number;
  30532. /**
  30533. * Vignette stretch size.
  30534. */
  30535. vignetteStretch: number;
  30536. /**
  30537. * Vignette centre X Offset.
  30538. */
  30539. vignetteCentreX: number;
  30540. /**
  30541. * Vignette centre Y Offset.
  30542. */
  30543. vignetteCentreY: number;
  30544. /**
  30545. * Vignette weight or intensity of the vignette effect.
  30546. */
  30547. vignetteWeight: number;
  30548. /**
  30549. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30550. * if vignetteEnabled is set to true.
  30551. */
  30552. vignetteColor: Color4;
  30553. /**
  30554. * Camera field of view used by the Vignette effect.
  30555. */
  30556. vignetteCameraFov: number;
  30557. private _vignetteBlendMode;
  30558. /**
  30559. * Gets the vignette blend mode allowing different kind of effect.
  30560. */
  30561. /**
  30562. * Sets the vignette blend mode allowing different kind of effect.
  30563. */
  30564. vignetteBlendMode: number;
  30565. private _vignetteEnabled;
  30566. /**
  30567. * Gets wether the vignette effect is enabled.
  30568. */
  30569. /**
  30570. * Sets wether the vignette effect is enabled.
  30571. */
  30572. vignetteEnabled: boolean;
  30573. private _applyByPostProcess;
  30574. /**
  30575. * Gets wether the image processing is applied through a post process or not.
  30576. */
  30577. /**
  30578. * Sets wether the image processing is applied through a post process or not.
  30579. */
  30580. applyByPostProcess: boolean;
  30581. private _isEnabled;
  30582. /**
  30583. * Gets wether the image processing is enabled or not.
  30584. */
  30585. /**
  30586. * Sets wether the image processing is enabled or not.
  30587. */
  30588. isEnabled: boolean;
  30589. /**
  30590. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30591. */
  30592. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30593. /**
  30594. * Method called each time the image processing information changes requires to recompile the effect.
  30595. */
  30596. protected _updateParameters(): void;
  30597. /**
  30598. * Gets the current class name.
  30599. * @return "ImageProcessingConfiguration"
  30600. */
  30601. getClassName(): string;
  30602. /**
  30603. * Prepare the list of uniforms associated with the Image Processing effects.
  30604. * @param uniforms The list of uniforms used in the effect
  30605. * @param defines the list of defines currently in use
  30606. */
  30607. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30608. /**
  30609. * Prepare the list of samplers associated with the Image Processing effects.
  30610. * @param samplersList The list of uniforms used in the effect
  30611. * @param defines the list of defines currently in use
  30612. */
  30613. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30614. /**
  30615. * Prepare the list of defines associated to the shader.
  30616. * @param defines the list of defines to complete
  30617. * @param forPostProcess Define if we are currently in post process mode or not
  30618. */
  30619. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30620. /**
  30621. * Returns true if all the image processing information are ready.
  30622. * @returns True if ready, otherwise, false
  30623. */
  30624. isReady(): boolean;
  30625. /**
  30626. * Binds the image processing to the shader.
  30627. * @param effect The effect to bind to
  30628. * @param aspectRatio Define the current aspect ratio of the effect
  30629. */
  30630. bind(effect: Effect, aspectRatio?: number): void;
  30631. /**
  30632. * Clones the current image processing instance.
  30633. * @return The cloned image processing
  30634. */
  30635. clone(): ImageProcessingConfiguration;
  30636. /**
  30637. * Serializes the current image processing instance to a json representation.
  30638. * @return a JSON representation
  30639. */
  30640. serialize(): any;
  30641. /**
  30642. * Parses the image processing from a json representation.
  30643. * @param source the JSON source to parse
  30644. * @return The parsed image processing
  30645. */
  30646. static Parse(source: any): ImageProcessingConfiguration;
  30647. private static _VIGNETTEMODE_MULTIPLY;
  30648. private static _VIGNETTEMODE_OPAQUE;
  30649. /**
  30650. * Used to apply the vignette as a mix with the pixel color.
  30651. */
  30652. static readonly VIGNETTEMODE_MULTIPLY: number;
  30653. /**
  30654. * Used to apply the vignette as a replacement of the pixel color.
  30655. */
  30656. static readonly VIGNETTEMODE_OPAQUE: number;
  30657. }
  30658. }
  30659. declare module "babylonjs/Materials/fresnelParameters" {
  30660. import { Color3 } from "babylonjs/Maths/math";
  30661. /**
  30662. * This represents all the required information to add a fresnel effect on a material:
  30663. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30664. */
  30665. export class FresnelParameters {
  30666. private _isEnabled;
  30667. /**
  30668. * Define if the fresnel effect is enable or not.
  30669. */
  30670. isEnabled: boolean;
  30671. /**
  30672. * Define the color used on edges (grazing angle)
  30673. */
  30674. leftColor: Color3;
  30675. /**
  30676. * Define the color used on center
  30677. */
  30678. rightColor: Color3;
  30679. /**
  30680. * Define bias applied to computed fresnel term
  30681. */
  30682. bias: number;
  30683. /**
  30684. * Defined the power exponent applied to fresnel term
  30685. */
  30686. power: number;
  30687. /**
  30688. * Clones the current fresnel and its valuues
  30689. * @returns a clone fresnel configuration
  30690. */
  30691. clone(): FresnelParameters;
  30692. /**
  30693. * Serializes the current fresnel parameters to a JSON representation.
  30694. * @return the JSON serialization
  30695. */
  30696. serialize(): any;
  30697. /**
  30698. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30699. * @param parsedFresnelParameters Define the JSON representation
  30700. * @returns the parsed parameters
  30701. */
  30702. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30703. }
  30704. }
  30705. declare module "babylonjs/Misc/decorators" {
  30706. import { Nullable } from "babylonjs/types";
  30707. import { Scene } from "babylonjs/scene";
  30708. import { IAnimatable } from "babylonjs/Misc/tools";
  30709. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30710. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30711. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30712. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30713. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30714. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30715. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30716. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30717. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30718. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30719. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30720. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30721. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30722. /**
  30723. * Decorator used to define property that can be serialized as reference to a camera
  30724. * @param sourceName defines the name of the property to decorate
  30725. */
  30726. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30727. /**
  30728. * Class used to help serialization objects
  30729. */
  30730. export class SerializationHelper {
  30731. /** hidden */
  30732. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30733. /** hidden */
  30734. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30735. /** hidden */
  30736. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30737. /** hidden */
  30738. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30739. /**
  30740. * Appends the serialized animations from the source animations
  30741. * @param source Source containing the animations
  30742. * @param destination Target to store the animations
  30743. */
  30744. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30745. /**
  30746. * Static function used to serialized a specific entity
  30747. * @param entity defines the entity to serialize
  30748. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30749. * @returns a JSON compatible object representing the serialization of the entity
  30750. */
  30751. static Serialize<T>(entity: T, serializationObject?: any): any;
  30752. /**
  30753. * Creates a new entity from a serialization data object
  30754. * @param creationFunction defines a function used to instanciated the new entity
  30755. * @param source defines the source serialization data
  30756. * @param scene defines the hosting scene
  30757. * @param rootUrl defines the root url for resources
  30758. * @returns a new entity
  30759. */
  30760. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30761. /**
  30762. * Clones an object
  30763. * @param creationFunction defines the function used to instanciate the new object
  30764. * @param source defines the source object
  30765. * @returns the cloned object
  30766. */
  30767. static Clone<T>(creationFunction: () => T, source: T): T;
  30768. /**
  30769. * Instanciates a new object based on a source one (some data will be shared between both object)
  30770. * @param creationFunction defines the function used to instanciate the new object
  30771. * @param source defines the source object
  30772. * @returns the new object
  30773. */
  30774. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30775. }
  30776. }
  30777. declare module "babylonjs/Cameras/camera" {
  30778. import { SmartArray } from "babylonjs/Misc/smartArray";
  30779. import { Observable } from "babylonjs/Misc/observable";
  30780. import { Nullable } from "babylonjs/types";
  30781. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30782. import { Scene } from "babylonjs/scene";
  30783. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30784. import { Node } from "babylonjs/node";
  30785. import { Mesh } from "babylonjs/Meshes/mesh";
  30786. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30787. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30788. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30789. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30790. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30791. import { Ray } from "babylonjs/Culling/ray";
  30792. /**
  30793. * This is the base class of all the camera used in the application.
  30794. * @see http://doc.babylonjs.com/features/cameras
  30795. */
  30796. export class Camera extends Node {
  30797. /** @hidden */
  30798. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30799. /**
  30800. * This is the default projection mode used by the cameras.
  30801. * It helps recreating a feeling of perspective and better appreciate depth.
  30802. * This is the best way to simulate real life cameras.
  30803. */
  30804. static readonly PERSPECTIVE_CAMERA: number;
  30805. /**
  30806. * This helps creating camera with an orthographic mode.
  30807. * 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.
  30808. */
  30809. static readonly ORTHOGRAPHIC_CAMERA: number;
  30810. /**
  30811. * This is the default FOV mode for perspective cameras.
  30812. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30813. */
  30814. static readonly FOVMODE_VERTICAL_FIXED: number;
  30815. /**
  30816. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30817. */
  30818. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30819. /**
  30820. * This specifies ther is no need for a camera rig.
  30821. * Basically only one eye is rendered corresponding to the camera.
  30822. */
  30823. static readonly RIG_MODE_NONE: number;
  30824. /**
  30825. * Simulates a camera Rig with one blue eye and one red eye.
  30826. * This can be use with 3d blue and red glasses.
  30827. */
  30828. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30829. /**
  30830. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30831. */
  30832. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30833. /**
  30834. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30835. */
  30836. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30837. /**
  30838. * Defines that both eyes of the camera will be rendered over under each other.
  30839. */
  30840. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30841. /**
  30842. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30843. */
  30844. static readonly RIG_MODE_VR: number;
  30845. /**
  30846. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30847. */
  30848. static readonly RIG_MODE_WEBVR: number;
  30849. /**
  30850. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30851. */
  30852. static readonly RIG_MODE_CUSTOM: number;
  30853. /**
  30854. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30855. */
  30856. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30857. /**
  30858. * Define the input manager associated with the camera.
  30859. */
  30860. inputs: CameraInputsManager<Camera>;
  30861. /** @hidden */
  30862. _position: Vector3;
  30863. /**
  30864. * Define the current local position of the camera in the scene
  30865. */
  30866. position: Vector3;
  30867. /**
  30868. * The vector the camera should consider as up.
  30869. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30870. */
  30871. upVector: Vector3;
  30872. /**
  30873. * Define the current limit on the left side for an orthographic camera
  30874. * In scene unit
  30875. */
  30876. orthoLeft: Nullable<number>;
  30877. /**
  30878. * Define the current limit on the right side for an orthographic camera
  30879. * In scene unit
  30880. */
  30881. orthoRight: Nullable<number>;
  30882. /**
  30883. * Define the current limit on the bottom side for an orthographic camera
  30884. * In scene unit
  30885. */
  30886. orthoBottom: Nullable<number>;
  30887. /**
  30888. * Define the current limit on the top side for an orthographic camera
  30889. * In scene unit
  30890. */
  30891. orthoTop: Nullable<number>;
  30892. /**
  30893. * Field Of View is set in Radians. (default is 0.8)
  30894. */
  30895. fov: number;
  30896. /**
  30897. * Define the minimum distance the camera can see from.
  30898. * This is important to note that the depth buffer are not infinite and the closer it starts
  30899. * the more your scene might encounter depth fighting issue.
  30900. */
  30901. minZ: number;
  30902. /**
  30903. * Define the maximum distance the camera can see to.
  30904. * This is important to note that the depth buffer are not infinite and the further it end
  30905. * the more your scene might encounter depth fighting issue.
  30906. */
  30907. maxZ: number;
  30908. /**
  30909. * Define the default inertia of the camera.
  30910. * This helps giving a smooth feeling to the camera movement.
  30911. */
  30912. inertia: number;
  30913. /**
  30914. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30915. */
  30916. mode: number;
  30917. /**
  30918. * Define wether the camera is intermediate.
  30919. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30920. */
  30921. isIntermediate: boolean;
  30922. /**
  30923. * Define the viewport of the camera.
  30924. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30925. */
  30926. viewport: Viewport;
  30927. /**
  30928. * Restricts the camera to viewing objects with the same layerMask.
  30929. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30930. */
  30931. layerMask: number;
  30932. /**
  30933. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30934. */
  30935. fovMode: number;
  30936. /**
  30937. * Rig mode of the camera.
  30938. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30939. * This is normally controlled byt the camera themselves as internal use.
  30940. */
  30941. cameraRigMode: number;
  30942. /**
  30943. * Defines the distance between both "eyes" in case of a RIG
  30944. */
  30945. interaxialDistance: number;
  30946. /**
  30947. * Defines if stereoscopic rendering is done side by side or over under.
  30948. */
  30949. isStereoscopicSideBySide: boolean;
  30950. /**
  30951. * 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
  30952. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30953. * else in the scene.
  30954. */
  30955. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30956. /**
  30957. * When set, the camera will render to this render target instead of the default canvas
  30958. */
  30959. outputRenderTarget: Nullable<RenderTargetTexture>;
  30960. /**
  30961. * Observable triggered when the camera view matrix has changed.
  30962. */
  30963. onViewMatrixChangedObservable: Observable<Camera>;
  30964. /**
  30965. * Observable triggered when the camera Projection matrix has changed.
  30966. */
  30967. onProjectionMatrixChangedObservable: Observable<Camera>;
  30968. /**
  30969. * Observable triggered when the inputs have been processed.
  30970. */
  30971. onAfterCheckInputsObservable: Observable<Camera>;
  30972. /**
  30973. * Observable triggered when reset has been called and applied to the camera.
  30974. */
  30975. onRestoreStateObservable: Observable<Camera>;
  30976. /** @hidden */
  30977. _cameraRigParams: any;
  30978. /** @hidden */
  30979. _rigCameras: Camera[];
  30980. /** @hidden */
  30981. _rigPostProcess: Nullable<PostProcess>;
  30982. protected _webvrViewMatrix: Matrix;
  30983. /** @hidden */
  30984. _skipRendering: boolean;
  30985. /** @hidden */
  30986. _projectionMatrix: Matrix;
  30987. /** @hidden */
  30988. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30989. /** @hidden */
  30990. _activeMeshes: SmartArray<AbstractMesh>;
  30991. protected _globalPosition: Vector3;
  30992. /** hidden */
  30993. _computedViewMatrix: Matrix;
  30994. private _doNotComputeProjectionMatrix;
  30995. private _transformMatrix;
  30996. private _frustumPlanes;
  30997. private _refreshFrustumPlanes;
  30998. private _storedFov;
  30999. private _stateStored;
  31000. /**
  31001. * Instantiates a new camera object.
  31002. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31003. * @see http://doc.babylonjs.com/features/cameras
  31004. * @param name Defines the name of the camera in the scene
  31005. * @param position Defines the position of the camera
  31006. * @param scene Defines the scene the camera belongs too
  31007. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31008. */
  31009. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31010. /**
  31011. * Store current camera state (fov, position, etc..)
  31012. * @returns the camera
  31013. */
  31014. storeState(): Camera;
  31015. /**
  31016. * Restores the camera state values if it has been stored. You must call storeState() first
  31017. */
  31018. protected _restoreStateValues(): boolean;
  31019. /**
  31020. * Restored camera state. You must call storeState() first.
  31021. * @returns true if restored and false otherwise
  31022. */
  31023. restoreState(): boolean;
  31024. /**
  31025. * Gets the class name of the camera.
  31026. * @returns the class name
  31027. */
  31028. getClassName(): string;
  31029. /** @hidden */
  31030. readonly _isCamera: boolean;
  31031. /**
  31032. * Gets a string representation of the camera useful for debug purpose.
  31033. * @param fullDetails Defines that a more verboe level of logging is required
  31034. * @returns the string representation
  31035. */
  31036. toString(fullDetails?: boolean): string;
  31037. /**
  31038. * Gets the current world space position of the camera.
  31039. */
  31040. readonly globalPosition: Vector3;
  31041. /**
  31042. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31043. * @returns the active meshe list
  31044. */
  31045. getActiveMeshes(): SmartArray<AbstractMesh>;
  31046. /**
  31047. * Check wether a mesh is part of the current active mesh list of the camera
  31048. * @param mesh Defines the mesh to check
  31049. * @returns true if active, false otherwise
  31050. */
  31051. isActiveMesh(mesh: Mesh): boolean;
  31052. /**
  31053. * Is this camera ready to be used/rendered
  31054. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31055. * @return true if the camera is ready
  31056. */
  31057. isReady(completeCheck?: boolean): boolean;
  31058. /** @hidden */
  31059. _initCache(): void;
  31060. /** @hidden */
  31061. _updateCache(ignoreParentClass?: boolean): void;
  31062. /** @hidden */
  31063. _isSynchronized(): boolean;
  31064. /** @hidden */
  31065. _isSynchronizedViewMatrix(): boolean;
  31066. /** @hidden */
  31067. _isSynchronizedProjectionMatrix(): boolean;
  31068. /**
  31069. * Attach the input controls to a specific dom element to get the input from.
  31070. * @param element Defines the element the controls should be listened from
  31071. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31072. */
  31073. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31074. /**
  31075. * Detach the current controls from the specified dom element.
  31076. * @param element Defines the element to stop listening the inputs from
  31077. */
  31078. detachControl(element: HTMLElement): void;
  31079. /**
  31080. * Update the camera state according to the different inputs gathered during the frame.
  31081. */
  31082. update(): void;
  31083. /** @hidden */
  31084. _checkInputs(): void;
  31085. /** @hidden */
  31086. readonly rigCameras: Camera[];
  31087. /**
  31088. * Gets the post process used by the rig cameras
  31089. */
  31090. readonly rigPostProcess: Nullable<PostProcess>;
  31091. /**
  31092. * Internal, gets the first post proces.
  31093. * @returns the first post process to be run on this camera.
  31094. */
  31095. _getFirstPostProcess(): Nullable<PostProcess>;
  31096. private _cascadePostProcessesToRigCams;
  31097. /**
  31098. * Attach a post process to the camera.
  31099. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31100. * @param postProcess The post process to attach to the camera
  31101. * @param insertAt The position of the post process in case several of them are in use in the scene
  31102. * @returns the position the post process has been inserted at
  31103. */
  31104. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31105. /**
  31106. * Detach a post process to the camera.
  31107. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31108. * @param postProcess The post process to detach from the camera
  31109. */
  31110. detachPostProcess(postProcess: PostProcess): void;
  31111. /**
  31112. * Gets the current world matrix of the camera
  31113. */
  31114. getWorldMatrix(): Matrix;
  31115. /** @hidden */
  31116. _getViewMatrix(): Matrix;
  31117. /**
  31118. * Gets the current view matrix of the camera.
  31119. * @param force forces the camera to recompute the matrix without looking at the cached state
  31120. * @returns the view matrix
  31121. */
  31122. getViewMatrix(force?: boolean): Matrix;
  31123. /**
  31124. * Freeze the projection matrix.
  31125. * It will prevent the cache check of the camera projection compute and can speed up perf
  31126. * if no parameter of the camera are meant to change
  31127. * @param projection Defines manually a projection if necessary
  31128. */
  31129. freezeProjectionMatrix(projection?: Matrix): void;
  31130. /**
  31131. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31132. */
  31133. unfreezeProjectionMatrix(): void;
  31134. /**
  31135. * Gets the current projection matrix of the camera.
  31136. * @param force forces the camera to recompute the matrix without looking at the cached state
  31137. * @returns the projection matrix
  31138. */
  31139. getProjectionMatrix(force?: boolean): Matrix;
  31140. /**
  31141. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31142. * @returns a Matrix
  31143. */
  31144. getTransformationMatrix(): Matrix;
  31145. private _updateFrustumPlanes;
  31146. /**
  31147. * Checks if a cullable object (mesh...) is in the camera frustum
  31148. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31149. * @param target The object to check
  31150. * @returns true if the object is in frustum otherwise false
  31151. */
  31152. isInFrustum(target: ICullable): boolean;
  31153. /**
  31154. * Checks if a cullable object (mesh...) is in the camera frustum
  31155. * Unlike isInFrustum this cheks the full bounding box
  31156. * @param target The object to check
  31157. * @returns true if the object is in frustum otherwise false
  31158. */
  31159. isCompletelyInFrustum(target: ICullable): boolean;
  31160. /**
  31161. * Gets a ray in the forward direction from the camera.
  31162. * @param length Defines the length of the ray to create
  31163. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31164. * @param origin Defines the start point of the ray which defaults to the camera position
  31165. * @returns the forward ray
  31166. */
  31167. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31168. /**
  31169. * Releases resources associated with this node.
  31170. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31171. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31172. */
  31173. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31174. /** @hidden */
  31175. _isLeftCamera: boolean;
  31176. /**
  31177. * Gets the left camera of a rig setup in case of Rigged Camera
  31178. */
  31179. readonly isLeftCamera: boolean;
  31180. /** @hidden */
  31181. _isRightCamera: boolean;
  31182. /**
  31183. * Gets the right camera of a rig setup in case of Rigged Camera
  31184. */
  31185. readonly isRightCamera: boolean;
  31186. /**
  31187. * Gets the left camera of a rig setup in case of Rigged Camera
  31188. */
  31189. readonly leftCamera: Nullable<FreeCamera>;
  31190. /**
  31191. * Gets the right camera of a rig setup in case of Rigged Camera
  31192. */
  31193. readonly rightCamera: Nullable<FreeCamera>;
  31194. /**
  31195. * Gets the left camera target of a rig setup in case of Rigged Camera
  31196. * @returns the target position
  31197. */
  31198. getLeftTarget(): Nullable<Vector3>;
  31199. /**
  31200. * Gets the right camera target of a rig setup in case of Rigged Camera
  31201. * @returns the target position
  31202. */
  31203. getRightTarget(): Nullable<Vector3>;
  31204. /**
  31205. * @hidden
  31206. */
  31207. setCameraRigMode(mode: number, rigParams: any): void;
  31208. /** @hidden */
  31209. static _setStereoscopicRigMode(camera: Camera): void;
  31210. /** @hidden */
  31211. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31212. /** @hidden */
  31213. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31214. /** @hidden */
  31215. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31216. /** @hidden */
  31217. _getVRProjectionMatrix(): Matrix;
  31218. protected _updateCameraRotationMatrix(): void;
  31219. protected _updateWebVRCameraRotationMatrix(): void;
  31220. /**
  31221. * This function MUST be overwritten by the different WebVR cameras available.
  31222. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31223. * @hidden
  31224. */
  31225. _getWebVRProjectionMatrix(): Matrix;
  31226. /**
  31227. * This function MUST be overwritten by the different WebVR cameras available.
  31228. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31229. * @hidden
  31230. */
  31231. _getWebVRViewMatrix(): Matrix;
  31232. /** @hidden */
  31233. setCameraRigParameter(name: string, value: any): void;
  31234. /**
  31235. * needs to be overridden by children so sub has required properties to be copied
  31236. * @hidden
  31237. */
  31238. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31239. /**
  31240. * May need to be overridden by children
  31241. * @hidden
  31242. */
  31243. _updateRigCameras(): void;
  31244. /** @hidden */
  31245. _setupInputs(): void;
  31246. /**
  31247. * Serialiaze the camera setup to a json represention
  31248. * @returns the JSON representation
  31249. */
  31250. serialize(): any;
  31251. /**
  31252. * Clones the current camera.
  31253. * @param name The cloned camera name
  31254. * @returns the cloned camera
  31255. */
  31256. clone(name: string): Camera;
  31257. /**
  31258. * Gets the direction of the camera relative to a given local axis.
  31259. * @param localAxis Defines the reference axis to provide a relative direction.
  31260. * @return the direction
  31261. */
  31262. getDirection(localAxis: Vector3): Vector3;
  31263. /**
  31264. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31265. * @param localAxis Defines the reference axis to provide a relative direction.
  31266. * @param result Defines the vector to store the result in
  31267. */
  31268. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31269. /**
  31270. * Gets a camera constructor for a given camera type
  31271. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31272. * @param name The name of the camera the result will be able to instantiate
  31273. * @param scene The scene the result will construct the camera in
  31274. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31275. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31276. * @returns a factory method to construc the camera
  31277. */
  31278. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31279. /**
  31280. * Compute the world matrix of the camera.
  31281. * @returns the camera workd matrix
  31282. */
  31283. computeWorldMatrix(): Matrix;
  31284. /**
  31285. * Parse a JSON and creates the camera from the parsed information
  31286. * @param parsedCamera The JSON to parse
  31287. * @param scene The scene to instantiate the camera in
  31288. * @returns the newly constructed camera
  31289. */
  31290. static Parse(parsedCamera: any, scene: Scene): Camera;
  31291. }
  31292. }
  31293. declare module "babylonjs/Misc/tools" {
  31294. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31295. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31296. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31297. import { Observable } from "babylonjs/Misc/observable";
  31298. import { DomManagement } from "babylonjs/Misc/domManagement";
  31299. import { WebRequest } from "babylonjs/Misc/webRequest";
  31300. import { Camera } from "babylonjs/Cameras/camera";
  31301. import { Engine } from "babylonjs/Engines/engine";
  31302. import { Animation } from "babylonjs/Animations/animation";
  31303. /**
  31304. * Interface for any object that can request an animation frame
  31305. */
  31306. export interface ICustomAnimationFrameRequester {
  31307. /**
  31308. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31309. */
  31310. renderFunction?: Function;
  31311. /**
  31312. * Called to request the next frame to render to
  31313. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31314. */
  31315. requestAnimationFrame: Function;
  31316. /**
  31317. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31318. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31319. */
  31320. requestID?: number;
  31321. }
  31322. /**
  31323. * Interface containing an array of animations
  31324. */
  31325. export interface IAnimatable {
  31326. /**
  31327. * Array of animations
  31328. */
  31329. animations: Array<Animation>;
  31330. }
  31331. /** Interface used by value gradients (color, factor, ...) */
  31332. export interface IValueGradient {
  31333. /**
  31334. * Gets or sets the gradient value (between 0 and 1)
  31335. */
  31336. gradient: number;
  31337. }
  31338. /** Class used to store color4 gradient */
  31339. export class ColorGradient implements IValueGradient {
  31340. /**
  31341. * Gets or sets the gradient value (between 0 and 1)
  31342. */
  31343. gradient: number;
  31344. /**
  31345. * Gets or sets first associated color
  31346. */
  31347. color1: Color4;
  31348. /**
  31349. * Gets or sets second associated color
  31350. */
  31351. color2?: Color4;
  31352. /**
  31353. * Will get a color picked randomly between color1 and color2.
  31354. * If color2 is undefined then color1 will be used
  31355. * @param result defines the target Color4 to store the result in
  31356. */
  31357. getColorToRef(result: Color4): void;
  31358. }
  31359. /** Class used to store color 3 gradient */
  31360. export class Color3Gradient implements IValueGradient {
  31361. /**
  31362. * Gets or sets the gradient value (between 0 and 1)
  31363. */
  31364. gradient: number;
  31365. /**
  31366. * Gets or sets the associated color
  31367. */
  31368. color: Color3;
  31369. }
  31370. /** Class used to store factor gradient */
  31371. export class FactorGradient implements IValueGradient {
  31372. /**
  31373. * Gets or sets the gradient value (between 0 and 1)
  31374. */
  31375. gradient: number;
  31376. /**
  31377. * Gets or sets first associated factor
  31378. */
  31379. factor1: number;
  31380. /**
  31381. * Gets or sets second associated factor
  31382. */
  31383. factor2?: number;
  31384. /**
  31385. * Will get a number picked randomly between factor1 and factor2.
  31386. * If factor2 is undefined then factor1 will be used
  31387. * @returns the picked number
  31388. */
  31389. getFactor(): number;
  31390. }
  31391. /**
  31392. * @ignore
  31393. * Application error to support additional information when loading a file
  31394. */
  31395. export class LoadFileError extends Error {
  31396. /** defines the optional web request */
  31397. request?: WebRequest | undefined;
  31398. private static _setPrototypeOf;
  31399. /**
  31400. * Creates a new LoadFileError
  31401. * @param message defines the message of the error
  31402. * @param request defines the optional web request
  31403. */
  31404. constructor(message: string,
  31405. /** defines the optional web request */
  31406. request?: WebRequest | undefined);
  31407. }
  31408. /**
  31409. * Class used to define a retry strategy when error happens while loading assets
  31410. */
  31411. export class RetryStrategy {
  31412. /**
  31413. * Function used to defines an exponential back off strategy
  31414. * @param maxRetries defines the maximum number of retries (3 by default)
  31415. * @param baseInterval defines the interval between retries
  31416. * @returns the strategy function to use
  31417. */
  31418. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31419. }
  31420. /**
  31421. * File request interface
  31422. */
  31423. export interface IFileRequest {
  31424. /**
  31425. * Raised when the request is complete (success or error).
  31426. */
  31427. onCompleteObservable: Observable<IFileRequest>;
  31428. /**
  31429. * Aborts the request for a file.
  31430. */
  31431. abort: () => void;
  31432. }
  31433. /**
  31434. * Class containing a set of static utilities functions
  31435. */
  31436. export class Tools {
  31437. /**
  31438. * Gets or sets the base URL to use to load assets
  31439. */
  31440. static BaseUrl: string;
  31441. /**
  31442. * Enable/Disable Custom HTTP Request Headers globally.
  31443. * default = false
  31444. * @see CustomRequestHeaders
  31445. */
  31446. static UseCustomRequestHeaders: boolean;
  31447. /**
  31448. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31449. * i.e. when loading files, where the server/service expects an Authorization header
  31450. */
  31451. static CustomRequestHeaders: {
  31452. [key: string]: string;
  31453. };
  31454. /**
  31455. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31456. */
  31457. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31458. /**
  31459. * Default behaviour for cors in the application.
  31460. * It can be a string if the expected behavior is identical in the entire app.
  31461. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31462. */
  31463. static CorsBehavior: string | ((url: string | string[]) => string);
  31464. /**
  31465. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31466. * @ignorenaming
  31467. */
  31468. static UseFallbackTexture: boolean;
  31469. /**
  31470. * Use this object to register external classes like custom textures or material
  31471. * to allow the laoders to instantiate them
  31472. */
  31473. static RegisteredExternalClasses: {
  31474. [key: string]: Object;
  31475. };
  31476. /**
  31477. * Texture content used if a texture cannot loaded
  31478. * @ignorenaming
  31479. */
  31480. static fallbackTexture: string;
  31481. /**
  31482. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31483. * @param u defines the coordinate on X axis
  31484. * @param v defines the coordinate on Y axis
  31485. * @param width defines the width of the source data
  31486. * @param height defines the height of the source data
  31487. * @param pixels defines the source byte array
  31488. * @param color defines the output color
  31489. */
  31490. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31491. /**
  31492. * Interpolates between a and b via alpha
  31493. * @param a The lower value (returned when alpha = 0)
  31494. * @param b The upper value (returned when alpha = 1)
  31495. * @param alpha The interpolation-factor
  31496. * @return The mixed value
  31497. */
  31498. static Mix(a: number, b: number, alpha: number): number;
  31499. /**
  31500. * Tries to instantiate a new object from a given class name
  31501. * @param className defines the class name to instantiate
  31502. * @returns the new object or null if the system was not able to do the instantiation
  31503. */
  31504. static Instantiate(className: string): any;
  31505. /**
  31506. * Provides a slice function that will work even on IE
  31507. * @param data defines the array to slice
  31508. * @param start defines the start of the data (optional)
  31509. * @param end defines the end of the data (optional)
  31510. * @returns the new sliced array
  31511. */
  31512. static Slice<T>(data: T, start?: number, end?: number): T;
  31513. /**
  31514. * Polyfill for setImmediate
  31515. * @param action defines the action to execute after the current execution block
  31516. */
  31517. static SetImmediate(action: () => void): void;
  31518. /**
  31519. * Function indicating if a number is an exponent of 2
  31520. * @param value defines the value to test
  31521. * @returns true if the value is an exponent of 2
  31522. */
  31523. static IsExponentOfTwo(value: number): boolean;
  31524. private static _tmpFloatArray;
  31525. /**
  31526. * Returns the nearest 32-bit single precision float representation of a Number
  31527. * @param value A Number. If the parameter is of a different type, it will get converted
  31528. * to a number or to NaN if it cannot be converted
  31529. * @returns number
  31530. */
  31531. static FloatRound(value: number): number;
  31532. /**
  31533. * Find the next highest power of two.
  31534. * @param x Number to start search from.
  31535. * @return Next highest power of two.
  31536. */
  31537. static CeilingPOT(x: number): number;
  31538. /**
  31539. * Find the next lowest power of two.
  31540. * @param x Number to start search from.
  31541. * @return Next lowest power of two.
  31542. */
  31543. static FloorPOT(x: number): number;
  31544. /**
  31545. * Find the nearest power of two.
  31546. * @param x Number to start search from.
  31547. * @return Next nearest power of two.
  31548. */
  31549. static NearestPOT(x: number): number;
  31550. /**
  31551. * Get the closest exponent of two
  31552. * @param value defines the value to approximate
  31553. * @param max defines the maximum value to return
  31554. * @param mode defines how to define the closest value
  31555. * @returns closest exponent of two of the given value
  31556. */
  31557. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31558. /**
  31559. * Extracts the filename from a path
  31560. * @param path defines the path to use
  31561. * @returns the filename
  31562. */
  31563. static GetFilename(path: string): string;
  31564. /**
  31565. * Extracts the "folder" part of a path (everything before the filename).
  31566. * @param uri The URI to extract the info from
  31567. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31568. * @returns The "folder" part of the path
  31569. */
  31570. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31571. /**
  31572. * Extracts text content from a DOM element hierarchy
  31573. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31574. */
  31575. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31576. /**
  31577. * Convert an angle in radians to degrees
  31578. * @param angle defines the angle to convert
  31579. * @returns the angle in degrees
  31580. */
  31581. static ToDegrees(angle: number): number;
  31582. /**
  31583. * Convert an angle in degrees to radians
  31584. * @param angle defines the angle to convert
  31585. * @returns the angle in radians
  31586. */
  31587. static ToRadians(angle: number): number;
  31588. /**
  31589. * Encode a buffer to a base64 string
  31590. * @param buffer defines the buffer to encode
  31591. * @returns the encoded string
  31592. */
  31593. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31594. /**
  31595. * Extracts minimum and maximum values from a list of indexed positions
  31596. * @param positions defines the positions to use
  31597. * @param indices defines the indices to the positions
  31598. * @param indexStart defines the start index
  31599. * @param indexCount defines the end index
  31600. * @param bias defines bias value to add to the result
  31601. * @return minimum and maximum values
  31602. */
  31603. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31604. minimum: Vector3;
  31605. maximum: Vector3;
  31606. };
  31607. /**
  31608. * Extracts minimum and maximum values from a list of positions
  31609. * @param positions defines the positions to use
  31610. * @param start defines the start index in the positions array
  31611. * @param count defines the number of positions to handle
  31612. * @param bias defines bias value to add to the result
  31613. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31614. * @return minimum and maximum values
  31615. */
  31616. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31617. minimum: Vector3;
  31618. maximum: Vector3;
  31619. };
  31620. /**
  31621. * Returns an array if obj is not an array
  31622. * @param obj defines the object to evaluate as an array
  31623. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31624. * @returns either obj directly if obj is an array or a new array containing obj
  31625. */
  31626. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31627. /**
  31628. * Gets the pointer prefix to use
  31629. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31630. */
  31631. static GetPointerPrefix(): string;
  31632. /**
  31633. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31634. * @param func - the function to be called
  31635. * @param requester - the object that will request the next frame. Falls back to window.
  31636. * @returns frame number
  31637. */
  31638. static QueueNewFrame(func: () => void, requester?: any): number;
  31639. /**
  31640. * Ask the browser to promote the current element to fullscreen rendering mode
  31641. * @param element defines the DOM element to promote
  31642. */
  31643. static RequestFullscreen(element: HTMLElement): void;
  31644. /**
  31645. * Asks the browser to exit fullscreen mode
  31646. */
  31647. static ExitFullscreen(): void;
  31648. /**
  31649. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31650. * @param url define the url we are trying
  31651. * @param element define the dom element where to configure the cors policy
  31652. */
  31653. static SetCorsBehavior(url: string | string[], element: {
  31654. crossOrigin: string | null;
  31655. }): void;
  31656. /**
  31657. * Removes unwanted characters from an url
  31658. * @param url defines the url to clean
  31659. * @returns the cleaned url
  31660. */
  31661. static CleanUrl(url: string): string;
  31662. /**
  31663. * Gets or sets a function used to pre-process url before using them to load assets
  31664. */
  31665. static PreprocessUrl: (url: string) => string;
  31666. /**
  31667. * Loads an image as an HTMLImageElement.
  31668. * @param input url string, ArrayBuffer, or Blob to load
  31669. * @param onLoad callback called when the image successfully loads
  31670. * @param onError callback called when the image fails to load
  31671. * @param offlineProvider offline provider for caching
  31672. * @returns the HTMLImageElement of the loaded image
  31673. */
  31674. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31675. /**
  31676. * Loads a file
  31677. * @param url url string, ArrayBuffer, or Blob to load
  31678. * @param onSuccess callback called when the file successfully loads
  31679. * @param onProgress callback called while file is loading (if the server supports this mode)
  31680. * @param offlineProvider defines the offline provider for caching
  31681. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31682. * @param onError callback called when the file fails to load
  31683. * @returns a file request object
  31684. */
  31685. 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;
  31686. /**
  31687. * Load a script (identified by an url). When the url returns, the
  31688. * content of this file is added into a new script element, attached to the DOM (body element)
  31689. * @param scriptUrl defines the url of the script to laod
  31690. * @param onSuccess defines the callback called when the script is loaded
  31691. * @param onError defines the callback to call if an error occurs
  31692. * @param scriptId defines the id of the script element
  31693. */
  31694. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31695. /**
  31696. * Load an asynchronous script (identified by an url). When the url returns, the
  31697. * content of this file is added into a new script element, attached to the DOM (body element)
  31698. * @param scriptUrl defines the url of the script to laod
  31699. * @param scriptId defines the id of the script element
  31700. * @returns a promise request object
  31701. */
  31702. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31703. /**
  31704. * Loads a file from a blob
  31705. * @param fileToLoad defines the blob to use
  31706. * @param callback defines the callback to call when data is loaded
  31707. * @param progressCallback defines the callback to call during loading process
  31708. * @returns a file request object
  31709. */
  31710. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31711. /**
  31712. * Loads a file
  31713. * @param fileToLoad defines the file to load
  31714. * @param callback defines the callback to call when data is loaded
  31715. * @param progressCallBack defines the callback to call during loading process
  31716. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31717. * @returns a file request object
  31718. */
  31719. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31720. /**
  31721. * Creates a data url from a given string content
  31722. * @param content defines the content to convert
  31723. * @returns the new data url link
  31724. */
  31725. static FileAsURL(content: string): string;
  31726. /**
  31727. * Format the given number to a specific decimal format
  31728. * @param value defines the number to format
  31729. * @param decimals defines the number of decimals to use
  31730. * @returns the formatted string
  31731. */
  31732. static Format(value: number, decimals?: number): string;
  31733. /**
  31734. * Checks if a given vector is inside a specific range
  31735. * @param v defines the vector to test
  31736. * @param min defines the minimum range
  31737. * @param max defines the maximum range
  31738. */
  31739. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31740. /**
  31741. * Tries to copy an object by duplicating every property
  31742. * @param source defines the source object
  31743. * @param destination defines the target object
  31744. * @param doNotCopyList defines a list of properties to avoid
  31745. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31746. */
  31747. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31748. /**
  31749. * Gets a boolean indicating if the given object has no own property
  31750. * @param obj defines the object to test
  31751. * @returns true if object has no own property
  31752. */
  31753. static IsEmpty(obj: any): boolean;
  31754. /**
  31755. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31756. * @param str Source string
  31757. * @param suffix Suffix to search for in the source string
  31758. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31759. */
  31760. static EndsWith(str: string, suffix: string): boolean;
  31761. /**
  31762. * Function used to register events at window level
  31763. * @param events defines the events to register
  31764. */
  31765. static RegisterTopRootEvents(events: {
  31766. name: string;
  31767. handler: Nullable<(e: FocusEvent) => any>;
  31768. }[]): void;
  31769. /**
  31770. * Function used to unregister events from window level
  31771. * @param events defines the events to unregister
  31772. */
  31773. static UnregisterTopRootEvents(events: {
  31774. name: string;
  31775. handler: Nullable<(e: FocusEvent) => any>;
  31776. }[]): void;
  31777. /**
  31778. * @ignore
  31779. */
  31780. static _ScreenshotCanvas: HTMLCanvasElement;
  31781. /**
  31782. * Dumps the current bound framebuffer
  31783. * @param width defines the rendering width
  31784. * @param height defines the rendering height
  31785. * @param engine defines the hosting engine
  31786. * @param successCallback defines the callback triggered once the data are available
  31787. * @param mimeType defines the mime type of the result
  31788. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31789. */
  31790. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31791. /**
  31792. * Converts the canvas data to blob.
  31793. * This acts as a polyfill for browsers not supporting the to blob function.
  31794. * @param canvas Defines the canvas to extract the data from
  31795. * @param successCallback Defines the callback triggered once the data are available
  31796. * @param mimeType Defines the mime type of the result
  31797. */
  31798. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31799. /**
  31800. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31801. * @param successCallback defines the callback triggered once the data are available
  31802. * @param mimeType defines the mime type of the result
  31803. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31804. */
  31805. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31806. /**
  31807. * Downloads a blob in the browser
  31808. * @param blob defines the blob to download
  31809. * @param fileName defines the name of the downloaded file
  31810. */
  31811. static Download(blob: Blob, fileName: string): void;
  31812. /**
  31813. * Captures a screenshot of the current rendering
  31814. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31815. * @param engine defines the rendering engine
  31816. * @param camera defines the source camera
  31817. * @param size This parameter can be set to a single number or to an object with the
  31818. * following (optional) properties: precision, width, height. If a single number is passed,
  31819. * it will be used for both width and height. If an object is passed, the screenshot size
  31820. * will be derived from the parameters. The precision property is a multiplier allowing
  31821. * rendering at a higher or lower resolution
  31822. * @param successCallback defines the callback receives a single parameter which contains the
  31823. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31824. * src parameter of an <img> to display it
  31825. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31826. * Check your browser for supported MIME types
  31827. */
  31828. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31829. /**
  31830. * Generates an image screenshot from the specified camera.
  31831. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31832. * @param engine The engine to use for rendering
  31833. * @param camera The camera to use for rendering
  31834. * @param size This parameter can be set to a single number or to an object with the
  31835. * following (optional) properties: precision, width, height. If a single number is passed,
  31836. * it will be used for both width and height. If an object is passed, the screenshot size
  31837. * will be derived from the parameters. The precision property is a multiplier allowing
  31838. * rendering at a higher or lower resolution
  31839. * @param successCallback The callback receives a single parameter which contains the
  31840. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31841. * src parameter of an <img> to display it
  31842. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31843. * Check your browser for supported MIME types
  31844. * @param samples Texture samples (default: 1)
  31845. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31846. * @param fileName A name for for the downloaded file.
  31847. */
  31848. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31849. /**
  31850. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31851. * Be aware Math.random() could cause collisions, but:
  31852. * "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"
  31853. * @returns a pseudo random id
  31854. */
  31855. static RandomId(): string;
  31856. /**
  31857. * Test if the given uri is a base64 string
  31858. * @param uri The uri to test
  31859. * @return True if the uri is a base64 string or false otherwise
  31860. */
  31861. static IsBase64(uri: string): boolean;
  31862. /**
  31863. * Decode the given base64 uri.
  31864. * @param uri The uri to decode
  31865. * @return The decoded base64 data.
  31866. */
  31867. static DecodeBase64(uri: string): ArrayBuffer;
  31868. /**
  31869. * Gets the absolute url.
  31870. * @param url the input url
  31871. * @return the absolute url
  31872. */
  31873. static GetAbsoluteUrl(url: string): string;
  31874. /**
  31875. * No log
  31876. */
  31877. static readonly NoneLogLevel: number;
  31878. /**
  31879. * Only message logs
  31880. */
  31881. static readonly MessageLogLevel: number;
  31882. /**
  31883. * Only warning logs
  31884. */
  31885. static readonly WarningLogLevel: number;
  31886. /**
  31887. * Only error logs
  31888. */
  31889. static readonly ErrorLogLevel: number;
  31890. /**
  31891. * All logs
  31892. */
  31893. static readonly AllLogLevel: number;
  31894. /**
  31895. * Gets a value indicating the number of loading errors
  31896. * @ignorenaming
  31897. */
  31898. static readonly errorsCount: number;
  31899. /**
  31900. * Callback called when a new log is added
  31901. */
  31902. static OnNewCacheEntry: (entry: string) => void;
  31903. /**
  31904. * Log a message to the console
  31905. * @param message defines the message to log
  31906. */
  31907. static Log(message: string): void;
  31908. /**
  31909. * Write a warning message to the console
  31910. * @param message defines the message to log
  31911. */
  31912. static Warn(message: string): void;
  31913. /**
  31914. * Write an error message to the console
  31915. * @param message defines the message to log
  31916. */
  31917. static Error(message: string): void;
  31918. /**
  31919. * Gets current log cache (list of logs)
  31920. */
  31921. static readonly LogCache: string;
  31922. /**
  31923. * Clears the log cache
  31924. */
  31925. static ClearLogCache(): void;
  31926. /**
  31927. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31928. */
  31929. static LogLevels: number;
  31930. /**
  31931. * Checks if the loaded document was accessed via `file:`-Protocol.
  31932. * @returns boolean
  31933. */
  31934. static IsFileURL(): boolean;
  31935. /**
  31936. * Checks if the window object exists
  31937. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31938. */
  31939. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31940. /**
  31941. * No performance log
  31942. */
  31943. static readonly PerformanceNoneLogLevel: number;
  31944. /**
  31945. * Use user marks to log performance
  31946. */
  31947. static readonly PerformanceUserMarkLogLevel: number;
  31948. /**
  31949. * Log performance to the console
  31950. */
  31951. static readonly PerformanceConsoleLogLevel: number;
  31952. private static _performance;
  31953. /**
  31954. * Sets the current performance log level
  31955. */
  31956. static PerformanceLogLevel: number;
  31957. private static _StartPerformanceCounterDisabled;
  31958. private static _EndPerformanceCounterDisabled;
  31959. private static _StartUserMark;
  31960. private static _EndUserMark;
  31961. private static _StartPerformanceConsole;
  31962. private static _EndPerformanceConsole;
  31963. /**
  31964. * Starts a performance counter
  31965. */
  31966. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31967. /**
  31968. * Ends a specific performance coutner
  31969. */
  31970. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31971. /**
  31972. * Gets either window.performance.now() if supported or Date.now() else
  31973. */
  31974. static readonly Now: number;
  31975. /**
  31976. * This method will return the name of the class used to create the instance of the given object.
  31977. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31978. * @param object the object to get the class name from
  31979. * @param isType defines if the object is actually a type
  31980. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31981. */
  31982. static GetClassName(object: any, isType?: boolean): string;
  31983. /**
  31984. * Gets the first element of an array satisfying a given predicate
  31985. * @param array defines the array to browse
  31986. * @param predicate defines the predicate to use
  31987. * @returns null if not found or the element
  31988. */
  31989. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31990. /**
  31991. * This method will return the name of the full name of the class, including its owning module (if any).
  31992. * 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).
  31993. * @param object the object to get the class name from
  31994. * @param isType defines if the object is actually a type
  31995. * @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.
  31996. * @ignorenaming
  31997. */
  31998. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31999. /**
  32000. * Returns a promise that resolves after the given amount of time.
  32001. * @param delay Number of milliseconds to delay
  32002. * @returns Promise that resolves after the given amount of time
  32003. */
  32004. static DelayAsync(delay: number): Promise<void>;
  32005. /**
  32006. * Gets the current gradient from an array of IValueGradient
  32007. * @param ratio defines the current ratio to get
  32008. * @param gradients defines the array of IValueGradient
  32009. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32010. */
  32011. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32012. }
  32013. /**
  32014. * This class is used to track a performance counter which is number based.
  32015. * The user has access to many properties which give statistics of different nature.
  32016. *
  32017. * The implementer can track two kinds of Performance Counter: time and count.
  32018. * 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.
  32019. * 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.
  32020. */
  32021. export class PerfCounter {
  32022. /**
  32023. * Gets or sets a global boolean to turn on and off all the counters
  32024. */
  32025. static Enabled: boolean;
  32026. /**
  32027. * Returns the smallest value ever
  32028. */
  32029. readonly min: number;
  32030. /**
  32031. * Returns the biggest value ever
  32032. */
  32033. readonly max: number;
  32034. /**
  32035. * Returns the average value since the performance counter is running
  32036. */
  32037. readonly average: number;
  32038. /**
  32039. * Returns the average value of the last second the counter was monitored
  32040. */
  32041. readonly lastSecAverage: number;
  32042. /**
  32043. * Returns the current value
  32044. */
  32045. readonly current: number;
  32046. /**
  32047. * Gets the accumulated total
  32048. */
  32049. readonly total: number;
  32050. /**
  32051. * Gets the total value count
  32052. */
  32053. readonly count: number;
  32054. /**
  32055. * Creates a new counter
  32056. */
  32057. constructor();
  32058. /**
  32059. * Call this method to start monitoring a new frame.
  32060. * 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.
  32061. */
  32062. fetchNewFrame(): void;
  32063. /**
  32064. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32065. * @param newCount the count value to add to the monitored count
  32066. * @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.
  32067. */
  32068. addCount(newCount: number, fetchResult: boolean): void;
  32069. /**
  32070. * Start monitoring this performance counter
  32071. */
  32072. beginMonitoring(): void;
  32073. /**
  32074. * Compute the time lapsed since the previous beginMonitoring() call.
  32075. * @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
  32076. */
  32077. endMonitoring(newFrame?: boolean): void;
  32078. private _fetchResult;
  32079. private _startMonitoringTime;
  32080. private _min;
  32081. private _max;
  32082. private _average;
  32083. private _current;
  32084. private _totalValueCount;
  32085. private _totalAccumulated;
  32086. private _lastSecAverage;
  32087. private _lastSecAccumulated;
  32088. private _lastSecTime;
  32089. private _lastSecValueCount;
  32090. }
  32091. /**
  32092. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32093. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32094. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32095. * @param name The name of the class, case should be preserved
  32096. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32097. */
  32098. export function className(name: string, module?: string): (target: Object) => void;
  32099. /**
  32100. * An implementation of a loop for asynchronous functions.
  32101. */
  32102. export class AsyncLoop {
  32103. /**
  32104. * Defines the number of iterations for the loop
  32105. */
  32106. iterations: number;
  32107. /**
  32108. * Defines the current index of the loop.
  32109. */
  32110. index: number;
  32111. private _done;
  32112. private _fn;
  32113. private _successCallback;
  32114. /**
  32115. * Constructor.
  32116. * @param iterations the number of iterations.
  32117. * @param func the function to run each iteration
  32118. * @param successCallback the callback that will be called upon succesful execution
  32119. * @param offset starting offset.
  32120. */
  32121. constructor(
  32122. /**
  32123. * Defines the number of iterations for the loop
  32124. */
  32125. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32126. /**
  32127. * Execute the next iteration. Must be called after the last iteration was finished.
  32128. */
  32129. executeNext(): void;
  32130. /**
  32131. * Break the loop and run the success callback.
  32132. */
  32133. breakLoop(): void;
  32134. /**
  32135. * Create and run an async loop.
  32136. * @param iterations the number of iterations.
  32137. * @param fn the function to run each iteration
  32138. * @param successCallback the callback that will be called upon succesful execution
  32139. * @param offset starting offset.
  32140. * @returns the created async loop object
  32141. */
  32142. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32143. /**
  32144. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32145. * @param iterations total number of iterations
  32146. * @param syncedIterations number of synchronous iterations in each async iteration.
  32147. * @param fn the function to call each iteration.
  32148. * @param callback a success call back that will be called when iterating stops.
  32149. * @param breakFunction a break condition (optional)
  32150. * @param timeout timeout settings for the setTimeout function. default - 0.
  32151. * @returns the created async loop object
  32152. */
  32153. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32154. }
  32155. }
  32156. declare module "babylonjs/Collisions/collisionCoordinator" {
  32157. import { Nullable } from "babylonjs/types";
  32158. import { Scene } from "babylonjs/scene";
  32159. import { Vector3 } from "babylonjs/Maths/math";
  32160. import { Collider } from "babylonjs/Collisions/collider";
  32161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32162. /** @hidden */
  32163. export interface ICollisionCoordinator {
  32164. createCollider(): Collider;
  32165. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32166. init(scene: Scene): void;
  32167. }
  32168. /** @hidden */
  32169. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32170. private _scene;
  32171. private _scaledPosition;
  32172. private _scaledVelocity;
  32173. private _finalPosition;
  32174. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32175. createCollider(): Collider;
  32176. init(scene: Scene): void;
  32177. private _collideWithWorld;
  32178. }
  32179. }
  32180. declare module "babylonjs/Animations/animationGroup" {
  32181. import { Animatable } from "babylonjs/Animations/animatable";
  32182. import { Animation } from "babylonjs/Animations/animation";
  32183. import { Scene, IDisposable } from "babylonjs/scene";
  32184. import { Observable } from "babylonjs/Misc/observable";
  32185. import { Nullable } from "babylonjs/types";
  32186. /**
  32187. * This class defines the direct association between an animation and a target
  32188. */
  32189. export class TargetedAnimation {
  32190. /**
  32191. * Animation to perform
  32192. */
  32193. animation: Animation;
  32194. /**
  32195. * Target to animate
  32196. */
  32197. target: any;
  32198. }
  32199. /**
  32200. * Use this class to create coordinated animations on multiple targets
  32201. */
  32202. export class AnimationGroup implements IDisposable {
  32203. /** The name of the animation group */
  32204. name: string;
  32205. private _scene;
  32206. private _targetedAnimations;
  32207. private _animatables;
  32208. private _from;
  32209. private _to;
  32210. private _isStarted;
  32211. private _isPaused;
  32212. private _speedRatio;
  32213. /**
  32214. * Gets or sets the unique id of the node
  32215. */
  32216. uniqueId: number;
  32217. /**
  32218. * This observable will notify when one animation have ended
  32219. */
  32220. onAnimationEndObservable: Observable<TargetedAnimation>;
  32221. /**
  32222. * Observer raised when one animation loops
  32223. */
  32224. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32225. /**
  32226. * This observable will notify when all animations have ended.
  32227. */
  32228. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32229. /**
  32230. * This observable will notify when all animations have paused.
  32231. */
  32232. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32233. /**
  32234. * This observable will notify when all animations are playing.
  32235. */
  32236. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32237. /**
  32238. * Gets the first frame
  32239. */
  32240. readonly from: number;
  32241. /**
  32242. * Gets the last frame
  32243. */
  32244. readonly to: number;
  32245. /**
  32246. * Define if the animations are started
  32247. */
  32248. readonly isStarted: boolean;
  32249. /**
  32250. * Gets a value indicating that the current group is playing
  32251. */
  32252. readonly isPlaying: boolean;
  32253. /**
  32254. * Gets or sets the speed ratio to use for all animations
  32255. */
  32256. /**
  32257. * Gets or sets the speed ratio to use for all animations
  32258. */
  32259. speedRatio: number;
  32260. /**
  32261. * Gets the targeted animations for this animation group
  32262. */
  32263. readonly targetedAnimations: Array<TargetedAnimation>;
  32264. /**
  32265. * returning the list of animatables controlled by this animation group.
  32266. */
  32267. readonly animatables: Array<Animatable>;
  32268. /**
  32269. * Instantiates a new Animation Group.
  32270. * This helps managing several animations at once.
  32271. * @see http://doc.babylonjs.com/how_to/group
  32272. * @param name Defines the name of the group
  32273. * @param scene Defines the scene the group belongs to
  32274. */
  32275. constructor(
  32276. /** The name of the animation group */
  32277. name: string, scene?: Nullable<Scene>);
  32278. /**
  32279. * Add an animation (with its target) in the group
  32280. * @param animation defines the animation we want to add
  32281. * @param target defines the target of the animation
  32282. * @returns the TargetedAnimation object
  32283. */
  32284. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32285. /**
  32286. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32287. * It can add constant keys at begin or end
  32288. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32289. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32290. * @returns the animation group
  32291. */
  32292. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32293. /**
  32294. * Start all animations on given targets
  32295. * @param loop defines if animations must loop
  32296. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32297. * @param from defines the from key (optional)
  32298. * @param to defines the to key (optional)
  32299. * @returns the current animation group
  32300. */
  32301. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32302. /**
  32303. * Pause all animations
  32304. * @returns the animation group
  32305. */
  32306. pause(): AnimationGroup;
  32307. /**
  32308. * Play all animations to initial state
  32309. * This function will start() the animations if they were not started or will restart() them if they were paused
  32310. * @param loop defines if animations must loop
  32311. * @returns the animation group
  32312. */
  32313. play(loop?: boolean): AnimationGroup;
  32314. /**
  32315. * Reset all animations to initial state
  32316. * @returns the animation group
  32317. */
  32318. reset(): AnimationGroup;
  32319. /**
  32320. * Restart animations from key 0
  32321. * @returns the animation group
  32322. */
  32323. restart(): AnimationGroup;
  32324. /**
  32325. * Stop all animations
  32326. * @returns the animation group
  32327. */
  32328. stop(): AnimationGroup;
  32329. /**
  32330. * Set animation weight for all animatables
  32331. * @param weight defines the weight to use
  32332. * @return the animationGroup
  32333. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32334. */
  32335. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32336. /**
  32337. * Synchronize and normalize all animatables with a source animatable
  32338. * @param root defines the root animatable to synchronize with
  32339. * @return the animationGroup
  32340. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32341. */
  32342. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32343. /**
  32344. * Goes to a specific frame in this animation group
  32345. * @param frame the frame number to go to
  32346. * @return the animationGroup
  32347. */
  32348. goToFrame(frame: number): AnimationGroup;
  32349. /**
  32350. * Dispose all associated resources
  32351. */
  32352. dispose(): void;
  32353. private _checkAnimationGroupEnded;
  32354. /**
  32355. * Clone the current animation group and returns a copy
  32356. * @param newName defines the name of the new group
  32357. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32358. * @returns the new aniamtion group
  32359. */
  32360. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32361. /**
  32362. * Returns a new AnimationGroup object parsed from the source provided.
  32363. * @param parsedAnimationGroup defines the source
  32364. * @param scene defines the scene that will receive the animationGroup
  32365. * @returns a new AnimationGroup
  32366. */
  32367. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32368. /**
  32369. * Returns the string "AnimationGroup"
  32370. * @returns "AnimationGroup"
  32371. */
  32372. getClassName(): string;
  32373. /**
  32374. * Creates a detailled string about the object
  32375. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32376. * @returns a string representing the object
  32377. */
  32378. toString(fullDetails?: boolean): string;
  32379. }
  32380. }
  32381. declare module "babylonjs/scene" {
  32382. import { Nullable } from "babylonjs/types";
  32383. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32384. import { Observable } from "babylonjs/Misc/observable";
  32385. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32386. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32387. import { Geometry } from "babylonjs/Meshes/geometry";
  32388. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32389. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32391. import { Mesh } from "babylonjs/Meshes/mesh";
  32392. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32393. import { Bone } from "babylonjs/Bones/bone";
  32394. import { Skeleton } from "babylonjs/Bones/skeleton";
  32395. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32396. import { Camera } from "babylonjs/Cameras/camera";
  32397. import { AbstractScene } from "babylonjs/abstractScene";
  32398. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32399. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32400. import { Material } from "babylonjs/Materials/material";
  32401. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32402. import { Effect } from "babylonjs/Materials/effect";
  32403. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32404. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32405. import { Light } from "babylonjs/Lights/light";
  32406. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32407. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32408. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32409. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32410. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32411. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32412. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32413. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32414. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  32415. import { Engine } from "babylonjs/Engines/engine";
  32416. import { Node } from "babylonjs/node";
  32417. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32418. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32419. import { WebRequest } from "babylonjs/Misc/webRequest";
  32420. import { Ray } from "babylonjs/Culling/ray";
  32421. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32422. import { Animation } from "babylonjs/Animations/animation";
  32423. import { Animatable } from "babylonjs/Animations/animatable";
  32424. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32425. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32426. import { Collider } from "babylonjs/Collisions/collider";
  32427. /**
  32428. * Define an interface for all classes that will hold resources
  32429. */
  32430. export interface IDisposable {
  32431. /**
  32432. * Releases all held resources
  32433. */
  32434. dispose(): void;
  32435. }
  32436. /** Interface defining initialization parameters for Scene class */
  32437. export interface SceneOptions {
  32438. /**
  32439. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32440. * It will improve performance when the number of geometries becomes important.
  32441. */
  32442. useGeometryUniqueIdsMap?: boolean;
  32443. /**
  32444. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32445. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32446. */
  32447. useMaterialMeshMap?: boolean;
  32448. /**
  32449. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32450. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32451. */
  32452. useClonedMeshhMap?: boolean;
  32453. }
  32454. /**
  32455. * Represents a scene to be rendered by the engine.
  32456. * @see http://doc.babylonjs.com/features/scene
  32457. */
  32458. export class Scene extends AbstractScene implements IAnimatable {
  32459. private static _uniqueIdCounter;
  32460. /** The fog is deactivated */
  32461. static readonly FOGMODE_NONE: number;
  32462. /** The fog density is following an exponential function */
  32463. static readonly FOGMODE_EXP: number;
  32464. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32465. static readonly FOGMODE_EXP2: number;
  32466. /** The fog density is following a linear function. */
  32467. static readonly FOGMODE_LINEAR: number;
  32468. /**
  32469. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32470. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32471. */
  32472. static MinDeltaTime: number;
  32473. /**
  32474. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32475. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32476. */
  32477. static MaxDeltaTime: number;
  32478. /**
  32479. * Factory used to create the default material.
  32480. * @param name The name of the material to create
  32481. * @param scene The scene to create the material for
  32482. * @returns The default material
  32483. */
  32484. static DefaultMaterialFactory(scene: Scene): Material;
  32485. /**
  32486. * Factory used to create the a collision coordinator.
  32487. * @returns The collision coordinator
  32488. */
  32489. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32490. /** @hidden */
  32491. readonly _isScene: boolean;
  32492. /**
  32493. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32494. */
  32495. autoClear: boolean;
  32496. /**
  32497. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32498. */
  32499. autoClearDepthAndStencil: boolean;
  32500. /**
  32501. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32502. */
  32503. clearColor: Color4;
  32504. /**
  32505. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32506. */
  32507. ambientColor: Color3;
  32508. /**
  32509. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32510. * It should only be one of the following (if not the default embedded one):
  32511. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32512. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32513. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32514. * The material properties need to be setup according to the type of texture in use.
  32515. */
  32516. environmentBRDFTexture: BaseTexture;
  32517. /** @hidden */
  32518. protected _environmentTexture: Nullable<BaseTexture>;
  32519. /**
  32520. * Texture used in all pbr material as the reflection texture.
  32521. * As in the majority of the scene they are the same (exception for multi room and so on),
  32522. * this is easier to reference from here than from all the materials.
  32523. */
  32524. /**
  32525. * Texture used in all pbr material as the reflection texture.
  32526. * As in the majority of the scene they are the same (exception for multi room and so on),
  32527. * this is easier to set here than in all the materials.
  32528. */
  32529. environmentTexture: Nullable<BaseTexture>;
  32530. /** @hidden */
  32531. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32532. /**
  32533. * Default image processing configuration used either in the rendering
  32534. * Forward main pass or through the imageProcessingPostProcess if present.
  32535. * As in the majority of the scene they are the same (exception for multi camera),
  32536. * this is easier to reference from here than from all the materials and post process.
  32537. *
  32538. * No setter as we it is a shared configuration, you can set the values instead.
  32539. */
  32540. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32541. private _forceWireframe;
  32542. /**
  32543. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32544. */
  32545. forceWireframe: boolean;
  32546. private _forcePointsCloud;
  32547. /**
  32548. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32549. */
  32550. forcePointsCloud: boolean;
  32551. /**
  32552. * Gets or sets the active clipplane 1
  32553. */
  32554. clipPlane: Nullable<Plane>;
  32555. /**
  32556. * Gets or sets the active clipplane 2
  32557. */
  32558. clipPlane2: Nullable<Plane>;
  32559. /**
  32560. * Gets or sets the active clipplane 3
  32561. */
  32562. clipPlane3: Nullable<Plane>;
  32563. /**
  32564. * Gets or sets the active clipplane 4
  32565. */
  32566. clipPlane4: Nullable<Plane>;
  32567. /**
  32568. * Gets or sets a boolean indicating if animations are enabled
  32569. */
  32570. animationsEnabled: boolean;
  32571. private _animationPropertiesOverride;
  32572. /**
  32573. * Gets or sets the animation properties override
  32574. */
  32575. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32576. /**
  32577. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32578. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32579. */
  32580. useConstantAnimationDeltaTime: boolean;
  32581. /**
  32582. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32583. * Please note that it requires to run a ray cast through the scene on every frame
  32584. */
  32585. constantlyUpdateMeshUnderPointer: boolean;
  32586. /**
  32587. * Defines the HTML cursor to use when hovering over interactive elements
  32588. */
  32589. hoverCursor: string;
  32590. /**
  32591. * Defines the HTML default cursor to use (empty by default)
  32592. */
  32593. defaultCursor: string;
  32594. /**
  32595. * This is used to call preventDefault() on pointer down
  32596. * in order to block unwanted artifacts like system double clicks
  32597. */
  32598. preventDefaultOnPointerDown: boolean;
  32599. /**
  32600. * This is used to call preventDefault() on pointer up
  32601. * in order to block unwanted artifacts like system double clicks
  32602. */
  32603. preventDefaultOnPointerUp: boolean;
  32604. /**
  32605. * Gets or sets user defined metadata
  32606. */
  32607. metadata: any;
  32608. /**
  32609. * For internal use only. Please do not use.
  32610. */
  32611. reservedDataStore: any;
  32612. /**
  32613. * Gets the name of the plugin used to load this scene (null by default)
  32614. */
  32615. loadingPluginName: string;
  32616. /**
  32617. * Use this array to add regular expressions used to disable offline support for specific urls
  32618. */
  32619. disableOfflineSupportExceptionRules: RegExp[];
  32620. /**
  32621. * An event triggered when the scene is disposed.
  32622. */
  32623. onDisposeObservable: Observable<Scene>;
  32624. private _onDisposeObserver;
  32625. /** Sets a function to be executed when this scene is disposed. */
  32626. onDispose: () => void;
  32627. /**
  32628. * An event triggered before rendering the scene (right after animations and physics)
  32629. */
  32630. onBeforeRenderObservable: Observable<Scene>;
  32631. private _onBeforeRenderObserver;
  32632. /** Sets a function to be executed before rendering this scene */
  32633. beforeRender: Nullable<() => void>;
  32634. /**
  32635. * An event triggered after rendering the scene
  32636. */
  32637. onAfterRenderObservable: Observable<Scene>;
  32638. private _onAfterRenderObserver;
  32639. /** Sets a function to be executed after rendering this scene */
  32640. afterRender: Nullable<() => void>;
  32641. /**
  32642. * An event triggered before animating the scene
  32643. */
  32644. onBeforeAnimationsObservable: Observable<Scene>;
  32645. /**
  32646. * An event triggered after animations processing
  32647. */
  32648. onAfterAnimationsObservable: Observable<Scene>;
  32649. /**
  32650. * An event triggered before draw calls are ready to be sent
  32651. */
  32652. onBeforeDrawPhaseObservable: Observable<Scene>;
  32653. /**
  32654. * An event triggered after draw calls have been sent
  32655. */
  32656. onAfterDrawPhaseObservable: Observable<Scene>;
  32657. /**
  32658. * An event triggered when the scene is ready
  32659. */
  32660. onReadyObservable: Observable<Scene>;
  32661. /**
  32662. * An event triggered before rendering a camera
  32663. */
  32664. onBeforeCameraRenderObservable: Observable<Camera>;
  32665. private _onBeforeCameraRenderObserver;
  32666. /** Sets a function to be executed before rendering a camera*/
  32667. beforeCameraRender: () => void;
  32668. /**
  32669. * An event triggered after rendering a camera
  32670. */
  32671. onAfterCameraRenderObservable: Observable<Camera>;
  32672. private _onAfterCameraRenderObserver;
  32673. /** Sets a function to be executed after rendering a camera*/
  32674. afterCameraRender: () => void;
  32675. /**
  32676. * An event triggered when active meshes evaluation is about to start
  32677. */
  32678. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32679. /**
  32680. * An event triggered when active meshes evaluation is done
  32681. */
  32682. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32683. /**
  32684. * An event triggered when particles rendering is about to start
  32685. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32686. */
  32687. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32688. /**
  32689. * An event triggered when particles rendering is done
  32690. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32691. */
  32692. onAfterParticlesRenderingObservable: Observable<Scene>;
  32693. /**
  32694. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32695. */
  32696. onDataLoadedObservable: Observable<Scene>;
  32697. /**
  32698. * An event triggered when a camera is created
  32699. */
  32700. onNewCameraAddedObservable: Observable<Camera>;
  32701. /**
  32702. * An event triggered when a camera is removed
  32703. */
  32704. onCameraRemovedObservable: Observable<Camera>;
  32705. /**
  32706. * An event triggered when a light is created
  32707. */
  32708. onNewLightAddedObservable: Observable<Light>;
  32709. /**
  32710. * An event triggered when a light is removed
  32711. */
  32712. onLightRemovedObservable: Observable<Light>;
  32713. /**
  32714. * An event triggered when a geometry is created
  32715. */
  32716. onNewGeometryAddedObservable: Observable<Geometry>;
  32717. /**
  32718. * An event triggered when a geometry is removed
  32719. */
  32720. onGeometryRemovedObservable: Observable<Geometry>;
  32721. /**
  32722. * An event triggered when a transform node is created
  32723. */
  32724. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32725. /**
  32726. * An event triggered when a transform node is removed
  32727. */
  32728. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32729. /**
  32730. * An event triggered when a mesh is created
  32731. */
  32732. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32733. /**
  32734. * An event triggered when a mesh is removed
  32735. */
  32736. onMeshRemovedObservable: Observable<AbstractMesh>;
  32737. /**
  32738. * An event triggered when a skeleton is created
  32739. */
  32740. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32741. /**
  32742. * An event triggered when a skeleton is removed
  32743. */
  32744. onSkeletonRemovedObservable: Observable<Skeleton>;
  32745. /**
  32746. * An event triggered when a material is created
  32747. */
  32748. onNewMaterialAddedObservable: Observable<Material>;
  32749. /**
  32750. * An event triggered when a material is removed
  32751. */
  32752. onMaterialRemovedObservable: Observable<Material>;
  32753. /**
  32754. * An event triggered when a texture is created
  32755. */
  32756. onNewTextureAddedObservable: Observable<BaseTexture>;
  32757. /**
  32758. * An event triggered when a texture is removed
  32759. */
  32760. onTextureRemovedObservable: Observable<BaseTexture>;
  32761. /**
  32762. * An event triggered when render targets are about to be rendered
  32763. * Can happen multiple times per frame.
  32764. */
  32765. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32766. /**
  32767. * An event triggered when render targets were rendered.
  32768. * Can happen multiple times per frame.
  32769. */
  32770. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32771. /**
  32772. * An event triggered before calculating deterministic simulation step
  32773. */
  32774. onBeforeStepObservable: Observable<Scene>;
  32775. /**
  32776. * An event triggered after calculating deterministic simulation step
  32777. */
  32778. onAfterStepObservable: Observable<Scene>;
  32779. /**
  32780. * An event triggered when the activeCamera property is updated
  32781. */
  32782. onActiveCameraChanged: Observable<Scene>;
  32783. /**
  32784. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32785. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32786. * 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)
  32787. */
  32788. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32789. /**
  32790. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32791. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32792. * 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)
  32793. */
  32794. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32795. /**
  32796. * This Observable will when a mesh has been imported into the scene.
  32797. */
  32798. onMeshImportedObservable: Observable<AbstractMesh>;
  32799. /**
  32800. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32801. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32802. */
  32803. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32804. /** @hidden */
  32805. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32806. /**
  32807. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32808. */
  32809. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32810. /**
  32811. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32812. */
  32813. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32814. /**
  32815. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32816. */
  32817. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32818. private _onPointerMove;
  32819. private _onPointerDown;
  32820. private _onPointerUp;
  32821. /** Callback called when a pointer move is detected */
  32822. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32823. /** Callback called when a pointer down is detected */
  32824. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32825. /** Callback called when a pointer up is detected */
  32826. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32827. /** Callback called when a pointer pick is detected */
  32828. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32829. /**
  32830. * 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).
  32831. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32832. */
  32833. onPrePointerObservable: Observable<PointerInfoPre>;
  32834. /**
  32835. * Observable event triggered each time an input event is received from the rendering canvas
  32836. */
  32837. onPointerObservable: Observable<PointerInfo>;
  32838. /**
  32839. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32840. */
  32841. readonly unTranslatedPointer: Vector2;
  32842. /** The distance in pixel that you have to move to prevent some events */
  32843. static DragMovementThreshold: number;
  32844. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32845. static LongPressDelay: number;
  32846. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32847. static DoubleClickDelay: number;
  32848. /** If you need to check double click without raising a single click at first click, enable this flag */
  32849. static ExclusiveDoubleClickMode: boolean;
  32850. private _initClickEvent;
  32851. private _initActionManager;
  32852. private _delayedSimpleClick;
  32853. private _delayedSimpleClickTimeout;
  32854. private _previousDelayedSimpleClickTimeout;
  32855. private _meshPickProceed;
  32856. private _previousButtonPressed;
  32857. private _currentPickResult;
  32858. private _previousPickResult;
  32859. private _totalPointersPressed;
  32860. private _doubleClickOccured;
  32861. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32862. cameraToUseForPointers: Nullable<Camera>;
  32863. private _pointerX;
  32864. private _pointerY;
  32865. private _unTranslatedPointerX;
  32866. private _unTranslatedPointerY;
  32867. private _startingPointerPosition;
  32868. private _previousStartingPointerPosition;
  32869. private _startingPointerTime;
  32870. private _previousStartingPointerTime;
  32871. private _pointerCaptures;
  32872. private _timeAccumulator;
  32873. private _currentStepId;
  32874. private _currentInternalStep;
  32875. /** @hidden */
  32876. _mirroredCameraPosition: Nullable<Vector3>;
  32877. /**
  32878. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32879. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32880. */
  32881. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32882. /**
  32883. * Observable event triggered each time an keyboard event is received from the hosting window
  32884. */
  32885. onKeyboardObservable: Observable<KeyboardInfo>;
  32886. private _onKeyDown;
  32887. private _onKeyUp;
  32888. private _onCanvasFocusObserver;
  32889. private _onCanvasBlurObserver;
  32890. private _useRightHandedSystem;
  32891. /**
  32892. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32893. */
  32894. useRightHandedSystem: boolean;
  32895. /**
  32896. * Sets the step Id used by deterministic lock step
  32897. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32898. * @param newStepId defines the step Id
  32899. */
  32900. setStepId(newStepId: number): void;
  32901. /**
  32902. * Gets the step Id used by deterministic lock step
  32903. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32904. * @returns the step Id
  32905. */
  32906. getStepId(): number;
  32907. /**
  32908. * Gets the internal step used by deterministic lock step
  32909. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32910. * @returns the internal step
  32911. */
  32912. getInternalStep(): number;
  32913. private _fogEnabled;
  32914. /**
  32915. * Gets or sets a boolean indicating if fog is enabled on this scene
  32916. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32917. * (Default is true)
  32918. */
  32919. fogEnabled: boolean;
  32920. private _fogMode;
  32921. /**
  32922. * Gets or sets the fog mode to use
  32923. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32924. * | mode | value |
  32925. * | --- | --- |
  32926. * | FOGMODE_NONE | 0 |
  32927. * | FOGMODE_EXP | 1 |
  32928. * | FOGMODE_EXP2 | 2 |
  32929. * | FOGMODE_LINEAR | 3 |
  32930. */
  32931. fogMode: number;
  32932. /**
  32933. * Gets or sets the fog color to use
  32934. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32935. * (Default is Color3(0.2, 0.2, 0.3))
  32936. */
  32937. fogColor: Color3;
  32938. /**
  32939. * Gets or sets the fog density to use
  32940. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32941. * (Default is 0.1)
  32942. */
  32943. fogDensity: number;
  32944. /**
  32945. * Gets or sets the fog start distance to use
  32946. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32947. * (Default is 0)
  32948. */
  32949. fogStart: number;
  32950. /**
  32951. * Gets or sets the fog end distance to use
  32952. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32953. * (Default is 1000)
  32954. */
  32955. fogEnd: number;
  32956. private _shadowsEnabled;
  32957. /**
  32958. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32959. */
  32960. shadowsEnabled: boolean;
  32961. private _lightsEnabled;
  32962. /**
  32963. * Gets or sets a boolean indicating if lights are enabled on this scene
  32964. */
  32965. lightsEnabled: boolean;
  32966. /** All of the active cameras added to this scene. */
  32967. activeCameras: Camera[];
  32968. /** @hidden */
  32969. _activeCamera: Nullable<Camera>;
  32970. /** Gets or sets the current active camera */
  32971. activeCamera: Nullable<Camera>;
  32972. private _defaultMaterial;
  32973. /** The default material used on meshes when no material is affected */
  32974. /** The default material used on meshes when no material is affected */
  32975. defaultMaterial: Material;
  32976. private _texturesEnabled;
  32977. /**
  32978. * Gets or sets a boolean indicating if textures are enabled on this scene
  32979. */
  32980. texturesEnabled: boolean;
  32981. /**
  32982. * Gets or sets a boolean indicating if particles are enabled on this scene
  32983. */
  32984. particlesEnabled: boolean;
  32985. /**
  32986. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32987. */
  32988. spritesEnabled: boolean;
  32989. private _skeletonsEnabled;
  32990. /**
  32991. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32992. */
  32993. skeletonsEnabled: boolean;
  32994. /**
  32995. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32996. */
  32997. lensFlaresEnabled: boolean;
  32998. /**
  32999. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33000. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33001. */
  33002. collisionsEnabled: boolean;
  33003. private _collisionCoordinator;
  33004. /** @hidden */
  33005. readonly collisionCoordinator: ICollisionCoordinator;
  33006. /**
  33007. * Defines the gravity applied to this scene (used only for collisions)
  33008. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33009. */
  33010. gravity: Vector3;
  33011. /**
  33012. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33013. */
  33014. postProcessesEnabled: boolean;
  33015. /**
  33016. * The list of postprocesses added to the scene
  33017. */
  33018. postProcesses: PostProcess[];
  33019. /**
  33020. * Gets the current postprocess manager
  33021. */
  33022. postProcessManager: PostProcessManager;
  33023. /**
  33024. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33025. */
  33026. renderTargetsEnabled: boolean;
  33027. /**
  33028. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33029. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33030. */
  33031. dumpNextRenderTargets: boolean;
  33032. /**
  33033. * The list of user defined render targets added to the scene
  33034. */
  33035. customRenderTargets: RenderTargetTexture[];
  33036. /**
  33037. * Defines if texture loading must be delayed
  33038. * If true, textures will only be loaded when they need to be rendered
  33039. */
  33040. useDelayedTextureLoading: boolean;
  33041. /**
  33042. * Gets the list of meshes imported to the scene through SceneLoader
  33043. */
  33044. importedMeshesFiles: String[];
  33045. /**
  33046. * Gets or sets a boolean indicating if probes are enabled on this scene
  33047. */
  33048. probesEnabled: boolean;
  33049. /**
  33050. * Gets or sets the current offline provider to use to store scene data
  33051. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33052. */
  33053. offlineProvider: IOfflineProvider;
  33054. /**
  33055. * Gets or sets the action manager associated with the scene
  33056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33057. */
  33058. actionManager: AbstractActionManager;
  33059. private _meshesForIntersections;
  33060. /**
  33061. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33062. */
  33063. proceduralTexturesEnabled: boolean;
  33064. private _engine;
  33065. private _totalVertices;
  33066. /** @hidden */
  33067. _activeIndices: PerfCounter;
  33068. /** @hidden */
  33069. _activeParticles: PerfCounter;
  33070. /** @hidden */
  33071. _activeBones: PerfCounter;
  33072. private _animationRatio;
  33073. /** @hidden */
  33074. _animationTimeLast: number;
  33075. /** @hidden */
  33076. _animationTime: number;
  33077. /**
  33078. * Gets or sets a general scale for animation speed
  33079. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33080. */
  33081. animationTimeScale: number;
  33082. /** @hidden */
  33083. _cachedMaterial: Nullable<Material>;
  33084. /** @hidden */
  33085. _cachedEffect: Nullable<Effect>;
  33086. /** @hidden */
  33087. _cachedVisibility: Nullable<number>;
  33088. private _renderId;
  33089. private _frameId;
  33090. private _executeWhenReadyTimeoutId;
  33091. private _intermediateRendering;
  33092. private _viewUpdateFlag;
  33093. private _projectionUpdateFlag;
  33094. /** @hidden */
  33095. _toBeDisposed: Nullable<IDisposable>[];
  33096. private _activeRequests;
  33097. /** @hidden */
  33098. _pendingData: any[];
  33099. private _isDisposed;
  33100. /**
  33101. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33102. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33103. */
  33104. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33105. private _activeMeshes;
  33106. private _processedMaterials;
  33107. private _renderTargets;
  33108. /** @hidden */
  33109. _activeParticleSystems: SmartArray<IParticleSystem>;
  33110. private _activeSkeletons;
  33111. private _softwareSkinnedMeshes;
  33112. private _renderingManager;
  33113. /** @hidden */
  33114. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33115. private _transformMatrix;
  33116. private _sceneUbo;
  33117. /** @hidden */
  33118. _viewMatrix: Matrix;
  33119. private _projectionMatrix;
  33120. private _wheelEventName;
  33121. /** @hidden */
  33122. _forcedViewPosition: Nullable<Vector3>;
  33123. /** @hidden */
  33124. _frustumPlanes: Plane[];
  33125. /**
  33126. * Gets the list of frustum planes (built from the active camera)
  33127. */
  33128. readonly frustumPlanes: Plane[];
  33129. /**
  33130. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33131. * This is useful if there are more lights that the maximum simulteanous authorized
  33132. */
  33133. requireLightSorting: boolean;
  33134. /** @hidden */
  33135. readonly useMaterialMeshMap: boolean;
  33136. /** @hidden */
  33137. readonly useClonedMeshhMap: boolean;
  33138. private _pointerOverMesh;
  33139. private _pickedDownMesh;
  33140. private _pickedUpMesh;
  33141. private _externalData;
  33142. private _uid;
  33143. /**
  33144. * @hidden
  33145. * Backing store of defined scene components.
  33146. */
  33147. _components: ISceneComponent[];
  33148. /**
  33149. * @hidden
  33150. * Backing store of defined scene components.
  33151. */
  33152. _serializableComponents: ISceneSerializableComponent[];
  33153. /**
  33154. * List of components to register on the next registration step.
  33155. */
  33156. private _transientComponents;
  33157. /**
  33158. * Registers the transient components if needed.
  33159. */
  33160. private _registerTransientComponents;
  33161. /**
  33162. * @hidden
  33163. * Add a component to the scene.
  33164. * Note that the ccomponent could be registered on th next frame if this is called after
  33165. * the register component stage.
  33166. * @param component Defines the component to add to the scene
  33167. */
  33168. _addComponent(component: ISceneComponent): void;
  33169. /**
  33170. * @hidden
  33171. * Gets a component from the scene.
  33172. * @param name defines the name of the component to retrieve
  33173. * @returns the component or null if not present
  33174. */
  33175. _getComponent(name: string): Nullable<ISceneComponent>;
  33176. /**
  33177. * @hidden
  33178. * Defines the actions happening before camera updates.
  33179. */
  33180. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33181. /**
  33182. * @hidden
  33183. * Defines the actions happening before clear the canvas.
  33184. */
  33185. _beforeClearStage: Stage<SimpleStageAction>;
  33186. /**
  33187. * @hidden
  33188. * Defines the actions when collecting render targets for the frame.
  33189. */
  33190. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33191. /**
  33192. * @hidden
  33193. * Defines the actions happening for one camera in the frame.
  33194. */
  33195. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33196. /**
  33197. * @hidden
  33198. * Defines the actions happening during the per mesh ready checks.
  33199. */
  33200. _isReadyForMeshStage: Stage<MeshStageAction>;
  33201. /**
  33202. * @hidden
  33203. * Defines the actions happening before evaluate active mesh checks.
  33204. */
  33205. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33206. /**
  33207. * @hidden
  33208. * Defines the actions happening during the evaluate sub mesh checks.
  33209. */
  33210. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33211. /**
  33212. * @hidden
  33213. * Defines the actions happening during the active mesh stage.
  33214. */
  33215. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33216. /**
  33217. * @hidden
  33218. * Defines the actions happening during the per camera render target step.
  33219. */
  33220. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  33221. /**
  33222. * @hidden
  33223. * Defines the actions happening just before the active camera is drawing.
  33224. */
  33225. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33226. /**
  33227. * @hidden
  33228. * Defines the actions happening just before a render target is drawing.
  33229. */
  33230. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33231. /**
  33232. * @hidden
  33233. * Defines the actions happening just before a rendering group is drawing.
  33234. */
  33235. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33236. /**
  33237. * @hidden
  33238. * Defines the actions happening just before a mesh is drawing.
  33239. */
  33240. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33241. /**
  33242. * @hidden
  33243. * Defines the actions happening just after a mesh has been drawn.
  33244. */
  33245. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33246. /**
  33247. * @hidden
  33248. * Defines the actions happening just after a rendering group has been drawn.
  33249. */
  33250. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33251. /**
  33252. * @hidden
  33253. * Defines the actions happening just after the active camera has been drawn.
  33254. */
  33255. _afterCameraDrawStage: Stage<CameraStageAction>;
  33256. /**
  33257. * @hidden
  33258. * Defines the actions happening just after a render target has been drawn.
  33259. */
  33260. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33261. /**
  33262. * @hidden
  33263. * Defines the actions happening just after rendering all cameras and computing intersections.
  33264. */
  33265. _afterRenderStage: Stage<SimpleStageAction>;
  33266. /**
  33267. * @hidden
  33268. * Defines the actions happening when a pointer move event happens.
  33269. */
  33270. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33271. /**
  33272. * @hidden
  33273. * Defines the actions happening when a pointer down event happens.
  33274. */
  33275. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33276. /**
  33277. * @hidden
  33278. * Defines the actions happening when a pointer up event happens.
  33279. */
  33280. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33281. /**
  33282. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33283. */
  33284. private geometriesByUniqueId;
  33285. /**
  33286. * Creates a new Scene
  33287. * @param engine defines the engine to use to render this scene
  33288. * @param options defines the scene options
  33289. */
  33290. constructor(engine: Engine, options?: SceneOptions);
  33291. /**
  33292. * Gets a string idenfifying the name of the class
  33293. * @returns "Scene" string
  33294. */
  33295. getClassName(): string;
  33296. private _defaultMeshCandidates;
  33297. /**
  33298. * @hidden
  33299. */
  33300. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33301. private _defaultSubMeshCandidates;
  33302. /**
  33303. * @hidden
  33304. */
  33305. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33306. /**
  33307. * Sets the default candidate providers for the scene.
  33308. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33309. * and getCollidingSubMeshCandidates to their default function
  33310. */
  33311. setDefaultCandidateProviders(): void;
  33312. /**
  33313. * Gets the mesh that is currently under the pointer
  33314. */
  33315. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33316. /**
  33317. * Gets or sets the current on-screen X position of the pointer
  33318. */
  33319. pointerX: number;
  33320. /**
  33321. * Gets or sets the current on-screen Y position of the pointer
  33322. */
  33323. pointerY: number;
  33324. /**
  33325. * Gets the cached material (ie. the latest rendered one)
  33326. * @returns the cached material
  33327. */
  33328. getCachedMaterial(): Nullable<Material>;
  33329. /**
  33330. * Gets the cached effect (ie. the latest rendered one)
  33331. * @returns the cached effect
  33332. */
  33333. getCachedEffect(): Nullable<Effect>;
  33334. /**
  33335. * Gets the cached visibility state (ie. the latest rendered one)
  33336. * @returns the cached visibility state
  33337. */
  33338. getCachedVisibility(): Nullable<number>;
  33339. /**
  33340. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33341. * @param material defines the current material
  33342. * @param effect defines the current effect
  33343. * @param visibility defines the current visibility state
  33344. * @returns true if one parameter is not cached
  33345. */
  33346. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33347. /**
  33348. * Gets the engine associated with the scene
  33349. * @returns an Engine
  33350. */
  33351. getEngine(): Engine;
  33352. /**
  33353. * Gets the total number of vertices rendered per frame
  33354. * @returns the total number of vertices rendered per frame
  33355. */
  33356. getTotalVertices(): number;
  33357. /**
  33358. * Gets the performance counter for total vertices
  33359. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33360. */
  33361. readonly totalVerticesPerfCounter: PerfCounter;
  33362. /**
  33363. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33364. * @returns the total number of active indices rendered per frame
  33365. */
  33366. getActiveIndices(): number;
  33367. /**
  33368. * Gets the performance counter for active indices
  33369. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33370. */
  33371. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33372. /**
  33373. * Gets the total number of active particles rendered per frame
  33374. * @returns the total number of active particles rendered per frame
  33375. */
  33376. getActiveParticles(): number;
  33377. /**
  33378. * Gets the performance counter for active particles
  33379. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33380. */
  33381. readonly activeParticlesPerfCounter: PerfCounter;
  33382. /**
  33383. * Gets the total number of active bones rendered per frame
  33384. * @returns the total number of active bones rendered per frame
  33385. */
  33386. getActiveBones(): number;
  33387. /**
  33388. * Gets the performance counter for active bones
  33389. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33390. */
  33391. readonly activeBonesPerfCounter: PerfCounter;
  33392. /**
  33393. * Gets the array of active meshes
  33394. * @returns an array of AbstractMesh
  33395. */
  33396. getActiveMeshes(): SmartArray<AbstractMesh>;
  33397. /**
  33398. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33399. * @returns a number
  33400. */
  33401. getAnimationRatio(): number;
  33402. /**
  33403. * Gets an unique Id for the current render phase
  33404. * @returns a number
  33405. */
  33406. getRenderId(): number;
  33407. /**
  33408. * Gets an unique Id for the current frame
  33409. * @returns a number
  33410. */
  33411. getFrameId(): number;
  33412. /** Call this function if you want to manually increment the render Id*/
  33413. incrementRenderId(): void;
  33414. private _updatePointerPosition;
  33415. private _createUbo;
  33416. private _setRayOnPointerInfo;
  33417. /**
  33418. * Use this method to simulate a pointer move on a mesh
  33419. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33420. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33421. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33422. * @returns the current scene
  33423. */
  33424. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33425. private _processPointerMove;
  33426. private _checkPrePointerObservable;
  33427. /**
  33428. * Use this method to simulate a pointer down 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. * @returns the current scene
  33433. */
  33434. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33435. private _processPointerDown;
  33436. /**
  33437. * Use this method to simulate a pointer up on a mesh
  33438. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33439. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33440. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33441. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33442. * @returns the current scene
  33443. */
  33444. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33445. private _processPointerUp;
  33446. /**
  33447. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33448. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33449. * @returns true if the pointer was captured
  33450. */
  33451. isPointerCaptured(pointerId?: number): boolean;
  33452. /** @hidden */
  33453. _isPointerSwiping(): boolean;
  33454. /**
  33455. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33456. * @param attachUp defines if you want to attach events to pointerup
  33457. * @param attachDown defines if you want to attach events to pointerdown
  33458. * @param attachMove defines if you want to attach events to pointermove
  33459. */
  33460. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33461. /** Detaches all event handlers*/
  33462. detachControl(): void;
  33463. /**
  33464. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33465. * Delay loaded resources are not taking in account
  33466. * @return true if all required resources are ready
  33467. */
  33468. isReady(): boolean;
  33469. /** Resets all cached information relative to material (including effect and visibility) */
  33470. resetCachedMaterial(): void;
  33471. /**
  33472. * Registers a function to be called before every frame render
  33473. * @param func defines the function to register
  33474. */
  33475. registerBeforeRender(func: () => void): void;
  33476. /**
  33477. * Unregisters a function called before every frame render
  33478. * @param func defines the function to unregister
  33479. */
  33480. unregisterBeforeRender(func: () => void): void;
  33481. /**
  33482. * Registers a function to be called after every frame render
  33483. * @param func defines the function to register
  33484. */
  33485. registerAfterRender(func: () => void): void;
  33486. /**
  33487. * Unregisters a function called after every frame render
  33488. * @param func defines the function to unregister
  33489. */
  33490. unregisterAfterRender(func: () => void): void;
  33491. private _executeOnceBeforeRender;
  33492. /**
  33493. * The provided function will run before render once and will be disposed afterwards.
  33494. * A timeout delay can be provided so that the function will be executed in N ms.
  33495. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33496. * @param func The function to be executed.
  33497. * @param timeout optional delay in ms
  33498. */
  33499. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33500. /** @hidden */
  33501. _addPendingData(data: any): void;
  33502. /** @hidden */
  33503. _removePendingData(data: any): void;
  33504. /**
  33505. * Returns the number of items waiting to be loaded
  33506. * @returns the number of items waiting to be loaded
  33507. */
  33508. getWaitingItemsCount(): number;
  33509. /**
  33510. * Returns a boolean indicating if the scene is still loading data
  33511. */
  33512. readonly isLoading: boolean;
  33513. /**
  33514. * Registers a function to be executed when the scene is ready
  33515. * @param {Function} func - the function to be executed
  33516. */
  33517. executeWhenReady(func: () => void): void;
  33518. /**
  33519. * Returns a promise that resolves when the scene is ready
  33520. * @returns A promise that resolves when the scene is ready
  33521. */
  33522. whenReadyAsync(): Promise<void>;
  33523. /** @hidden */
  33524. _checkIsReady(): void;
  33525. /**
  33526. * Gets all animatable attached to the scene
  33527. */
  33528. readonly animatables: Animatable[];
  33529. /**
  33530. * Resets the last animation time frame.
  33531. * Useful to override when animations start running when loading a scene for the first time.
  33532. */
  33533. resetLastAnimationTimeFrame(): void;
  33534. /**
  33535. * Gets the current view matrix
  33536. * @returns a Matrix
  33537. */
  33538. getViewMatrix(): Matrix;
  33539. /**
  33540. * Gets the current projection matrix
  33541. * @returns a Matrix
  33542. */
  33543. getProjectionMatrix(): Matrix;
  33544. /**
  33545. * Gets the current transform matrix
  33546. * @returns a Matrix made of View * Projection
  33547. */
  33548. getTransformMatrix(): Matrix;
  33549. /**
  33550. * Sets the current transform matrix
  33551. * @param viewL defines the View matrix to use
  33552. * @param projectionL defines the Projection matrix to use
  33553. * @param viewR defines the right View matrix to use (if provided)
  33554. * @param projectionR defines the right Projection matrix to use (if provided)
  33555. */
  33556. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33557. /**
  33558. * Gets the uniform buffer used to store scene data
  33559. * @returns a UniformBuffer
  33560. */
  33561. getSceneUniformBuffer(): UniformBuffer;
  33562. /**
  33563. * Gets an unique (relatively to the current scene) Id
  33564. * @returns an unique number for the scene
  33565. */
  33566. getUniqueId(): number;
  33567. /**
  33568. * Add a mesh to the list of scene's meshes
  33569. * @param newMesh defines the mesh to add
  33570. * @param recursive if all child meshes should also be added to the scene
  33571. */
  33572. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33573. /**
  33574. * Remove a mesh for the list of scene's meshes
  33575. * @param toRemove defines the mesh to remove
  33576. * @param recursive if all child meshes should also be removed from the scene
  33577. * @returns the index where the mesh was in the mesh list
  33578. */
  33579. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33580. /**
  33581. * Add a transform node to the list of scene's transform nodes
  33582. * @param newTransformNode defines the transform node to add
  33583. */
  33584. addTransformNode(newTransformNode: TransformNode): void;
  33585. /**
  33586. * Remove a transform node for the list of scene's transform nodes
  33587. * @param toRemove defines the transform node to remove
  33588. * @returns the index where the transform node was in the transform node list
  33589. */
  33590. removeTransformNode(toRemove: TransformNode): number;
  33591. /**
  33592. * Remove a skeleton for the list of scene's skeletons
  33593. * @param toRemove defines the skeleton to remove
  33594. * @returns the index where the skeleton was in the skeleton list
  33595. */
  33596. removeSkeleton(toRemove: Skeleton): number;
  33597. /**
  33598. * Remove a morph target for the list of scene's morph targets
  33599. * @param toRemove defines the morph target to remove
  33600. * @returns the index where the morph target was in the morph target list
  33601. */
  33602. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33603. /**
  33604. * Remove a light for the list of scene's lights
  33605. * @param toRemove defines the light to remove
  33606. * @returns the index where the light was in the light list
  33607. */
  33608. removeLight(toRemove: Light): number;
  33609. /**
  33610. * Remove a camera for the list of scene's cameras
  33611. * @param toRemove defines the camera to remove
  33612. * @returns the index where the camera was in the camera list
  33613. */
  33614. removeCamera(toRemove: Camera): number;
  33615. /**
  33616. * Remove a particle system for the list of scene's particle systems
  33617. * @param toRemove defines the particle system to remove
  33618. * @returns the index where the particle system was in the particle system list
  33619. */
  33620. removeParticleSystem(toRemove: IParticleSystem): number;
  33621. /**
  33622. * Remove a animation for the list of scene's animations
  33623. * @param toRemove defines the animation to remove
  33624. * @returns the index where the animation was in the animation list
  33625. */
  33626. removeAnimation(toRemove: Animation): number;
  33627. /**
  33628. * Removes the given animation group from this scene.
  33629. * @param toRemove The animation group to remove
  33630. * @returns The index of the removed animation group
  33631. */
  33632. removeAnimationGroup(toRemove: AnimationGroup): number;
  33633. /**
  33634. * Removes the given multi-material from this scene.
  33635. * @param toRemove The multi-material to remove
  33636. * @returns The index of the removed multi-material
  33637. */
  33638. removeMultiMaterial(toRemove: MultiMaterial): number;
  33639. /**
  33640. * Removes the given material from this scene.
  33641. * @param toRemove The material to remove
  33642. * @returns The index of the removed material
  33643. */
  33644. removeMaterial(toRemove: Material): number;
  33645. /**
  33646. * Removes the given action manager from this scene.
  33647. * @param toRemove The action manager to remove
  33648. * @returns The index of the removed action manager
  33649. */
  33650. removeActionManager(toRemove: AbstractActionManager): number;
  33651. /**
  33652. * Removes the given texture from this scene.
  33653. * @param toRemove The texture to remove
  33654. * @returns The index of the removed texture
  33655. */
  33656. removeTexture(toRemove: BaseTexture): number;
  33657. /**
  33658. * Adds the given light to this scene
  33659. * @param newLight The light to add
  33660. */
  33661. addLight(newLight: Light): void;
  33662. /**
  33663. * Sorts the list list based on light priorities
  33664. */
  33665. sortLightsByPriority(): void;
  33666. /**
  33667. * Adds the given camera to this scene
  33668. * @param newCamera The camera to add
  33669. */
  33670. addCamera(newCamera: Camera): void;
  33671. /**
  33672. * Adds the given skeleton to this scene
  33673. * @param newSkeleton The skeleton to add
  33674. */
  33675. addSkeleton(newSkeleton: Skeleton): void;
  33676. /**
  33677. * Adds the given particle system to this scene
  33678. * @param newParticleSystem The particle system to add
  33679. */
  33680. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33681. /**
  33682. * Adds the given animation to this scene
  33683. * @param newAnimation The animation to add
  33684. */
  33685. addAnimation(newAnimation: Animation): void;
  33686. /**
  33687. * Adds the given animation group to this scene.
  33688. * @param newAnimationGroup The animation group to add
  33689. */
  33690. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33691. /**
  33692. * Adds the given multi-material to this scene
  33693. * @param newMultiMaterial The multi-material to add
  33694. */
  33695. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33696. /**
  33697. * Adds the given material to this scene
  33698. * @param newMaterial The material to add
  33699. */
  33700. addMaterial(newMaterial: Material): void;
  33701. /**
  33702. * Adds the given morph target to this scene
  33703. * @param newMorphTargetManager The morph target to add
  33704. */
  33705. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33706. /**
  33707. * Adds the given geometry to this scene
  33708. * @param newGeometry The geometry to add
  33709. */
  33710. addGeometry(newGeometry: Geometry): void;
  33711. /**
  33712. * Adds the given action manager to this scene
  33713. * @param newActionManager The action manager to add
  33714. */
  33715. addActionManager(newActionManager: AbstractActionManager): void;
  33716. /**
  33717. * Adds the given texture to this scene.
  33718. * @param newTexture The texture to add
  33719. */
  33720. addTexture(newTexture: BaseTexture): void;
  33721. /**
  33722. * Switch active camera
  33723. * @param newCamera defines the new active camera
  33724. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33725. */
  33726. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33727. /**
  33728. * sets the active camera of the scene using its ID
  33729. * @param id defines the camera's ID
  33730. * @return the new active camera or null if none found.
  33731. */
  33732. setActiveCameraByID(id: string): Nullable<Camera>;
  33733. /**
  33734. * sets the active camera of the scene using its name
  33735. * @param name defines the camera's name
  33736. * @returns the new active camera or null if none found.
  33737. */
  33738. setActiveCameraByName(name: string): Nullable<Camera>;
  33739. /**
  33740. * get an animation group using its name
  33741. * @param name defines the material's name
  33742. * @return the animation group or null if none found.
  33743. */
  33744. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33745. /**
  33746. * Get a material using its unique id
  33747. * @param uniqueId defines the material's unique id
  33748. * @return the material or null if none found.
  33749. */
  33750. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33751. /**
  33752. * get a material using its id
  33753. * @param id defines the material's ID
  33754. * @return the material or null if none found.
  33755. */
  33756. getMaterialByID(id: string): Nullable<Material>;
  33757. /**
  33758. * Gets a material using its name
  33759. * @param name defines the material's name
  33760. * @return the material or null if none found.
  33761. */
  33762. getMaterialByName(name: string): Nullable<Material>;
  33763. /**
  33764. * Gets a camera using its id
  33765. * @param id defines the id to look for
  33766. * @returns the camera or null if not found
  33767. */
  33768. getCameraByID(id: string): Nullable<Camera>;
  33769. /**
  33770. * Gets a camera using its unique id
  33771. * @param uniqueId defines the unique id to look for
  33772. * @returns the camera or null if not found
  33773. */
  33774. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33775. /**
  33776. * Gets a camera using its name
  33777. * @param name defines the camera's name
  33778. * @return the camera or null if none found.
  33779. */
  33780. getCameraByName(name: string): Nullable<Camera>;
  33781. /**
  33782. * Gets a bone using its id
  33783. * @param id defines the bone's id
  33784. * @return the bone or null if not found
  33785. */
  33786. getBoneByID(id: string): Nullable<Bone>;
  33787. /**
  33788. * Gets a bone using its id
  33789. * @param name defines the bone's name
  33790. * @return the bone or null if not found
  33791. */
  33792. getBoneByName(name: string): Nullable<Bone>;
  33793. /**
  33794. * Gets a light node using its name
  33795. * @param name defines the the light's name
  33796. * @return the light or null if none found.
  33797. */
  33798. getLightByName(name: string): Nullable<Light>;
  33799. /**
  33800. * Gets a light node using its id
  33801. * @param id defines the light's id
  33802. * @return the light or null if none found.
  33803. */
  33804. getLightByID(id: string): Nullable<Light>;
  33805. /**
  33806. * Gets a light node using its scene-generated unique ID
  33807. * @param uniqueId defines the light's unique id
  33808. * @return the light or null if none found.
  33809. */
  33810. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33811. /**
  33812. * Gets a particle system by id
  33813. * @param id defines the particle system id
  33814. * @return the corresponding system or null if none found
  33815. */
  33816. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33817. /**
  33818. * Gets a geometry using its ID
  33819. * @param id defines the geometry's id
  33820. * @return the geometry or null if none found.
  33821. */
  33822. getGeometryByID(id: string): Nullable<Geometry>;
  33823. private _getGeometryByUniqueID;
  33824. /**
  33825. * Add a new geometry to this scene
  33826. * @param geometry defines the geometry to be added to the scene.
  33827. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33828. * @return a boolean defining if the geometry was added or not
  33829. */
  33830. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33831. /**
  33832. * Removes an existing geometry
  33833. * @param geometry defines the geometry to be removed from the scene
  33834. * @return a boolean defining if the geometry was removed or not
  33835. */
  33836. removeGeometry(geometry: Geometry): boolean;
  33837. /**
  33838. * Gets the list of geometries attached to the scene
  33839. * @returns an array of Geometry
  33840. */
  33841. getGeometries(): Geometry[];
  33842. /**
  33843. * Gets the first added mesh found of a given ID
  33844. * @param id defines the id to search for
  33845. * @return the mesh found or null if not found at all
  33846. */
  33847. getMeshByID(id: string): Nullable<AbstractMesh>;
  33848. /**
  33849. * Gets a list of meshes using their id
  33850. * @param id defines the id to search for
  33851. * @returns a list of meshes
  33852. */
  33853. getMeshesByID(id: string): Array<AbstractMesh>;
  33854. /**
  33855. * Gets the first added transform node found of a given ID
  33856. * @param id defines the id to search for
  33857. * @return the found transform node or null if not found at all.
  33858. */
  33859. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33860. /**
  33861. * Gets a transform node with its auto-generated unique id
  33862. * @param uniqueId efines the unique id to search for
  33863. * @return the found transform node or null if not found at all.
  33864. */
  33865. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33866. /**
  33867. * Gets a list of transform nodes using their id
  33868. * @param id defines the id to search for
  33869. * @returns a list of transform nodes
  33870. */
  33871. getTransformNodesByID(id: string): Array<TransformNode>;
  33872. /**
  33873. * Gets a mesh with its auto-generated unique id
  33874. * @param uniqueId defines the unique id to search for
  33875. * @return the found mesh or null if not found at all.
  33876. */
  33877. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33878. /**
  33879. * Gets a the last added mesh using a given id
  33880. * @param id defines the id to search for
  33881. * @return the found mesh or null if not found at all.
  33882. */
  33883. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33884. /**
  33885. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33886. * @param id defines the id to search for
  33887. * @return the found node or null if not found at all
  33888. */
  33889. getLastEntryByID(id: string): Nullable<Node>;
  33890. /**
  33891. * Gets a node (Mesh, Camera, Light) using a given id
  33892. * @param id defines the id to search for
  33893. * @return the found node or null if not found at all
  33894. */
  33895. getNodeByID(id: string): Nullable<Node>;
  33896. /**
  33897. * Gets a node (Mesh, Camera, Light) using a given name
  33898. * @param name defines the name to search for
  33899. * @return the found node or null if not found at all.
  33900. */
  33901. getNodeByName(name: string): Nullable<Node>;
  33902. /**
  33903. * Gets a mesh using a given name
  33904. * @param name defines the name to search for
  33905. * @return the found mesh or null if not found at all.
  33906. */
  33907. getMeshByName(name: string): Nullable<AbstractMesh>;
  33908. /**
  33909. * Gets a transform node using a given name
  33910. * @param name defines the name to search for
  33911. * @return the found transform node or null if not found at all.
  33912. */
  33913. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33914. /**
  33915. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33916. * @param id defines the id to search for
  33917. * @return the found skeleton or null if not found at all.
  33918. */
  33919. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33920. /**
  33921. * Gets a skeleton using a given auto generated unique id
  33922. * @param uniqueId defines the unique id to search for
  33923. * @return the found skeleton or null if not found at all.
  33924. */
  33925. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33926. /**
  33927. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33928. * @param id defines the id to search for
  33929. * @return the found skeleton or null if not found at all.
  33930. */
  33931. getSkeletonById(id: string): Nullable<Skeleton>;
  33932. /**
  33933. * Gets a skeleton using a given name
  33934. * @param name defines the name to search for
  33935. * @return the found skeleton or null if not found at all.
  33936. */
  33937. getSkeletonByName(name: string): Nullable<Skeleton>;
  33938. /**
  33939. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33940. * @param id defines the id to search for
  33941. * @return the found morph target manager or null if not found at all.
  33942. */
  33943. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33944. /**
  33945. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33946. * @param id defines the id to search for
  33947. * @return the found morph target or null if not found at all.
  33948. */
  33949. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33950. /**
  33951. * Gets a boolean indicating if the given mesh is active
  33952. * @param mesh defines the mesh to look for
  33953. * @returns true if the mesh is in the active list
  33954. */
  33955. isActiveMesh(mesh: AbstractMesh): boolean;
  33956. /**
  33957. * Return a unique id as a string which can serve as an identifier for the scene
  33958. */
  33959. readonly uid: string;
  33960. /**
  33961. * Add an externaly attached data from its key.
  33962. * This method call will fail and return false, if such key already exists.
  33963. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33964. * @param key the unique key that identifies the data
  33965. * @param data the data object to associate to the key for this Engine instance
  33966. * @return true if no such key were already present and the data was added successfully, false otherwise
  33967. */
  33968. addExternalData<T>(key: string, data: T): boolean;
  33969. /**
  33970. * Get an externaly attached data from its key
  33971. * @param key the unique key that identifies the data
  33972. * @return the associated data, if present (can be null), or undefined if not present
  33973. */
  33974. getExternalData<T>(key: string): Nullable<T>;
  33975. /**
  33976. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33977. * @param key the unique key that identifies the data
  33978. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33979. * @return the associated data, can be null if the factory returned null.
  33980. */
  33981. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33982. /**
  33983. * Remove an externaly attached data from the Engine instance
  33984. * @param key the unique key that identifies the data
  33985. * @return true if the data was successfully removed, false if it doesn't exist
  33986. */
  33987. removeExternalData(key: string): boolean;
  33988. private _evaluateSubMesh;
  33989. /**
  33990. * Clear the processed materials smart array preventing retention point in material dispose.
  33991. */
  33992. freeProcessedMaterials(): void;
  33993. private _preventFreeActiveMeshesAndRenderingGroups;
  33994. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33995. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33996. * when disposing several meshes in a row or a hierarchy of meshes.
  33997. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33998. */
  33999. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34000. /**
  34001. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34002. */
  34003. freeActiveMeshes(): void;
  34004. /**
  34005. * Clear the info related to rendering groups preventing retention points during dispose.
  34006. */
  34007. freeRenderingGroups(): void;
  34008. /** @hidden */
  34009. _isInIntermediateRendering(): boolean;
  34010. /**
  34011. * Lambda returning the list of potentially active meshes.
  34012. */
  34013. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34014. /**
  34015. * Lambda returning the list of potentially active sub meshes.
  34016. */
  34017. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34018. /**
  34019. * Lambda returning the list of potentially intersecting sub meshes.
  34020. */
  34021. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34022. /**
  34023. * Lambda returning the list of potentially colliding sub meshes.
  34024. */
  34025. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34026. private _activeMeshesFrozen;
  34027. /**
  34028. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34029. * @returns the current scene
  34030. */
  34031. freezeActiveMeshes(): Scene;
  34032. /**
  34033. * Use this function to restart evaluating active meshes on every frame
  34034. * @returns the current scene
  34035. */
  34036. unfreezeActiveMeshes(): Scene;
  34037. private _evaluateActiveMeshes;
  34038. private _activeMesh;
  34039. /**
  34040. * Update the transform matrix to update from the current active camera
  34041. * @param force defines a boolean used to force the update even if cache is up to date
  34042. */
  34043. updateTransformMatrix(force?: boolean): void;
  34044. private _bindFrameBuffer;
  34045. /** @hidden */
  34046. _allowPostProcessClearColor: boolean;
  34047. /** @hidden */
  34048. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34049. private _processSubCameras;
  34050. private _checkIntersections;
  34051. /** @hidden */
  34052. _advancePhysicsEngineStep(step: number): void;
  34053. /**
  34054. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34055. */
  34056. getDeterministicFrameTime: () => number;
  34057. /** @hidden */
  34058. _animate(): void;
  34059. /**
  34060. * Render the scene
  34061. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34062. */
  34063. render(updateCameras?: boolean): void;
  34064. /**
  34065. * Freeze all materials
  34066. * A frozen material will not be updatable but should be faster to render
  34067. */
  34068. freezeMaterials(): void;
  34069. /**
  34070. * Unfreeze all materials
  34071. * A frozen material will not be updatable but should be faster to render
  34072. */
  34073. unfreezeMaterials(): void;
  34074. /**
  34075. * Releases all held ressources
  34076. */
  34077. dispose(): void;
  34078. /**
  34079. * Gets if the scene is already disposed
  34080. */
  34081. readonly isDisposed: boolean;
  34082. /**
  34083. * Call this function to reduce memory footprint of the scene.
  34084. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34085. */
  34086. clearCachedVertexData(): void;
  34087. /**
  34088. * This function will remove the local cached buffer data from texture.
  34089. * It will save memory but will prevent the texture from being rebuilt
  34090. */
  34091. cleanCachedTextureBuffer(): void;
  34092. /**
  34093. * Get the world extend vectors with an optional filter
  34094. *
  34095. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34096. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34097. */
  34098. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34099. min: Vector3;
  34100. max: Vector3;
  34101. };
  34102. /**
  34103. * Creates a ray that can be used to pick in the scene
  34104. * @param x defines the x coordinate of the origin (on-screen)
  34105. * @param y defines the y coordinate of the origin (on-screen)
  34106. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34107. * @param camera defines the camera to use for the picking
  34108. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34109. * @returns a Ray
  34110. */
  34111. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34112. /**
  34113. * Creates a ray that can be used to pick in the scene
  34114. * @param x defines the x coordinate of the origin (on-screen)
  34115. * @param y defines the y coordinate of the origin (on-screen)
  34116. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34117. * @param result defines the ray where to store the picking ray
  34118. * @param camera defines the camera to use for the picking
  34119. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34120. * @returns the current scene
  34121. */
  34122. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34123. /**
  34124. * Creates a ray that can be used to pick in the scene
  34125. * @param x defines the x coordinate of the origin (on-screen)
  34126. * @param y defines the y coordinate of the origin (on-screen)
  34127. * @param camera defines the camera to use for the picking
  34128. * @returns a Ray
  34129. */
  34130. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34131. /**
  34132. * Creates a ray that can be used to pick in the scene
  34133. * @param x defines the x coordinate of the origin (on-screen)
  34134. * @param y defines the y coordinate of the origin (on-screen)
  34135. * @param result defines the ray where to store the picking ray
  34136. * @param camera defines the camera to use for the picking
  34137. * @returns the current scene
  34138. */
  34139. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34140. /** Launch a ray to try to pick a mesh in the scene
  34141. * @param x position on screen
  34142. * @param y position on screen
  34143. * @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
  34144. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34145. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34146. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34147. * @returns a PickingInfo
  34148. */
  34149. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34150. /** Use the given ray to pick a mesh in the scene
  34151. * @param ray The ray to use to pick meshes
  34152. * @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
  34153. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34154. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34155. * @returns a PickingInfo
  34156. */
  34157. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34158. /**
  34159. * Launch a ray to try to pick a mesh in the scene
  34160. * @param x X position on screen
  34161. * @param y Y position on screen
  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 camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34164. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34165. * @returns an array of PickingInfo
  34166. */
  34167. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34168. /**
  34169. * Launch a ray to try to pick a mesh in the scene
  34170. * @param ray Ray to use
  34171. * @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
  34172. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34173. * @returns an array of PickingInfo
  34174. */
  34175. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34176. /**
  34177. * Force the value of meshUnderPointer
  34178. * @param mesh defines the mesh to use
  34179. */
  34180. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34181. /**
  34182. * Gets the mesh under the pointer
  34183. * @returns a Mesh or null if no mesh is under the pointer
  34184. */
  34185. getPointerOverMesh(): Nullable<AbstractMesh>;
  34186. /** @hidden */
  34187. _rebuildGeometries(): void;
  34188. /** @hidden */
  34189. _rebuildTextures(): void;
  34190. private _getByTags;
  34191. /**
  34192. * Get a list of meshes by tags
  34193. * @param tagsQuery defines the tags query to use
  34194. * @param forEach defines a predicate used to filter results
  34195. * @returns an array of Mesh
  34196. */
  34197. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34198. /**
  34199. * Get a list of cameras by tags
  34200. * @param tagsQuery defines the tags query to use
  34201. * @param forEach defines a predicate used to filter results
  34202. * @returns an array of Camera
  34203. */
  34204. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34205. /**
  34206. * Get a list of lights by tags
  34207. * @param tagsQuery defines the tags query to use
  34208. * @param forEach defines a predicate used to filter results
  34209. * @returns an array of Light
  34210. */
  34211. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34212. /**
  34213. * Get a list of materials by tags
  34214. * @param tagsQuery defines the tags query to use
  34215. * @param forEach defines a predicate used to filter results
  34216. * @returns an array of Material
  34217. */
  34218. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34219. /**
  34220. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34221. * This allowed control for front to back rendering or reversly depending of the special needs.
  34222. *
  34223. * @param renderingGroupId The rendering group id corresponding to its index
  34224. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34225. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34226. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34227. */
  34228. 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;
  34229. /**
  34230. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34231. *
  34232. * @param renderingGroupId The rendering group id corresponding to its index
  34233. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34234. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34235. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34236. */
  34237. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34238. /**
  34239. * Gets the current auto clear configuration for one rendering group of the rendering
  34240. * manager.
  34241. * @param index the rendering group index to get the information for
  34242. * @returns The auto clear setup for the requested rendering group
  34243. */
  34244. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34245. private _blockMaterialDirtyMechanism;
  34246. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34247. blockMaterialDirtyMechanism: boolean;
  34248. /**
  34249. * Will flag all materials as dirty to trigger new shader compilation
  34250. * @param flag defines the flag used to specify which material part must be marked as dirty
  34251. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34252. */
  34253. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34254. /** @hidden */
  34255. _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;
  34256. /** @hidden */
  34257. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34258. }
  34259. }
  34260. declare module "babylonjs/assetContainer" {
  34261. import { AbstractScene } from "babylonjs/abstractScene";
  34262. import { Scene } from "babylonjs/scene";
  34263. import { Mesh } from "babylonjs/Meshes/mesh";
  34264. /**
  34265. * Set of assets to keep when moving a scene into an asset container.
  34266. */
  34267. export class KeepAssets extends AbstractScene {
  34268. }
  34269. /**
  34270. * Container with a set of assets that can be added or removed from a scene.
  34271. */
  34272. export class AssetContainer extends AbstractScene {
  34273. /**
  34274. * The scene the AssetContainer belongs to.
  34275. */
  34276. scene: Scene;
  34277. /**
  34278. * Instantiates an AssetContainer.
  34279. * @param scene The scene the AssetContainer belongs to.
  34280. */
  34281. constructor(scene: Scene);
  34282. /**
  34283. * Adds all the assets from the container to the scene.
  34284. */
  34285. addAllToScene(): void;
  34286. /**
  34287. * Removes all the assets in the container from the scene
  34288. */
  34289. removeAllFromScene(): void;
  34290. /**
  34291. * Disposes all the assets in the container
  34292. */
  34293. dispose(): void;
  34294. private _moveAssets;
  34295. /**
  34296. * Removes all the assets contained in the scene and adds them to the container.
  34297. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34298. */
  34299. moveAllFromScene(keepAssets?: KeepAssets): void;
  34300. /**
  34301. * 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.
  34302. * @returns the root mesh
  34303. */
  34304. createRootMesh(): Mesh;
  34305. }
  34306. }
  34307. declare module "babylonjs/abstractScene" {
  34308. import { Scene } from "babylonjs/scene";
  34309. import { Nullable } from "babylonjs/types";
  34310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34311. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34312. import { Geometry } from "babylonjs/Meshes/geometry";
  34313. import { Skeleton } from "babylonjs/Bones/skeleton";
  34314. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34315. import { AssetContainer } from "babylonjs/assetContainer";
  34316. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34317. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34318. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34319. import { Material } from "babylonjs/Materials/material";
  34320. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34321. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34322. import { Camera } from "babylonjs/Cameras/camera";
  34323. import { Light } from "babylonjs/Lights/light";
  34324. import { Node } from "babylonjs/node";
  34325. import { Animation } from "babylonjs/Animations/animation";
  34326. /**
  34327. * Defines how the parser contract is defined.
  34328. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34329. */
  34330. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34331. /**
  34332. * Defines how the individual parser contract is defined.
  34333. * These parser can parse an individual asset
  34334. */
  34335. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34336. /**
  34337. * Base class of the scene acting as a container for the different elements composing a scene.
  34338. * This class is dynamically extended by the different components of the scene increasing
  34339. * flexibility and reducing coupling
  34340. */
  34341. export abstract class AbstractScene {
  34342. /**
  34343. * Stores the list of available parsers in the application.
  34344. */
  34345. private static _BabylonFileParsers;
  34346. /**
  34347. * Stores the list of available individual parsers in the application.
  34348. */
  34349. private static _IndividualBabylonFileParsers;
  34350. /**
  34351. * Adds a parser in the list of available ones
  34352. * @param name Defines the name of the parser
  34353. * @param parser Defines the parser to add
  34354. */
  34355. static AddParser(name: string, parser: BabylonFileParser): void;
  34356. /**
  34357. * Gets a general parser from the list of avaialble ones
  34358. * @param name Defines the name of the parser
  34359. * @returns the requested parser or null
  34360. */
  34361. static GetParser(name: string): Nullable<BabylonFileParser>;
  34362. /**
  34363. * Adds n individual parser in the list of available ones
  34364. * @param name Defines the name of the parser
  34365. * @param parser Defines the parser to add
  34366. */
  34367. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34368. /**
  34369. * Gets an individual parser from the list of avaialble ones
  34370. * @param name Defines the name of the parser
  34371. * @returns the requested parser or null
  34372. */
  34373. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34374. /**
  34375. * Parser json data and populate both a scene and its associated container object
  34376. * @param jsonData Defines the data to parse
  34377. * @param scene Defines the scene to parse the data for
  34378. * @param container Defines the container attached to the parsing sequence
  34379. * @param rootUrl Defines the root url of the data
  34380. */
  34381. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34382. /**
  34383. * Gets the list of root nodes (ie. nodes with no parent)
  34384. */
  34385. rootNodes: Node[];
  34386. /** All of the cameras added to this scene
  34387. * @see http://doc.babylonjs.com/babylon101/cameras
  34388. */
  34389. cameras: Camera[];
  34390. /**
  34391. * All of the lights added to this scene
  34392. * @see http://doc.babylonjs.com/babylon101/lights
  34393. */
  34394. lights: Light[];
  34395. /**
  34396. * All of the (abstract) meshes added to this scene
  34397. */
  34398. meshes: AbstractMesh[];
  34399. /**
  34400. * The list of skeletons added to the scene
  34401. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34402. */
  34403. skeletons: Skeleton[];
  34404. /**
  34405. * All of the particle systems added to this scene
  34406. * @see http://doc.babylonjs.com/babylon101/particles
  34407. */
  34408. particleSystems: IParticleSystem[];
  34409. /**
  34410. * Gets a list of Animations associated with the scene
  34411. */
  34412. animations: Animation[];
  34413. /**
  34414. * All of the animation groups added to this scene
  34415. * @see http://doc.babylonjs.com/how_to/group
  34416. */
  34417. animationGroups: AnimationGroup[];
  34418. /**
  34419. * All of the multi-materials added to this scene
  34420. * @see http://doc.babylonjs.com/how_to/multi_materials
  34421. */
  34422. multiMaterials: MultiMaterial[];
  34423. /**
  34424. * All of the materials added to this scene
  34425. * In the context of a Scene, it is not supposed to be modified manually.
  34426. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34427. * Note also that the order of the Material wihin the array is not significant and might change.
  34428. * @see http://doc.babylonjs.com/babylon101/materials
  34429. */
  34430. materials: Material[];
  34431. /**
  34432. * The list of morph target managers added to the scene
  34433. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34434. */
  34435. morphTargetManagers: MorphTargetManager[];
  34436. /**
  34437. * The list of geometries used in the scene.
  34438. */
  34439. geometries: Geometry[];
  34440. /**
  34441. * All of the tranform nodes added to this scene
  34442. * In the context of a Scene, it is not supposed to be modified manually.
  34443. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34444. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34445. * @see http://doc.babylonjs.com/how_to/transformnode
  34446. */
  34447. transformNodes: TransformNode[];
  34448. /**
  34449. * ActionManagers available on the scene.
  34450. */
  34451. actionManagers: AbstractActionManager[];
  34452. /**
  34453. * Textures to keep.
  34454. */
  34455. textures: BaseTexture[];
  34456. /**
  34457. * Environment texture for the scene
  34458. */
  34459. environmentTexture: Nullable<BaseTexture>;
  34460. }
  34461. }
  34462. declare module "babylonjs/Audio/sound" {
  34463. import { Observable } from "babylonjs/Misc/observable";
  34464. import { Vector3 } from "babylonjs/Maths/math";
  34465. import { Nullable } from "babylonjs/types";
  34466. import { Scene } from "babylonjs/scene";
  34467. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34468. /**
  34469. * Defines a sound that can be played in the application.
  34470. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34472. */
  34473. export class Sound {
  34474. /**
  34475. * The name of the sound in the scene.
  34476. */
  34477. name: string;
  34478. /**
  34479. * Does the sound autoplay once loaded.
  34480. */
  34481. autoplay: boolean;
  34482. /**
  34483. * Does the sound loop after it finishes playing once.
  34484. */
  34485. loop: boolean;
  34486. /**
  34487. * Does the sound use a custom attenuation curve to simulate the falloff
  34488. * happening when the source gets further away from the camera.
  34489. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34490. */
  34491. useCustomAttenuation: boolean;
  34492. /**
  34493. * The sound track id this sound belongs to.
  34494. */
  34495. soundTrackId: number;
  34496. /**
  34497. * Is this sound currently played.
  34498. */
  34499. isPlaying: boolean;
  34500. /**
  34501. * Is this sound currently paused.
  34502. */
  34503. isPaused: boolean;
  34504. /**
  34505. * Does this sound enables spatial sound.
  34506. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34507. */
  34508. spatialSound: boolean;
  34509. /**
  34510. * Define the reference distance the sound should be heard perfectly.
  34511. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34512. */
  34513. refDistance: number;
  34514. /**
  34515. * Define the roll off factor of spatial sounds.
  34516. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34517. */
  34518. rolloffFactor: number;
  34519. /**
  34520. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34521. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34522. */
  34523. maxDistance: number;
  34524. /**
  34525. * Define the distance attenuation model the sound will follow.
  34526. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34527. */
  34528. distanceModel: string;
  34529. /**
  34530. * @hidden
  34531. * Back Compat
  34532. **/
  34533. onended: () => any;
  34534. /**
  34535. * Observable event when the current playing sound finishes.
  34536. */
  34537. onEndedObservable: Observable<Sound>;
  34538. private _panningModel;
  34539. private _playbackRate;
  34540. private _streaming;
  34541. private _startTime;
  34542. private _startOffset;
  34543. private _position;
  34544. /** @hidden */
  34545. _positionInEmitterSpace: boolean;
  34546. private _localDirection;
  34547. private _volume;
  34548. private _isReadyToPlay;
  34549. private _isDirectional;
  34550. private _readyToPlayCallback;
  34551. private _audioBuffer;
  34552. private _soundSource;
  34553. private _streamingSource;
  34554. private _soundPanner;
  34555. private _soundGain;
  34556. private _inputAudioNode;
  34557. private _outputAudioNode;
  34558. private _coneInnerAngle;
  34559. private _coneOuterAngle;
  34560. private _coneOuterGain;
  34561. private _scene;
  34562. private _connectedTransformNode;
  34563. private _customAttenuationFunction;
  34564. private _registerFunc;
  34565. private _isOutputConnected;
  34566. private _htmlAudioElement;
  34567. private _urlType;
  34568. /** @hidden */
  34569. static _SceneComponentInitialization: (scene: Scene) => void;
  34570. /**
  34571. * Create a sound and attach it to a scene
  34572. * @param name Name of your sound
  34573. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34574. * @param scene defines the scene the sound belongs to
  34575. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34576. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34577. */
  34578. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34579. /**
  34580. * Release the sound and its associated resources
  34581. */
  34582. dispose(): void;
  34583. /**
  34584. * Gets if the sounds is ready to be played or not.
  34585. * @returns true if ready, otherwise false
  34586. */
  34587. isReady(): boolean;
  34588. private _soundLoaded;
  34589. /**
  34590. * Sets the data of the sound from an audiobuffer
  34591. * @param audioBuffer The audioBuffer containing the data
  34592. */
  34593. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34594. /**
  34595. * Updates the current sounds options such as maxdistance, loop...
  34596. * @param options A JSON object containing values named as the object properties
  34597. */
  34598. updateOptions(options: any): void;
  34599. private _createSpatialParameters;
  34600. private _updateSpatialParameters;
  34601. /**
  34602. * Switch the panning model to HRTF:
  34603. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34604. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34605. */
  34606. switchPanningModelToHRTF(): void;
  34607. /**
  34608. * Switch the panning model to Equal Power:
  34609. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34610. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34611. */
  34612. switchPanningModelToEqualPower(): void;
  34613. private _switchPanningModel;
  34614. /**
  34615. * Connect this sound to a sound track audio node like gain...
  34616. * @param soundTrackAudioNode the sound track audio node to connect to
  34617. */
  34618. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34619. /**
  34620. * Transform this sound into a directional source
  34621. * @param coneInnerAngle Size of the inner cone in degree
  34622. * @param coneOuterAngle Size of the outer cone in degree
  34623. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34624. */
  34625. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34626. /**
  34627. * Gets or sets the inner angle for the directional cone.
  34628. */
  34629. /**
  34630. * Gets or sets the inner angle for the directional cone.
  34631. */
  34632. directionalConeInnerAngle: number;
  34633. /**
  34634. * Gets or sets the outer angle for the directional cone.
  34635. */
  34636. /**
  34637. * Gets or sets the outer angle for the directional cone.
  34638. */
  34639. directionalConeOuterAngle: number;
  34640. /**
  34641. * Sets the position of the emitter if spatial sound is enabled
  34642. * @param newPosition Defines the new posisiton
  34643. */
  34644. setPosition(newPosition: Vector3): void;
  34645. /**
  34646. * Sets the local direction of the emitter if spatial sound is enabled
  34647. * @param newLocalDirection Defines the new local direction
  34648. */
  34649. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34650. private _updateDirection;
  34651. /** @hidden */
  34652. updateDistanceFromListener(): void;
  34653. /**
  34654. * Sets a new custom attenuation function for the sound.
  34655. * @param callback Defines the function used for the attenuation
  34656. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34657. */
  34658. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34659. /**
  34660. * Play the sound
  34661. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34662. * @param offset (optional) Start the sound setting it at a specific time
  34663. */
  34664. play(time?: number, offset?: number): void;
  34665. private _onended;
  34666. /**
  34667. * Stop the sound
  34668. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34669. */
  34670. stop(time?: number): void;
  34671. /**
  34672. * Put the sound in pause
  34673. */
  34674. pause(): void;
  34675. /**
  34676. * Sets a dedicated volume for this sounds
  34677. * @param newVolume Define the new volume of the sound
  34678. * @param time Define in how long the sound should be at this value
  34679. */
  34680. setVolume(newVolume: number, time?: number): void;
  34681. /**
  34682. * Set the sound play back rate
  34683. * @param newPlaybackRate Define the playback rate the sound should be played at
  34684. */
  34685. setPlaybackRate(newPlaybackRate: number): void;
  34686. /**
  34687. * Gets the volume of the sound.
  34688. * @returns the volume of the sound
  34689. */
  34690. getVolume(): number;
  34691. /**
  34692. * Attach the sound to a dedicated mesh
  34693. * @param transformNode The transform node to connect the sound with
  34694. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34695. */
  34696. attachToMesh(transformNode: TransformNode): void;
  34697. /**
  34698. * Detach the sound from the previously attached mesh
  34699. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34700. */
  34701. detachFromMesh(): void;
  34702. private _onRegisterAfterWorldMatrixUpdate;
  34703. /**
  34704. * Clone the current sound in the scene.
  34705. * @returns the new sound clone
  34706. */
  34707. clone(): Nullable<Sound>;
  34708. /**
  34709. * Gets the current underlying audio buffer containing the data
  34710. * @returns the audio buffer
  34711. */
  34712. getAudioBuffer(): Nullable<AudioBuffer>;
  34713. /**
  34714. * Serializes the Sound in a JSON representation
  34715. * @returns the JSON representation of the sound
  34716. */
  34717. serialize(): any;
  34718. /**
  34719. * Parse a JSON representation of a sound to innstantiate in a given scene
  34720. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34721. * @param scene Define the scene the new parsed sound should be created in
  34722. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34723. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34724. * @returns the newly parsed sound
  34725. */
  34726. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34727. }
  34728. }
  34729. declare module "babylonjs/Actions/directAudioActions" {
  34730. import { Action } from "babylonjs/Actions/action";
  34731. import { Condition } from "babylonjs/Actions/condition";
  34732. import { Sound } from "babylonjs/Audio/sound";
  34733. /**
  34734. * This defines an action helpful to play a defined sound on a triggered action.
  34735. */
  34736. export class PlaySoundAction extends Action {
  34737. private _sound;
  34738. /**
  34739. * Instantiate the action
  34740. * @param triggerOptions defines the trigger options
  34741. * @param sound defines the sound to play
  34742. * @param condition defines the trigger related conditions
  34743. */
  34744. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34745. /** @hidden */
  34746. _prepare(): void;
  34747. /**
  34748. * Execute the action and play the sound.
  34749. */
  34750. execute(): void;
  34751. /**
  34752. * Serializes the actions and its related information.
  34753. * @param parent defines the object to serialize in
  34754. * @returns the serialized object
  34755. */
  34756. serialize(parent: any): any;
  34757. }
  34758. /**
  34759. * This defines an action helpful to stop a defined sound on a triggered action.
  34760. */
  34761. export class StopSoundAction extends Action {
  34762. private _sound;
  34763. /**
  34764. * Instantiate the action
  34765. * @param triggerOptions defines the trigger options
  34766. * @param sound defines the sound to stop
  34767. * @param condition defines the trigger related conditions
  34768. */
  34769. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34770. /** @hidden */
  34771. _prepare(): void;
  34772. /**
  34773. * Execute the action and stop the sound.
  34774. */
  34775. execute(): void;
  34776. /**
  34777. * Serializes the actions and its related information.
  34778. * @param parent defines the object to serialize in
  34779. * @returns the serialized object
  34780. */
  34781. serialize(parent: any): any;
  34782. }
  34783. }
  34784. declare module "babylonjs/Actions/interpolateValueAction" {
  34785. import { Action } from "babylonjs/Actions/action";
  34786. import { Condition } from "babylonjs/Actions/condition";
  34787. import { Observable } from "babylonjs/Misc/observable";
  34788. /**
  34789. * This defines an action responsible to change the value of a property
  34790. * by interpolating between its current value and the newly set one once triggered.
  34791. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34792. */
  34793. export class InterpolateValueAction extends Action {
  34794. /**
  34795. * Defines the path of the property where the value should be interpolated
  34796. */
  34797. propertyPath: string;
  34798. /**
  34799. * Defines the target value at the end of the interpolation.
  34800. */
  34801. value: any;
  34802. /**
  34803. * Defines the time it will take for the property to interpolate to the value.
  34804. */
  34805. duration: number;
  34806. /**
  34807. * Defines if the other scene animations should be stopped when the action has been triggered
  34808. */
  34809. stopOtherAnimations?: boolean;
  34810. /**
  34811. * Defines a callback raised once the interpolation animation has been done.
  34812. */
  34813. onInterpolationDone?: () => void;
  34814. /**
  34815. * Observable triggered once the interpolation animation has been done.
  34816. */
  34817. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34818. private _target;
  34819. private _effectiveTarget;
  34820. private _property;
  34821. /**
  34822. * Instantiate the action
  34823. * @param triggerOptions defines the trigger options
  34824. * @param target defines the object containing the value to interpolate
  34825. * @param propertyPath defines the path to the property in the target object
  34826. * @param value defines the target value at the end of the interpolation
  34827. * @param duration deines the time it will take for the property to interpolate to the value.
  34828. * @param condition defines the trigger related conditions
  34829. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34830. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34831. */
  34832. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34833. /** @hidden */
  34834. _prepare(): void;
  34835. /**
  34836. * Execute the action starts the value interpolation.
  34837. */
  34838. execute(): void;
  34839. /**
  34840. * Serializes the actions and its related information.
  34841. * @param parent defines the object to serialize in
  34842. * @returns the serialized object
  34843. */
  34844. serialize(parent: any): any;
  34845. }
  34846. }
  34847. declare module "babylonjs/Actions/index" {
  34848. export * from "babylonjs/Actions/action";
  34849. export * from "babylonjs/Actions/actionEvent";
  34850. export * from "babylonjs/Actions/actionManager";
  34851. export * from "babylonjs/Actions/condition";
  34852. export * from "babylonjs/Actions/directActions";
  34853. export * from "babylonjs/Actions/directAudioActions";
  34854. export * from "babylonjs/Actions/interpolateValueAction";
  34855. }
  34856. declare module "babylonjs/Animations/index" {
  34857. export * from "babylonjs/Animations/animatable";
  34858. export * from "babylonjs/Animations/animation";
  34859. export * from "babylonjs/Animations/animationGroup";
  34860. export * from "babylonjs/Animations/animationPropertiesOverride";
  34861. export * from "babylonjs/Animations/easing";
  34862. export * from "babylonjs/Animations/runtimeAnimation";
  34863. export * from "babylonjs/Animations/animationEvent";
  34864. export * from "babylonjs/Animations/animationGroup";
  34865. export * from "babylonjs/Animations/animationKey";
  34866. export * from "babylonjs/Animations/animationRange";
  34867. }
  34868. declare module "babylonjs/Audio/soundTrack" {
  34869. import { Sound } from "babylonjs/Audio/sound";
  34870. import { Analyser } from "babylonjs/Audio/analyser";
  34871. import { Scene } from "babylonjs/scene";
  34872. /**
  34873. * Options allowed during the creation of a sound track.
  34874. */
  34875. export interface ISoundTrackOptions {
  34876. /**
  34877. * The volume the sound track should take during creation
  34878. */
  34879. volume?: number;
  34880. /**
  34881. * Define if the sound track is the main sound track of the scene
  34882. */
  34883. mainTrack?: boolean;
  34884. }
  34885. /**
  34886. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34887. * It will be also used in a future release to apply effects on a specific track.
  34888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34889. */
  34890. export class SoundTrack {
  34891. /**
  34892. * The unique identifier of the sound track in the scene.
  34893. */
  34894. id: number;
  34895. /**
  34896. * The list of sounds included in the sound track.
  34897. */
  34898. soundCollection: Array<Sound>;
  34899. private _outputAudioNode;
  34900. private _scene;
  34901. private _isMainTrack;
  34902. private _connectedAnalyser;
  34903. private _options;
  34904. private _isInitialized;
  34905. /**
  34906. * Creates a new sound track.
  34907. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34908. * @param scene Define the scene the sound track belongs to
  34909. * @param options
  34910. */
  34911. constructor(scene: Scene, options?: ISoundTrackOptions);
  34912. private _initializeSoundTrackAudioGraph;
  34913. /**
  34914. * Release the sound track and its associated resources
  34915. */
  34916. dispose(): void;
  34917. /**
  34918. * Adds a sound to this sound track
  34919. * @param sound define the cound to add
  34920. * @ignoreNaming
  34921. */
  34922. AddSound(sound: Sound): void;
  34923. /**
  34924. * Removes a sound to this sound track
  34925. * @param sound define the cound to remove
  34926. * @ignoreNaming
  34927. */
  34928. RemoveSound(sound: Sound): void;
  34929. /**
  34930. * Set a global volume for the full sound track.
  34931. * @param newVolume Define the new volume of the sound track
  34932. */
  34933. setVolume(newVolume: number): void;
  34934. /**
  34935. * Switch the panning model to HRTF:
  34936. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34938. */
  34939. switchPanningModelToHRTF(): void;
  34940. /**
  34941. * Switch the panning model to Equal Power:
  34942. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34943. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34944. */
  34945. switchPanningModelToEqualPower(): void;
  34946. /**
  34947. * Connect the sound track to an audio analyser allowing some amazing
  34948. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34949. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34950. * @param analyser The analyser to connect to the engine
  34951. */
  34952. connectToAnalyser(analyser: Analyser): void;
  34953. }
  34954. }
  34955. declare module "babylonjs/Audio/audioSceneComponent" {
  34956. import { Sound } from "babylonjs/Audio/sound";
  34957. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34958. import { Nullable } from "babylonjs/types";
  34959. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34960. import { Scene } from "babylonjs/scene";
  34961. import { AbstractScene } from "babylonjs/abstractScene";
  34962. module "babylonjs/abstractScene" {
  34963. interface AbstractScene {
  34964. /**
  34965. * The list of sounds used in the scene.
  34966. */
  34967. sounds: Nullable<Array<Sound>>;
  34968. }
  34969. }
  34970. module "babylonjs/scene" {
  34971. interface Scene {
  34972. /**
  34973. * @hidden
  34974. * Backing field
  34975. */
  34976. _mainSoundTrack: SoundTrack;
  34977. /**
  34978. * The main sound track played by the scene.
  34979. * It cotains your primary collection of sounds.
  34980. */
  34981. mainSoundTrack: SoundTrack;
  34982. /**
  34983. * The list of sound tracks added to the scene
  34984. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34985. */
  34986. soundTracks: Nullable<Array<SoundTrack>>;
  34987. /**
  34988. * Gets a sound using a given name
  34989. * @param name defines the name to search for
  34990. * @return the found sound or null if not found at all.
  34991. */
  34992. getSoundByName(name: string): Nullable<Sound>;
  34993. /**
  34994. * Gets or sets if audio support is enabled
  34995. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34996. */
  34997. audioEnabled: boolean;
  34998. /**
  34999. * Gets or sets if audio will be output to headphones
  35000. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35001. */
  35002. headphone: boolean;
  35003. }
  35004. }
  35005. /**
  35006. * Defines the sound scene component responsible to manage any sounds
  35007. * in a given scene.
  35008. */
  35009. export class AudioSceneComponent implements ISceneSerializableComponent {
  35010. /**
  35011. * The component name helpfull to identify the component in the list of scene components.
  35012. */
  35013. readonly name: string;
  35014. /**
  35015. * The scene the component belongs to.
  35016. */
  35017. scene: Scene;
  35018. private _audioEnabled;
  35019. /**
  35020. * Gets whether audio is enabled or not.
  35021. * Please use related enable/disable method to switch state.
  35022. */
  35023. readonly audioEnabled: boolean;
  35024. private _headphone;
  35025. /**
  35026. * Gets whether audio is outputing to headphone or not.
  35027. * Please use the according Switch methods to change output.
  35028. */
  35029. readonly headphone: boolean;
  35030. /**
  35031. * Creates a new instance of the component for the given scene
  35032. * @param scene Defines the scene to register the component in
  35033. */
  35034. constructor(scene: Scene);
  35035. /**
  35036. * Registers the component in a given scene
  35037. */
  35038. register(): void;
  35039. /**
  35040. * Rebuilds the elements related to this component in case of
  35041. * context lost for instance.
  35042. */
  35043. rebuild(): void;
  35044. /**
  35045. * Serializes the component data to the specified json object
  35046. * @param serializationObject The object to serialize to
  35047. */
  35048. serialize(serializationObject: any): void;
  35049. /**
  35050. * Adds all the element from the container to the scene
  35051. * @param container the container holding the elements
  35052. */
  35053. addFromContainer(container: AbstractScene): void;
  35054. /**
  35055. * Removes all the elements in the container from the scene
  35056. * @param container contains the elements to remove
  35057. * @param dispose if the removed element should be disposed (default: false)
  35058. */
  35059. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35060. /**
  35061. * Disposes the component and the associated ressources.
  35062. */
  35063. dispose(): void;
  35064. /**
  35065. * Disables audio in the associated scene.
  35066. */
  35067. disableAudio(): void;
  35068. /**
  35069. * Enables audio in the associated scene.
  35070. */
  35071. enableAudio(): void;
  35072. /**
  35073. * Switch audio to headphone output.
  35074. */
  35075. switchAudioModeForHeadphones(): void;
  35076. /**
  35077. * Switch audio to normal speakers.
  35078. */
  35079. switchAudioModeForNormalSpeakers(): void;
  35080. private _afterRender;
  35081. }
  35082. }
  35083. declare module "babylonjs/Audio/weightedsound" {
  35084. import { Sound } from "babylonjs/Audio/sound";
  35085. /**
  35086. * Wraps one or more Sound objects and selects one with random weight for playback.
  35087. */
  35088. export class WeightedSound {
  35089. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35090. loop: boolean;
  35091. private _coneInnerAngle;
  35092. private _coneOuterAngle;
  35093. private _volume;
  35094. /** A Sound is currently playing. */
  35095. isPlaying: boolean;
  35096. /** A Sound is currently paused. */
  35097. isPaused: boolean;
  35098. private _sounds;
  35099. private _weights;
  35100. private _currentIndex?;
  35101. /**
  35102. * Creates a new WeightedSound from the list of sounds given.
  35103. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35104. * @param sounds Array of Sounds that will be selected from.
  35105. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35106. */
  35107. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35108. /**
  35109. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35110. */
  35111. /**
  35112. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35113. */
  35114. directionalConeInnerAngle: number;
  35115. /**
  35116. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35117. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35118. */
  35119. /**
  35120. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35121. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35122. */
  35123. directionalConeOuterAngle: number;
  35124. /**
  35125. * Playback volume.
  35126. */
  35127. /**
  35128. * Playback volume.
  35129. */
  35130. volume: number;
  35131. private _onended;
  35132. /**
  35133. * Suspend playback
  35134. */
  35135. pause(): void;
  35136. /**
  35137. * Stop playback
  35138. */
  35139. stop(): void;
  35140. /**
  35141. * Start playback.
  35142. * @param startOffset Position the clip head at a specific time in seconds.
  35143. */
  35144. play(startOffset?: number): void;
  35145. }
  35146. }
  35147. declare module "babylonjs/Audio/index" {
  35148. export * from "babylonjs/Audio/analyser";
  35149. export * from "babylonjs/Audio/audioEngine";
  35150. export * from "babylonjs/Audio/audioSceneComponent";
  35151. export * from "babylonjs/Audio/sound";
  35152. export * from "babylonjs/Audio/soundTrack";
  35153. export * from "babylonjs/Audio/weightedsound";
  35154. }
  35155. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35156. import { Behavior } from "babylonjs/Behaviors/behavior";
  35157. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35158. import { BackEase } from "babylonjs/Animations/easing";
  35159. /**
  35160. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35161. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35162. */
  35163. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35164. /**
  35165. * Gets the name of the behavior.
  35166. */
  35167. readonly name: string;
  35168. /**
  35169. * The easing function used by animations
  35170. */
  35171. static EasingFunction: BackEase;
  35172. /**
  35173. * The easing mode used by animations
  35174. */
  35175. static EasingMode: number;
  35176. /**
  35177. * The duration of the animation, in milliseconds
  35178. */
  35179. transitionDuration: number;
  35180. /**
  35181. * Length of the distance animated by the transition when lower radius is reached
  35182. */
  35183. lowerRadiusTransitionRange: number;
  35184. /**
  35185. * Length of the distance animated by the transition when upper radius is reached
  35186. */
  35187. upperRadiusTransitionRange: number;
  35188. private _autoTransitionRange;
  35189. /**
  35190. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35191. */
  35192. /**
  35193. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35194. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35195. */
  35196. autoTransitionRange: boolean;
  35197. private _attachedCamera;
  35198. private _onAfterCheckInputsObserver;
  35199. private _onMeshTargetChangedObserver;
  35200. /**
  35201. * Initializes the behavior.
  35202. */
  35203. init(): void;
  35204. /**
  35205. * Attaches the behavior to its arc rotate camera.
  35206. * @param camera Defines the camera to attach the behavior to
  35207. */
  35208. attach(camera: ArcRotateCamera): void;
  35209. /**
  35210. * Detaches the behavior from its current arc rotate camera.
  35211. */
  35212. detach(): void;
  35213. private _radiusIsAnimating;
  35214. private _radiusBounceTransition;
  35215. private _animatables;
  35216. private _cachedWheelPrecision;
  35217. /**
  35218. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35219. * @param radiusLimit The limit to check against.
  35220. * @return Bool to indicate if at limit.
  35221. */
  35222. private _isRadiusAtLimit;
  35223. /**
  35224. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35225. * @param radiusDelta The delta by which to animate to. Can be negative.
  35226. */
  35227. private _applyBoundRadiusAnimation;
  35228. /**
  35229. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35230. */
  35231. protected _clearAnimationLocks(): void;
  35232. /**
  35233. * Stops and removes all animations that have been applied to the camera
  35234. */
  35235. stopAllAnimations(): void;
  35236. }
  35237. }
  35238. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35239. import { Behavior } from "babylonjs/Behaviors/behavior";
  35240. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35241. import { ExponentialEase } from "babylonjs/Animations/easing";
  35242. import { Nullable } from "babylonjs/types";
  35243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35244. import { Vector3 } from "babylonjs/Maths/math";
  35245. /**
  35246. * 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.
  35247. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35248. */
  35249. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35250. /**
  35251. * Gets the name of the behavior.
  35252. */
  35253. readonly name: string;
  35254. private _mode;
  35255. private _radiusScale;
  35256. private _positionScale;
  35257. private _defaultElevation;
  35258. private _elevationReturnTime;
  35259. private _elevationReturnWaitTime;
  35260. private _zoomStopsAnimation;
  35261. private _framingTime;
  35262. /**
  35263. * The easing function used by animations
  35264. */
  35265. static EasingFunction: ExponentialEase;
  35266. /**
  35267. * The easing mode used by animations
  35268. */
  35269. static EasingMode: number;
  35270. /**
  35271. * Sets the current mode used by the behavior
  35272. */
  35273. /**
  35274. * Gets current mode used by the behavior.
  35275. */
  35276. mode: number;
  35277. /**
  35278. * Sets the scale applied to the radius (1 by default)
  35279. */
  35280. /**
  35281. * Gets the scale applied to the radius
  35282. */
  35283. radiusScale: number;
  35284. /**
  35285. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35286. */
  35287. /**
  35288. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35289. */
  35290. positionScale: number;
  35291. /**
  35292. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35293. * behaviour is triggered, in radians.
  35294. */
  35295. /**
  35296. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35297. * behaviour is triggered, in radians.
  35298. */
  35299. defaultElevation: number;
  35300. /**
  35301. * Sets the time (in milliseconds) taken to return to the default beta position.
  35302. * Negative value indicates camera should not return to default.
  35303. */
  35304. /**
  35305. * Gets the time (in milliseconds) taken to return to the default beta position.
  35306. * Negative value indicates camera should not return to default.
  35307. */
  35308. elevationReturnTime: number;
  35309. /**
  35310. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35311. */
  35312. /**
  35313. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35314. */
  35315. elevationReturnWaitTime: number;
  35316. /**
  35317. * Sets the flag that indicates if user zooming should stop animation.
  35318. */
  35319. /**
  35320. * Gets the flag that indicates if user zooming should stop animation.
  35321. */
  35322. zoomStopsAnimation: boolean;
  35323. /**
  35324. * Sets the transition time when framing the mesh, in milliseconds
  35325. */
  35326. /**
  35327. * Gets the transition time when framing the mesh, in milliseconds
  35328. */
  35329. framingTime: number;
  35330. /**
  35331. * Define if the behavior should automatically change the configured
  35332. * camera limits and sensibilities.
  35333. */
  35334. autoCorrectCameraLimitsAndSensibility: boolean;
  35335. private _onPrePointerObservableObserver;
  35336. private _onAfterCheckInputsObserver;
  35337. private _onMeshTargetChangedObserver;
  35338. private _attachedCamera;
  35339. private _isPointerDown;
  35340. private _lastInteractionTime;
  35341. /**
  35342. * Initializes the behavior.
  35343. */
  35344. init(): void;
  35345. /**
  35346. * Attaches the behavior to its arc rotate camera.
  35347. * @param camera Defines the camera to attach the behavior to
  35348. */
  35349. attach(camera: ArcRotateCamera): void;
  35350. /**
  35351. * Detaches the behavior from its current arc rotate camera.
  35352. */
  35353. detach(): void;
  35354. private _animatables;
  35355. private _betaIsAnimating;
  35356. private _betaTransition;
  35357. private _radiusTransition;
  35358. private _vectorTransition;
  35359. /**
  35360. * Targets the given mesh 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. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35368. /**
  35369. * Targets the given mesh with its children and updates zoom level accordingly.
  35370. * @param mesh 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. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35377. /**
  35378. * Targets the given meshes with their children and updates zoom level accordingly.
  35379. * @param meshes The mesh to target.
  35380. * @param radius Optional. If a cached radius position already exists, overrides default.
  35381. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35382. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35383. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35384. */
  35385. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35386. /**
  35387. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35388. * @param minimumWorld Determines the smaller position of the bounding box extend
  35389. * @param maximumWorld Determines the bigger position of the bounding box extend
  35390. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35391. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35392. */
  35393. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35394. /**
  35395. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35396. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35397. * frustum width.
  35398. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35399. * to fully enclose the mesh in the viewing frustum.
  35400. */
  35401. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35402. /**
  35403. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35404. * is automatically returned to its default position (expected to be above ground plane).
  35405. */
  35406. private _maintainCameraAboveGround;
  35407. /**
  35408. * Returns the frustum slope based on the canvas ratio and camera FOV
  35409. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35410. */
  35411. private _getFrustumSlope;
  35412. /**
  35413. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35414. */
  35415. private _clearAnimationLocks;
  35416. /**
  35417. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35418. */
  35419. private _applyUserInteraction;
  35420. /**
  35421. * Stops and removes all animations that have been applied to the camera
  35422. */
  35423. stopAllAnimations(): void;
  35424. /**
  35425. * Gets a value indicating if the user is moving the camera
  35426. */
  35427. readonly isUserIsMoving: boolean;
  35428. /**
  35429. * The camera can move all the way towards the mesh.
  35430. */
  35431. static IgnoreBoundsSizeMode: number;
  35432. /**
  35433. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35434. */
  35435. static FitFrustumSidesMode: number;
  35436. }
  35437. }
  35438. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35439. import { Nullable } from "babylonjs/types";
  35440. import { Camera } from "babylonjs/Cameras/camera";
  35441. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35442. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35443. /**
  35444. * Base class for Camera Pointer Inputs.
  35445. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35446. * for example usage.
  35447. */
  35448. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35449. /**
  35450. * Defines the camera the input is attached to.
  35451. */
  35452. abstract camera: Camera;
  35453. /**
  35454. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35455. */
  35456. protected _altKey: boolean;
  35457. protected _ctrlKey: boolean;
  35458. protected _metaKey: boolean;
  35459. protected _shiftKey: boolean;
  35460. /**
  35461. * Which mouse buttons were pressed at time of last mouse event.
  35462. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35463. */
  35464. protected _buttonsPressed: number;
  35465. /**
  35466. * Defines the buttons associated with the input to handle camera move.
  35467. */
  35468. buttons: number[];
  35469. /**
  35470. * Attach the input controls to a specific dom element to get the input from.
  35471. * @param element Defines the element the controls should be listened from
  35472. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35473. */
  35474. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35475. /**
  35476. * Detach the current controls from the specified dom element.
  35477. * @param element Defines the element to stop listening the inputs from
  35478. */
  35479. detachControl(element: Nullable<HTMLElement>): void;
  35480. /**
  35481. * Gets the class name of the current input.
  35482. * @returns the class name
  35483. */
  35484. getClassName(): string;
  35485. /**
  35486. * Get the friendly name associated with the input class.
  35487. * @returns the input friendly name
  35488. */
  35489. getSimpleName(): string;
  35490. /**
  35491. * Called on pointer POINTERDOUBLETAP event.
  35492. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35493. */
  35494. protected onDoubleTap(type: string): void;
  35495. /**
  35496. * Called on pointer POINTERMOVE event if only a single touch is active.
  35497. * Override this method to provide functionality.
  35498. */
  35499. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35500. /**
  35501. * Called on pointer POINTERMOVE event if multiple touches are active.
  35502. * Override this method to provide functionality.
  35503. */
  35504. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35505. /**
  35506. * Called on JS contextmenu event.
  35507. * Override this method to provide functionality.
  35508. */
  35509. protected onContextMenu(evt: PointerEvent): void;
  35510. /**
  35511. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35512. * press.
  35513. * Override this method to provide functionality.
  35514. */
  35515. protected onButtonDown(evt: PointerEvent): void;
  35516. /**
  35517. * Called each time a new POINTERUP event occurs. Ie, for each button
  35518. * release.
  35519. * Override this method to provide functionality.
  35520. */
  35521. protected onButtonUp(evt: PointerEvent): void;
  35522. /**
  35523. * Called when window becomes inactive.
  35524. * Override this method to provide functionality.
  35525. */
  35526. protected onLostFocus(): void;
  35527. private _pointerInput;
  35528. private _observer;
  35529. private _onLostFocus;
  35530. private pointA;
  35531. private pointB;
  35532. }
  35533. }
  35534. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35535. import { Nullable } from "babylonjs/types";
  35536. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35537. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35538. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35539. /**
  35540. * Manage the pointers inputs to control an arc rotate camera.
  35541. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35542. */
  35543. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35544. /**
  35545. * Defines the camera the input is attached to.
  35546. */
  35547. camera: ArcRotateCamera;
  35548. /**
  35549. * Gets the class name of the current input.
  35550. * @returns the class name
  35551. */
  35552. getClassName(): string;
  35553. /**
  35554. * Defines the buttons associated with the input to handle camera move.
  35555. */
  35556. buttons: number[];
  35557. /**
  35558. * Defines the pointer angular sensibility along the X axis or how fast is
  35559. * the camera rotating.
  35560. */
  35561. angularSensibilityX: number;
  35562. /**
  35563. * Defines the pointer angular sensibility along the Y axis or how fast is
  35564. * the camera rotating.
  35565. */
  35566. angularSensibilityY: number;
  35567. /**
  35568. * Defines the pointer pinch precision or how fast is the camera zooming.
  35569. */
  35570. pinchPrecision: number;
  35571. /**
  35572. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35573. * from 0.
  35574. * It defines the percentage of current camera.radius to use as delta when
  35575. * pinch zoom is used.
  35576. */
  35577. pinchDeltaPercentage: number;
  35578. /**
  35579. * Defines the pointer panning sensibility or how fast is the camera moving.
  35580. */
  35581. panningSensibility: number;
  35582. /**
  35583. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35584. */
  35585. multiTouchPanning: boolean;
  35586. /**
  35587. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35588. * zoom (pinch) through multitouch.
  35589. */
  35590. multiTouchPanAndZoom: boolean;
  35591. /**
  35592. * Revers pinch action direction.
  35593. */
  35594. pinchInwards: boolean;
  35595. private _isPanClick;
  35596. private _twoFingerActivityCount;
  35597. private _isPinching;
  35598. /**
  35599. * Called on pointer POINTERMOVE event if only a single touch is active.
  35600. */
  35601. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35602. /**
  35603. * Called on pointer POINTERDOUBLETAP event.
  35604. */
  35605. protected onDoubleTap(type: string): void;
  35606. /**
  35607. * Called on pointer POINTERMOVE event if multiple touches are active.
  35608. */
  35609. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35610. /**
  35611. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35612. * press.
  35613. */
  35614. protected onButtonDown(evt: PointerEvent): void;
  35615. /**
  35616. * Called each time a new POINTERUP event occurs. Ie, for each button
  35617. * release.
  35618. */
  35619. protected onButtonUp(evt: PointerEvent): void;
  35620. /**
  35621. * Called when window becomes inactive.
  35622. */
  35623. protected onLostFocus(): void;
  35624. }
  35625. }
  35626. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35627. import { Nullable } from "babylonjs/types";
  35628. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35629. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35630. /**
  35631. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35632. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35633. */
  35634. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35635. /**
  35636. * Defines the camera the input is attached to.
  35637. */
  35638. camera: ArcRotateCamera;
  35639. /**
  35640. * Defines the list of key codes associated with the up action (increase alpha)
  35641. */
  35642. keysUp: number[];
  35643. /**
  35644. * Defines the list of key codes associated with the down action (decrease alpha)
  35645. */
  35646. keysDown: number[];
  35647. /**
  35648. * Defines the list of key codes associated with the left action (increase beta)
  35649. */
  35650. keysLeft: number[];
  35651. /**
  35652. * Defines the list of key codes associated with the right action (decrease beta)
  35653. */
  35654. keysRight: number[];
  35655. /**
  35656. * Defines the list of key codes associated with the reset action.
  35657. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35658. */
  35659. keysReset: number[];
  35660. /**
  35661. * Defines the panning sensibility of the inputs.
  35662. * (How fast is the camera paning)
  35663. */
  35664. panningSensibility: number;
  35665. /**
  35666. * Defines the zooming sensibility of the inputs.
  35667. * (How fast is the camera zooming)
  35668. */
  35669. zoomingSensibility: number;
  35670. /**
  35671. * Defines wether maintaining the alt key down switch the movement mode from
  35672. * orientation to zoom.
  35673. */
  35674. useAltToZoom: boolean;
  35675. /**
  35676. * Rotation speed of the camera
  35677. */
  35678. angularSpeed: number;
  35679. private _keys;
  35680. private _ctrlPressed;
  35681. private _altPressed;
  35682. private _onCanvasBlurObserver;
  35683. private _onKeyboardObserver;
  35684. private _engine;
  35685. private _scene;
  35686. /**
  35687. * Attach the input controls to a specific dom element to get the input from.
  35688. * @param element Defines the element the controls should be listened from
  35689. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35690. */
  35691. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35692. /**
  35693. * Detach the current controls from the specified dom element.
  35694. * @param element Defines the element to stop listening the inputs from
  35695. */
  35696. detachControl(element: Nullable<HTMLElement>): void;
  35697. /**
  35698. * Update the current camera state depending on the inputs that have been used this frame.
  35699. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35700. */
  35701. checkInputs(): void;
  35702. /**
  35703. * Gets the class name of the current intput.
  35704. * @returns the class name
  35705. */
  35706. getClassName(): string;
  35707. /**
  35708. * Get the friendly name associated with the input class.
  35709. * @returns the input friendly name
  35710. */
  35711. getSimpleName(): string;
  35712. }
  35713. }
  35714. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35715. import { Nullable } from "babylonjs/types";
  35716. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35717. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35718. /**
  35719. * Manage the mouse wheel inputs to control an arc rotate camera.
  35720. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35721. */
  35722. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35723. /**
  35724. * Defines the camera the input is attached to.
  35725. */
  35726. camera: ArcRotateCamera;
  35727. /**
  35728. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35729. */
  35730. wheelPrecision: number;
  35731. /**
  35732. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35733. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35734. */
  35735. wheelDeltaPercentage: number;
  35736. private _wheel;
  35737. private _observer;
  35738. /**
  35739. * Attach the input controls to a specific dom element to get the input from.
  35740. * @param element Defines the element the controls should be listened from
  35741. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35742. */
  35743. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35744. /**
  35745. * Detach the current controls from the specified dom element.
  35746. * @param element Defines the element to stop listening the inputs from
  35747. */
  35748. detachControl(element: Nullable<HTMLElement>): void;
  35749. /**
  35750. * Gets the class name of the current intput.
  35751. * @returns the class name
  35752. */
  35753. getClassName(): string;
  35754. /**
  35755. * Get the friendly name associated with the input class.
  35756. * @returns the input friendly name
  35757. */
  35758. getSimpleName(): string;
  35759. }
  35760. }
  35761. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35762. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35763. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35764. /**
  35765. * Default Inputs manager for the ArcRotateCamera.
  35766. * It groups all the default supported inputs for ease of use.
  35767. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35768. */
  35769. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35770. /**
  35771. * Instantiates a new ArcRotateCameraInputsManager.
  35772. * @param camera Defines the camera the inputs belong to
  35773. */
  35774. constructor(camera: ArcRotateCamera);
  35775. /**
  35776. * Add mouse wheel input support to the input manager.
  35777. * @returns the current input manager
  35778. */
  35779. addMouseWheel(): ArcRotateCameraInputsManager;
  35780. /**
  35781. * Add pointers input support to the input manager.
  35782. * @returns the current input manager
  35783. */
  35784. addPointers(): ArcRotateCameraInputsManager;
  35785. /**
  35786. * Add keyboard input support to the input manager.
  35787. * @returns the current input manager
  35788. */
  35789. addKeyboard(): ArcRotateCameraInputsManager;
  35790. }
  35791. }
  35792. declare module "babylonjs/Cameras/arcRotateCamera" {
  35793. import { Observable } from "babylonjs/Misc/observable";
  35794. import { Nullable } from "babylonjs/types";
  35795. import { Scene } from "babylonjs/scene";
  35796. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35797. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35798. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35799. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35800. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35801. import { Camera } from "babylonjs/Cameras/camera";
  35802. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35803. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35804. import { Collider } from "babylonjs/Collisions/collider";
  35805. /**
  35806. * This represents an orbital type of camera.
  35807. *
  35808. * 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.
  35809. * 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.
  35810. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35811. */
  35812. export class ArcRotateCamera extends TargetCamera {
  35813. /**
  35814. * Defines the rotation angle of the camera along the longitudinal axis.
  35815. */
  35816. alpha: number;
  35817. /**
  35818. * Defines the rotation angle of the camera along the latitudinal axis.
  35819. */
  35820. beta: number;
  35821. /**
  35822. * Defines the radius of the camera from it s target point.
  35823. */
  35824. radius: number;
  35825. protected _target: Vector3;
  35826. protected _targetHost: Nullable<AbstractMesh>;
  35827. /**
  35828. * Defines the target point of the camera.
  35829. * The camera looks towards it form the radius distance.
  35830. */
  35831. target: Vector3;
  35832. /**
  35833. * Define the current local position of the camera in the scene
  35834. */
  35835. position: Vector3;
  35836. protected _upVector: Vector3;
  35837. protected _upToYMatrix: Matrix;
  35838. protected _YToUpMatrix: Matrix;
  35839. /**
  35840. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35841. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35842. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35843. */
  35844. upVector: Vector3;
  35845. /**
  35846. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35847. */
  35848. setMatUp(): void;
  35849. /**
  35850. * Current inertia value on the longitudinal axis.
  35851. * The bigger this number the longer it will take for the camera to stop.
  35852. */
  35853. inertialAlphaOffset: number;
  35854. /**
  35855. * Current inertia value on the latitudinal axis.
  35856. * The bigger this number the longer it will take for the camera to stop.
  35857. */
  35858. inertialBetaOffset: number;
  35859. /**
  35860. * Current inertia value on the radius axis.
  35861. * The bigger this number the longer it will take for the camera to stop.
  35862. */
  35863. inertialRadiusOffset: number;
  35864. /**
  35865. * Minimum allowed angle on the longitudinal axis.
  35866. * This can help limiting how the Camera is able to move in the scene.
  35867. */
  35868. lowerAlphaLimit: Nullable<number>;
  35869. /**
  35870. * Maximum allowed angle on the longitudinal axis.
  35871. * This can help limiting how the Camera is able to move in the scene.
  35872. */
  35873. upperAlphaLimit: Nullable<number>;
  35874. /**
  35875. * Minimum allowed angle on the latitudinal axis.
  35876. * This can help limiting how the Camera is able to move in the scene.
  35877. */
  35878. lowerBetaLimit: number;
  35879. /**
  35880. * Maximum allowed angle on the latitudinal axis.
  35881. * This can help limiting how the Camera is able to move in the scene.
  35882. */
  35883. upperBetaLimit: number;
  35884. /**
  35885. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35886. * This can help limiting how the Camera is able to move in the scene.
  35887. */
  35888. lowerRadiusLimit: Nullable<number>;
  35889. /**
  35890. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35891. * This can help limiting how the Camera is able to move in the scene.
  35892. */
  35893. upperRadiusLimit: Nullable<number>;
  35894. /**
  35895. * Defines the current inertia value used during panning of the camera along the X axis.
  35896. */
  35897. inertialPanningX: number;
  35898. /**
  35899. * Defines the current inertia value used during panning of the camera along the Y axis.
  35900. */
  35901. inertialPanningY: number;
  35902. /**
  35903. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35904. * Basically if your fingers moves away from more than this distance you will be considered
  35905. * in pinch mode.
  35906. */
  35907. pinchToPanMaxDistance: number;
  35908. /**
  35909. * Defines the maximum distance the camera can pan.
  35910. * This could help keeping the cammera always in your scene.
  35911. */
  35912. panningDistanceLimit: Nullable<number>;
  35913. /**
  35914. * Defines the target of the camera before paning.
  35915. */
  35916. panningOriginTarget: Vector3;
  35917. /**
  35918. * Defines the value of the inertia used during panning.
  35919. * 0 would mean stop inertia and one would mean no decelleration at all.
  35920. */
  35921. panningInertia: number;
  35922. /**
  35923. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35924. */
  35925. angularSensibilityX: number;
  35926. /**
  35927. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35928. */
  35929. angularSensibilityY: number;
  35930. /**
  35931. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35932. */
  35933. pinchPrecision: number;
  35934. /**
  35935. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35936. * It will be used instead of pinchDeltaPrecision if different from 0.
  35937. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35938. */
  35939. pinchDeltaPercentage: number;
  35940. /**
  35941. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35942. */
  35943. panningSensibility: number;
  35944. /**
  35945. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35946. */
  35947. keysUp: number[];
  35948. /**
  35949. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35950. */
  35951. keysDown: number[];
  35952. /**
  35953. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35954. */
  35955. keysLeft: number[];
  35956. /**
  35957. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35958. */
  35959. keysRight: number[];
  35960. /**
  35961. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35962. */
  35963. wheelPrecision: number;
  35964. /**
  35965. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35966. * It will be used instead of pinchDeltaPrecision if different from 0.
  35967. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35968. */
  35969. wheelDeltaPercentage: number;
  35970. /**
  35971. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35972. */
  35973. zoomOnFactor: number;
  35974. /**
  35975. * Defines a screen offset for the camera position.
  35976. */
  35977. targetScreenOffset: Vector2;
  35978. /**
  35979. * Allows the camera to be completely reversed.
  35980. * If false the camera can not arrive upside down.
  35981. */
  35982. allowUpsideDown: boolean;
  35983. /**
  35984. * Define if double tap/click is used to restore the previously saved state of the camera.
  35985. */
  35986. useInputToRestoreState: boolean;
  35987. /** @hidden */
  35988. _viewMatrix: Matrix;
  35989. /** @hidden */
  35990. _useCtrlForPanning: boolean;
  35991. /** @hidden */
  35992. _panningMouseButton: number;
  35993. /**
  35994. * Defines the input associated to the camera.
  35995. */
  35996. inputs: ArcRotateCameraInputsManager;
  35997. /** @hidden */
  35998. _reset: () => void;
  35999. /**
  36000. * Defines the allowed panning axis.
  36001. */
  36002. panningAxis: Vector3;
  36003. protected _localDirection: Vector3;
  36004. protected _transformedDirection: Vector3;
  36005. private _bouncingBehavior;
  36006. /**
  36007. * Gets the bouncing behavior of the camera if it has been enabled.
  36008. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36009. */
  36010. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36011. /**
  36012. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36013. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36014. */
  36015. useBouncingBehavior: boolean;
  36016. private _framingBehavior;
  36017. /**
  36018. * Gets the framing behavior of the camera if it has been enabled.
  36019. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36020. */
  36021. readonly framingBehavior: Nullable<FramingBehavior>;
  36022. /**
  36023. * Defines if the framing behavior of the camera is enabled on the camera.
  36024. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36025. */
  36026. useFramingBehavior: boolean;
  36027. private _autoRotationBehavior;
  36028. /**
  36029. * Gets the auto rotation behavior of the camera if it has been enabled.
  36030. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36031. */
  36032. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36033. /**
  36034. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36035. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36036. */
  36037. useAutoRotationBehavior: boolean;
  36038. /**
  36039. * Observable triggered when the mesh target has been changed on the camera.
  36040. */
  36041. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36042. /**
  36043. * Event raised when the camera is colliding with a mesh.
  36044. */
  36045. onCollide: (collidedMesh: AbstractMesh) => void;
  36046. /**
  36047. * Defines whether the camera should check collision with the objects oh the scene.
  36048. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36049. */
  36050. checkCollisions: boolean;
  36051. /**
  36052. * Defines the collision radius of the camera.
  36053. * This simulates a sphere around the camera.
  36054. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36055. */
  36056. collisionRadius: Vector3;
  36057. protected _collider: Collider;
  36058. protected _previousPosition: Vector3;
  36059. protected _collisionVelocity: Vector3;
  36060. protected _newPosition: Vector3;
  36061. protected _previousAlpha: number;
  36062. protected _previousBeta: number;
  36063. protected _previousRadius: number;
  36064. protected _collisionTriggered: boolean;
  36065. protected _targetBoundingCenter: Nullable<Vector3>;
  36066. private _computationVector;
  36067. /**
  36068. * Instantiates a new ArcRotateCamera in a given scene
  36069. * @param name Defines the name of the camera
  36070. * @param alpha Defines the camera rotation along the logitudinal axis
  36071. * @param beta Defines the camera rotation along the latitudinal axis
  36072. * @param radius Defines the camera distance from its target
  36073. * @param target Defines the camera target
  36074. * @param scene Defines the scene the camera belongs to
  36075. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36076. */
  36077. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36078. /** @hidden */
  36079. _initCache(): void;
  36080. /** @hidden */
  36081. _updateCache(ignoreParentClass?: boolean): void;
  36082. protected _getTargetPosition(): Vector3;
  36083. private _storedAlpha;
  36084. private _storedBeta;
  36085. private _storedRadius;
  36086. private _storedTarget;
  36087. /**
  36088. * Stores the current state of the camera (alpha, beta, radius and target)
  36089. * @returns the camera itself
  36090. */
  36091. storeState(): Camera;
  36092. /**
  36093. * @hidden
  36094. * Restored camera state. You must call storeState() first
  36095. */
  36096. _restoreStateValues(): boolean;
  36097. /** @hidden */
  36098. _isSynchronizedViewMatrix(): boolean;
  36099. /**
  36100. * Attached controls to the current camera.
  36101. * @param element Defines the element the controls should be listened from
  36102. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36103. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36104. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36105. */
  36106. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36107. /**
  36108. * Detach the current controls from the camera.
  36109. * The camera will stop reacting to inputs.
  36110. * @param element Defines the element to stop listening the inputs from
  36111. */
  36112. detachControl(element: HTMLElement): void;
  36113. /** @hidden */
  36114. _checkInputs(): void;
  36115. protected _checkLimits(): void;
  36116. /**
  36117. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36118. */
  36119. rebuildAnglesAndRadius(): void;
  36120. /**
  36121. * Use a position to define the current camera related information like aplha, beta and radius
  36122. * @param position Defines the position to set the camera at
  36123. */
  36124. setPosition(position: Vector3): void;
  36125. /**
  36126. * Defines the target the camera should look at.
  36127. * This will automatically adapt alpha beta and radius to fit within the new target.
  36128. * @param target Defines the new target as a Vector or a mesh
  36129. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36130. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36131. */
  36132. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36133. /** @hidden */
  36134. _getViewMatrix(): Matrix;
  36135. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36136. /**
  36137. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36138. * @param meshes Defines the mesh to zoom on
  36139. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  36140. */
  36141. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36142. /**
  36143. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36144. * The target will be changed but the radius
  36145. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36146. * @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)
  36147. */
  36148. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36149. min: Vector3;
  36150. max: Vector3;
  36151. distance: number;
  36152. }, doNotUpdateMaxZ?: boolean): void;
  36153. /**
  36154. * @override
  36155. * Override Camera.createRigCamera
  36156. */
  36157. createRigCamera(name: string, cameraIndex: number): Camera;
  36158. /**
  36159. * @hidden
  36160. * @override
  36161. * Override Camera._updateRigCameras
  36162. */
  36163. _updateRigCameras(): void;
  36164. /**
  36165. * Destroy the camera and release the current resources hold by it.
  36166. */
  36167. dispose(): void;
  36168. /**
  36169. * Gets the current object class name.
  36170. * @return the class name
  36171. */
  36172. getClassName(): string;
  36173. }
  36174. }
  36175. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36176. import { Behavior } from "babylonjs/Behaviors/behavior";
  36177. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36178. /**
  36179. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36180. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36181. */
  36182. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36183. /**
  36184. * Gets the name of the behavior.
  36185. */
  36186. readonly name: string;
  36187. private _zoomStopsAnimation;
  36188. private _idleRotationSpeed;
  36189. private _idleRotationWaitTime;
  36190. private _idleRotationSpinupTime;
  36191. /**
  36192. * Sets the flag that indicates if user zooming should stop animation.
  36193. */
  36194. /**
  36195. * Gets the flag that indicates if user zooming should stop animation.
  36196. */
  36197. zoomStopsAnimation: boolean;
  36198. /**
  36199. * Sets the default speed at which the camera rotates around the model.
  36200. */
  36201. /**
  36202. * Gets the default speed at which the camera rotates around the model.
  36203. */
  36204. idleRotationSpeed: number;
  36205. /**
  36206. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36207. */
  36208. /**
  36209. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36210. */
  36211. idleRotationWaitTime: number;
  36212. /**
  36213. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36214. */
  36215. /**
  36216. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36217. */
  36218. idleRotationSpinupTime: number;
  36219. /**
  36220. * Gets a value indicating if the camera is currently rotating because of this behavior
  36221. */
  36222. readonly rotationInProgress: boolean;
  36223. private _onPrePointerObservableObserver;
  36224. private _onAfterCheckInputsObserver;
  36225. private _attachedCamera;
  36226. private _isPointerDown;
  36227. private _lastFrameTime;
  36228. private _lastInteractionTime;
  36229. private _cameraRotationSpeed;
  36230. /**
  36231. * Initializes the behavior.
  36232. */
  36233. init(): void;
  36234. /**
  36235. * Attaches the behavior to its arc rotate camera.
  36236. * @param camera Defines the camera to attach the behavior to
  36237. */
  36238. attach(camera: ArcRotateCamera): void;
  36239. /**
  36240. * Detaches the behavior from its current arc rotate camera.
  36241. */
  36242. detach(): void;
  36243. /**
  36244. * Returns true if user is scrolling.
  36245. * @return true if user is scrolling.
  36246. */
  36247. private _userIsZooming;
  36248. private _lastFrameRadius;
  36249. private _shouldAnimationStopForInteraction;
  36250. /**
  36251. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36252. */
  36253. private _applyUserInteraction;
  36254. private _userIsMoving;
  36255. }
  36256. }
  36257. declare module "babylonjs/Behaviors/Cameras/index" {
  36258. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36259. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36260. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36261. }
  36262. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36263. import { Mesh } from "babylonjs/Meshes/mesh";
  36264. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36265. import { Behavior } from "babylonjs/Behaviors/behavior";
  36266. /**
  36267. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36268. */
  36269. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36270. private ui;
  36271. /**
  36272. * The name of the behavior
  36273. */
  36274. name: string;
  36275. /**
  36276. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36277. */
  36278. distanceAwayFromFace: number;
  36279. /**
  36280. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36281. */
  36282. distanceAwayFromBottomOfFace: number;
  36283. private _faceVectors;
  36284. private _target;
  36285. private _scene;
  36286. private _onRenderObserver;
  36287. private _tmpMatrix;
  36288. private _tmpVector;
  36289. /**
  36290. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36291. * @param ui The transform node that should be attched to the mesh
  36292. */
  36293. constructor(ui: TransformNode);
  36294. /**
  36295. * Initializes the behavior
  36296. */
  36297. init(): void;
  36298. private _closestFace;
  36299. private _zeroVector;
  36300. private _lookAtTmpMatrix;
  36301. private _lookAtToRef;
  36302. /**
  36303. * Attaches the AttachToBoxBehavior to the passed in mesh
  36304. * @param target The mesh that the specified node will be attached to
  36305. */
  36306. attach(target: Mesh): void;
  36307. /**
  36308. * Detaches the behavior from the mesh
  36309. */
  36310. detach(): void;
  36311. }
  36312. }
  36313. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36314. import { Behavior } from "babylonjs/Behaviors/behavior";
  36315. import { Mesh } from "babylonjs/Meshes/mesh";
  36316. /**
  36317. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36318. */
  36319. export class FadeInOutBehavior implements Behavior<Mesh> {
  36320. /**
  36321. * Time in milliseconds to delay before fading in (Default: 0)
  36322. */
  36323. delay: number;
  36324. /**
  36325. * Time in milliseconds for the mesh to fade in (Default: 300)
  36326. */
  36327. fadeInTime: number;
  36328. private _millisecondsPerFrame;
  36329. private _hovered;
  36330. private _hoverValue;
  36331. private _ownerNode;
  36332. /**
  36333. * Instatiates the FadeInOutBehavior
  36334. */
  36335. constructor();
  36336. /**
  36337. * The name of the behavior
  36338. */
  36339. readonly name: string;
  36340. /**
  36341. * Initializes the behavior
  36342. */
  36343. init(): void;
  36344. /**
  36345. * Attaches the fade behavior on the passed in mesh
  36346. * @param ownerNode The mesh that will be faded in/out once attached
  36347. */
  36348. attach(ownerNode: Mesh): void;
  36349. /**
  36350. * Detaches the behavior from the mesh
  36351. */
  36352. detach(): void;
  36353. /**
  36354. * Triggers the mesh to begin fading in or out
  36355. * @param value if the object should fade in or out (true to fade in)
  36356. */
  36357. fadeIn(value: boolean): void;
  36358. private _update;
  36359. private _setAllVisibility;
  36360. }
  36361. }
  36362. declare module "babylonjs/Misc/pivotTools" {
  36363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36364. /**
  36365. * Class containing a set of static utilities functions for managing Pivots
  36366. * @hidden
  36367. */
  36368. export class PivotTools {
  36369. private static _PivotCached;
  36370. private static _OldPivotPoint;
  36371. private static _PivotTranslation;
  36372. private static _PivotTmpVector;
  36373. /** @hidden */
  36374. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36375. /** @hidden */
  36376. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36377. }
  36378. }
  36379. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36380. import { Scene } from "babylonjs/scene";
  36381. import { Vector4, Plane } from "babylonjs/Maths/math";
  36382. import { Mesh } from "babylonjs/Meshes/mesh";
  36383. import { Nullable } from "babylonjs/types";
  36384. /**
  36385. * Class containing static functions to help procedurally build meshes
  36386. */
  36387. export class PlaneBuilder {
  36388. /**
  36389. * Creates a plane mesh
  36390. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36391. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36392. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36393. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36394. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36396. * @param name defines the name of the mesh
  36397. * @param options defines the options used to create the mesh
  36398. * @param scene defines the hosting scene
  36399. * @returns the plane mesh
  36400. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36401. */
  36402. static CreatePlane(name: string, options: {
  36403. size?: number;
  36404. width?: number;
  36405. height?: number;
  36406. sideOrientation?: number;
  36407. frontUVs?: Vector4;
  36408. backUVs?: Vector4;
  36409. updatable?: boolean;
  36410. sourcePlane?: Plane;
  36411. }, scene?: Nullable<Scene>): Mesh;
  36412. }
  36413. }
  36414. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36415. import { Behavior } from "babylonjs/Behaviors/behavior";
  36416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36417. import { Observable } from "babylonjs/Misc/observable";
  36418. import { Vector3 } from "babylonjs/Maths/math";
  36419. import { Ray } from "babylonjs/Culling/ray";
  36420. import "babylonjs/Meshes/Builders/planeBuilder";
  36421. /**
  36422. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36423. */
  36424. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36425. private static _AnyMouseID;
  36426. private _attachedNode;
  36427. private _dragPlane;
  36428. private _scene;
  36429. private _pointerObserver;
  36430. private _beforeRenderObserver;
  36431. private static _planeScene;
  36432. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36433. /**
  36434. * 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)
  36435. */
  36436. maxDragAngle: number;
  36437. /**
  36438. * @hidden
  36439. */
  36440. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36441. /**
  36442. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36443. */
  36444. currentDraggingPointerID: number;
  36445. /**
  36446. * The last position where the pointer hit the drag plane in world space
  36447. */
  36448. lastDragPosition: Vector3;
  36449. /**
  36450. * If the behavior is currently in a dragging state
  36451. */
  36452. dragging: boolean;
  36453. /**
  36454. * 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)
  36455. */
  36456. dragDeltaRatio: number;
  36457. /**
  36458. * If the drag plane orientation should be updated during the dragging (Default: true)
  36459. */
  36460. updateDragPlane: boolean;
  36461. private _debugMode;
  36462. private _moving;
  36463. /**
  36464. * Fires each time the attached mesh is dragged with the pointer
  36465. * * delta between last drag position and current drag position in world space
  36466. * * dragDistance along the drag axis
  36467. * * dragPlaneNormal normal of the current drag plane used during the drag
  36468. * * dragPlanePoint in world space where the drag intersects the drag plane
  36469. */
  36470. onDragObservable: Observable<{
  36471. delta: Vector3;
  36472. dragPlanePoint: Vector3;
  36473. dragPlaneNormal: Vector3;
  36474. dragDistance: number;
  36475. pointerId: number;
  36476. }>;
  36477. /**
  36478. * Fires each time a drag begins (eg. mouse down on mesh)
  36479. */
  36480. onDragStartObservable: Observable<{
  36481. dragPlanePoint: Vector3;
  36482. pointerId: number;
  36483. }>;
  36484. /**
  36485. * Fires each time a drag ends (eg. mouse release after drag)
  36486. */
  36487. onDragEndObservable: Observable<{
  36488. dragPlanePoint: Vector3;
  36489. pointerId: number;
  36490. }>;
  36491. /**
  36492. * If the attached mesh should be moved when dragged
  36493. */
  36494. moveAttached: boolean;
  36495. /**
  36496. * If the drag behavior will react to drag events (Default: true)
  36497. */
  36498. enabled: boolean;
  36499. /**
  36500. * If camera controls should be detached during the drag
  36501. */
  36502. detachCameraControls: boolean;
  36503. /**
  36504. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36505. */
  36506. useObjectOrienationForDragging: boolean;
  36507. private _options;
  36508. /**
  36509. * Creates a pointer drag behavior that can be attached to a mesh
  36510. * @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)
  36511. */
  36512. constructor(options?: {
  36513. dragAxis?: Vector3;
  36514. dragPlaneNormal?: Vector3;
  36515. });
  36516. /**
  36517. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36518. */
  36519. validateDrag: (targetPosition: Vector3) => boolean;
  36520. /**
  36521. * The name of the behavior
  36522. */
  36523. readonly name: string;
  36524. /**
  36525. * Initializes the behavior
  36526. */
  36527. init(): void;
  36528. private _tmpVector;
  36529. private _alternatePickedPoint;
  36530. private _worldDragAxis;
  36531. private _targetPosition;
  36532. private _attachedElement;
  36533. /**
  36534. * Attaches the drag behavior the passed in mesh
  36535. * @param ownerNode The mesh that will be dragged around once attached
  36536. */
  36537. attach(ownerNode: AbstractMesh): void;
  36538. /**
  36539. * Force relase the drag action by code.
  36540. */
  36541. releaseDrag(): void;
  36542. private _startDragRay;
  36543. private _lastPointerRay;
  36544. /**
  36545. * Simulates the start of a pointer drag event on the behavior
  36546. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36547. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36548. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36549. */
  36550. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36551. private _startDrag;
  36552. private _dragDelta;
  36553. private _moveDrag;
  36554. private _pickWithRayOnDragPlane;
  36555. private _pointA;
  36556. private _pointB;
  36557. private _pointC;
  36558. private _lineA;
  36559. private _lineB;
  36560. private _localAxis;
  36561. private _lookAt;
  36562. private _updateDragPlanePosition;
  36563. /**
  36564. * Detaches the behavior from the mesh
  36565. */
  36566. detach(): void;
  36567. }
  36568. }
  36569. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36570. import { Mesh } from "babylonjs/Meshes/mesh";
  36571. import { Behavior } from "babylonjs/Behaviors/behavior";
  36572. /**
  36573. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36574. */
  36575. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36576. private _dragBehaviorA;
  36577. private _dragBehaviorB;
  36578. private _startDistance;
  36579. private _initialScale;
  36580. private _targetScale;
  36581. private _ownerNode;
  36582. private _sceneRenderObserver;
  36583. /**
  36584. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36585. */
  36586. constructor();
  36587. /**
  36588. * The name of the behavior
  36589. */
  36590. readonly name: string;
  36591. /**
  36592. * Initializes the behavior
  36593. */
  36594. init(): void;
  36595. private _getCurrentDistance;
  36596. /**
  36597. * Attaches the scale behavior the passed in mesh
  36598. * @param ownerNode The mesh that will be scaled around once attached
  36599. */
  36600. attach(ownerNode: Mesh): void;
  36601. /**
  36602. * Detaches the behavior from the mesh
  36603. */
  36604. detach(): void;
  36605. }
  36606. }
  36607. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36608. import { Behavior } from "babylonjs/Behaviors/behavior";
  36609. import { Mesh } from "babylonjs/Meshes/mesh";
  36610. import { Observable } from "babylonjs/Misc/observable";
  36611. /**
  36612. * 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
  36613. */
  36614. export class SixDofDragBehavior implements Behavior<Mesh> {
  36615. private static _virtualScene;
  36616. private _ownerNode;
  36617. private _sceneRenderObserver;
  36618. private _scene;
  36619. private _targetPosition;
  36620. private _virtualOriginMesh;
  36621. private _virtualDragMesh;
  36622. private _pointerObserver;
  36623. private _moving;
  36624. private _startingOrientation;
  36625. /**
  36626. * 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)
  36627. */
  36628. private zDragFactor;
  36629. /**
  36630. * If the object should rotate to face the drag origin
  36631. */
  36632. rotateDraggedObject: boolean;
  36633. /**
  36634. * If the behavior is currently in a dragging state
  36635. */
  36636. dragging: boolean;
  36637. /**
  36638. * 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)
  36639. */
  36640. dragDeltaRatio: number;
  36641. /**
  36642. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36643. */
  36644. currentDraggingPointerID: number;
  36645. /**
  36646. * If camera controls should be detached during the drag
  36647. */
  36648. detachCameraControls: boolean;
  36649. /**
  36650. * Fires each time a drag starts
  36651. */
  36652. onDragStartObservable: Observable<{}>;
  36653. /**
  36654. * Fires each time a drag ends (eg. mouse release after drag)
  36655. */
  36656. onDragEndObservable: Observable<{}>;
  36657. /**
  36658. * 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
  36659. */
  36660. constructor();
  36661. /**
  36662. * The name of the behavior
  36663. */
  36664. readonly name: string;
  36665. /**
  36666. * Initializes the behavior
  36667. */
  36668. init(): void;
  36669. /**
  36670. * Attaches the scale behavior the passed in mesh
  36671. * @param ownerNode The mesh that will be scaled around once attached
  36672. */
  36673. attach(ownerNode: Mesh): void;
  36674. /**
  36675. * Detaches the behavior from the mesh
  36676. */
  36677. detach(): void;
  36678. }
  36679. }
  36680. declare module "babylonjs/Behaviors/Meshes/index" {
  36681. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36682. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36683. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36684. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36685. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36686. }
  36687. declare module "babylonjs/Behaviors/index" {
  36688. export * from "babylonjs/Behaviors/behavior";
  36689. export * from "babylonjs/Behaviors/Cameras/index";
  36690. export * from "babylonjs/Behaviors/Meshes/index";
  36691. }
  36692. declare module "babylonjs/Bones/boneIKController" {
  36693. import { Bone } from "babylonjs/Bones/bone";
  36694. import { Vector3 } from "babylonjs/Maths/math";
  36695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36696. import { Nullable } from "babylonjs/types";
  36697. /**
  36698. * Class used to apply inverse kinematics to bones
  36699. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36700. */
  36701. export class BoneIKController {
  36702. private static _tmpVecs;
  36703. private static _tmpQuat;
  36704. private static _tmpMats;
  36705. /**
  36706. * Gets or sets the target mesh
  36707. */
  36708. targetMesh: AbstractMesh;
  36709. /** Gets or sets the mesh used as pole */
  36710. poleTargetMesh: AbstractMesh;
  36711. /**
  36712. * Gets or sets the bone used as pole
  36713. */
  36714. poleTargetBone: Nullable<Bone>;
  36715. /**
  36716. * Gets or sets the target position
  36717. */
  36718. targetPosition: Vector3;
  36719. /**
  36720. * Gets or sets the pole target position
  36721. */
  36722. poleTargetPosition: Vector3;
  36723. /**
  36724. * Gets or sets the pole target local offset
  36725. */
  36726. poleTargetLocalOffset: Vector3;
  36727. /**
  36728. * Gets or sets the pole angle
  36729. */
  36730. poleAngle: number;
  36731. /**
  36732. * Gets or sets the mesh associated with the controller
  36733. */
  36734. mesh: AbstractMesh;
  36735. /**
  36736. * 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)
  36737. */
  36738. slerpAmount: number;
  36739. private _bone1Quat;
  36740. private _bone1Mat;
  36741. private _bone2Ang;
  36742. private _bone1;
  36743. private _bone2;
  36744. private _bone1Length;
  36745. private _bone2Length;
  36746. private _maxAngle;
  36747. private _maxReach;
  36748. private _rightHandedSystem;
  36749. private _bendAxis;
  36750. private _slerping;
  36751. private _adjustRoll;
  36752. /**
  36753. * Gets or sets maximum allowed angle
  36754. */
  36755. maxAngle: number;
  36756. /**
  36757. * Creates a new BoneIKController
  36758. * @param mesh defines the mesh to control
  36759. * @param bone defines the bone to control
  36760. * @param options defines options to set up the controller
  36761. */
  36762. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36763. targetMesh?: AbstractMesh;
  36764. poleTargetMesh?: AbstractMesh;
  36765. poleTargetBone?: Bone;
  36766. poleTargetLocalOffset?: Vector3;
  36767. poleAngle?: number;
  36768. bendAxis?: Vector3;
  36769. maxAngle?: number;
  36770. slerpAmount?: number;
  36771. });
  36772. private _setMaxAngle;
  36773. /**
  36774. * Force the controller to update the bones
  36775. */
  36776. update(): void;
  36777. }
  36778. }
  36779. declare module "babylonjs/Bones/boneLookController" {
  36780. import { Vector3, Space } from "babylonjs/Maths/math";
  36781. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36782. import { Bone } from "babylonjs/Bones/bone";
  36783. /**
  36784. * Class used to make a bone look toward a point in space
  36785. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36786. */
  36787. export class BoneLookController {
  36788. private static _tmpVecs;
  36789. private static _tmpQuat;
  36790. private static _tmpMats;
  36791. /**
  36792. * The target Vector3 that the bone will look at
  36793. */
  36794. target: Vector3;
  36795. /**
  36796. * The mesh that the bone is attached to
  36797. */
  36798. mesh: AbstractMesh;
  36799. /**
  36800. * The bone that will be looking to the target
  36801. */
  36802. bone: Bone;
  36803. /**
  36804. * The up axis of the coordinate system that is used when the bone is rotated
  36805. */
  36806. upAxis: Vector3;
  36807. /**
  36808. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36809. */
  36810. upAxisSpace: Space;
  36811. /**
  36812. * Used to make an adjustment to the yaw of the bone
  36813. */
  36814. adjustYaw: number;
  36815. /**
  36816. * Used to make an adjustment to the pitch of the bone
  36817. */
  36818. adjustPitch: number;
  36819. /**
  36820. * Used to make an adjustment to the roll of the bone
  36821. */
  36822. adjustRoll: number;
  36823. /**
  36824. * 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)
  36825. */
  36826. slerpAmount: number;
  36827. private _minYaw;
  36828. private _maxYaw;
  36829. private _minPitch;
  36830. private _maxPitch;
  36831. private _minYawSin;
  36832. private _minYawCos;
  36833. private _maxYawSin;
  36834. private _maxYawCos;
  36835. private _midYawConstraint;
  36836. private _minPitchTan;
  36837. private _maxPitchTan;
  36838. private _boneQuat;
  36839. private _slerping;
  36840. private _transformYawPitch;
  36841. private _transformYawPitchInv;
  36842. private _firstFrameSkipped;
  36843. private _yawRange;
  36844. private _fowardAxis;
  36845. /**
  36846. * Gets or sets the minimum yaw angle that the bone can look to
  36847. */
  36848. minYaw: number;
  36849. /**
  36850. * Gets or sets the maximum yaw angle that the bone can look to
  36851. */
  36852. maxYaw: number;
  36853. /**
  36854. * Gets or sets the minimum pitch angle that the bone can look to
  36855. */
  36856. minPitch: number;
  36857. /**
  36858. * Gets or sets the maximum pitch angle that the bone can look to
  36859. */
  36860. maxPitch: number;
  36861. /**
  36862. * Create a BoneLookController
  36863. * @param mesh the mesh that the bone belongs to
  36864. * @param bone the bone that will be looking to the target
  36865. * @param target the target Vector3 to look at
  36866. * @param options optional settings:
  36867. * * maxYaw: the maximum angle the bone will yaw to
  36868. * * minYaw: the minimum angle the bone will yaw to
  36869. * * maxPitch: the maximum angle the bone will pitch to
  36870. * * minPitch: the minimum angle the bone will yaw to
  36871. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36872. * * upAxis: the up axis of the coordinate system
  36873. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36874. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36875. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36876. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36877. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36878. * * adjustRoll: used to make an adjustment to the roll of the bone
  36879. **/
  36880. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36881. maxYaw?: number;
  36882. minYaw?: number;
  36883. maxPitch?: number;
  36884. minPitch?: number;
  36885. slerpAmount?: number;
  36886. upAxis?: Vector3;
  36887. upAxisSpace?: Space;
  36888. yawAxis?: Vector3;
  36889. pitchAxis?: Vector3;
  36890. adjustYaw?: number;
  36891. adjustPitch?: number;
  36892. adjustRoll?: number;
  36893. });
  36894. /**
  36895. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36896. */
  36897. update(): void;
  36898. private _getAngleDiff;
  36899. private _getAngleBetween;
  36900. private _isAngleBetween;
  36901. }
  36902. }
  36903. declare module "babylonjs/Bones/index" {
  36904. export * from "babylonjs/Bones/bone";
  36905. export * from "babylonjs/Bones/boneIKController";
  36906. export * from "babylonjs/Bones/boneLookController";
  36907. export * from "babylonjs/Bones/skeleton";
  36908. }
  36909. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36910. import { Nullable } from "babylonjs/types";
  36911. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36912. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36913. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36914. /**
  36915. * Manage the gamepad inputs to control an arc rotate camera.
  36916. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36917. */
  36918. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36919. /**
  36920. * Defines the camera the input is attached to.
  36921. */
  36922. camera: ArcRotateCamera;
  36923. /**
  36924. * Defines the gamepad the input is gathering event from.
  36925. */
  36926. gamepad: Nullable<Gamepad>;
  36927. /**
  36928. * Defines the gamepad rotation sensiblity.
  36929. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36930. */
  36931. gamepadRotationSensibility: number;
  36932. /**
  36933. * Defines the gamepad move sensiblity.
  36934. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36935. */
  36936. gamepadMoveSensibility: number;
  36937. private _onGamepadConnectedObserver;
  36938. private _onGamepadDisconnectedObserver;
  36939. /**
  36940. * Attach the input controls to a specific dom element to get the input from.
  36941. * @param element Defines the element the controls should be listened from
  36942. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36943. */
  36944. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36945. /**
  36946. * Detach the current controls from the specified dom element.
  36947. * @param element Defines the element to stop listening the inputs from
  36948. */
  36949. detachControl(element: Nullable<HTMLElement>): void;
  36950. /**
  36951. * Update the current camera state depending on the inputs that have been used this frame.
  36952. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36953. */
  36954. checkInputs(): void;
  36955. /**
  36956. * Gets the class name of the current intput.
  36957. * @returns the class name
  36958. */
  36959. getClassName(): string;
  36960. /**
  36961. * Get the friendly name associated with the input class.
  36962. * @returns the input friendly name
  36963. */
  36964. getSimpleName(): string;
  36965. }
  36966. }
  36967. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36968. import { Nullable } from "babylonjs/types";
  36969. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36970. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36971. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36972. interface ArcRotateCameraInputsManager {
  36973. /**
  36974. * Add orientation input support to the input manager.
  36975. * @returns the current input manager
  36976. */
  36977. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36978. }
  36979. }
  36980. /**
  36981. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36982. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36983. */
  36984. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36985. /**
  36986. * Defines the camera the input is attached to.
  36987. */
  36988. camera: ArcRotateCamera;
  36989. /**
  36990. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36991. */
  36992. alphaCorrection: number;
  36993. /**
  36994. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36995. */
  36996. gammaCorrection: number;
  36997. private _alpha;
  36998. private _gamma;
  36999. private _dirty;
  37000. private _deviceOrientationHandler;
  37001. /**
  37002. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37003. */
  37004. constructor();
  37005. /**
  37006. * Attach the input controls to a specific dom element to get the input from.
  37007. * @param element Defines the element the controls should be listened from
  37008. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37009. */
  37010. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37011. /** @hidden */
  37012. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37013. /**
  37014. * Update the current camera state depending on the inputs that have been used this frame.
  37015. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37016. */
  37017. checkInputs(): void;
  37018. /**
  37019. * Detach the current controls from the specified dom element.
  37020. * @param element Defines the element to stop listening the inputs from
  37021. */
  37022. detachControl(element: Nullable<HTMLElement>): void;
  37023. /**
  37024. * Gets the class name of the current intput.
  37025. * @returns the class name
  37026. */
  37027. getClassName(): string;
  37028. /**
  37029. * Get the friendly name associated with the input class.
  37030. * @returns the input friendly name
  37031. */
  37032. getSimpleName(): string;
  37033. }
  37034. }
  37035. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37036. import { Nullable } from "babylonjs/types";
  37037. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37038. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37039. /**
  37040. * Listen to mouse events to control the camera.
  37041. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37042. */
  37043. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37044. /**
  37045. * Defines the camera the input is attached to.
  37046. */
  37047. camera: FlyCamera;
  37048. /**
  37049. * Defines if touch is enabled. (Default is true.)
  37050. */
  37051. touchEnabled: boolean;
  37052. /**
  37053. * Defines the buttons associated with the input to handle camera rotation.
  37054. */
  37055. buttons: number[];
  37056. /**
  37057. * Assign buttons for Yaw control.
  37058. */
  37059. buttonsYaw: number[];
  37060. /**
  37061. * Assign buttons for Pitch control.
  37062. */
  37063. buttonsPitch: number[];
  37064. /**
  37065. * Assign buttons for Roll control.
  37066. */
  37067. buttonsRoll: number[];
  37068. /**
  37069. * Detect if any button is being pressed while mouse is moved.
  37070. * -1 = Mouse locked.
  37071. * 0 = Left button.
  37072. * 1 = Middle Button.
  37073. * 2 = Right Button.
  37074. */
  37075. activeButton: number;
  37076. /**
  37077. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37078. * Higher values reduce its sensitivity.
  37079. */
  37080. angularSensibility: number;
  37081. private _mousemoveCallback;
  37082. private _observer;
  37083. private _rollObserver;
  37084. private previousPosition;
  37085. private noPreventDefault;
  37086. private element;
  37087. /**
  37088. * Listen to mouse events to control the camera.
  37089. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37090. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37091. */
  37092. constructor(touchEnabled?: boolean);
  37093. /**
  37094. * Attach the mouse control to the HTML DOM element.
  37095. * @param element Defines the element that listens to the input events.
  37096. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37097. */
  37098. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37099. /**
  37100. * Detach the current controls from the specified dom element.
  37101. * @param element Defines the element to stop listening the inputs from
  37102. */
  37103. detachControl(element: Nullable<HTMLElement>): void;
  37104. /**
  37105. * Gets the class name of the current input.
  37106. * @returns the class name.
  37107. */
  37108. getClassName(): string;
  37109. /**
  37110. * Get the friendly name associated with the input class.
  37111. * @returns the input's friendly name.
  37112. */
  37113. getSimpleName(): string;
  37114. private _pointerInput;
  37115. private _onMouseMove;
  37116. /**
  37117. * Rotate camera by mouse offset.
  37118. */
  37119. private rotateCamera;
  37120. }
  37121. }
  37122. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37123. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37124. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37125. /**
  37126. * Default Inputs manager for the FlyCamera.
  37127. * It groups all the default supported inputs for ease of use.
  37128. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37129. */
  37130. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37131. /**
  37132. * Instantiates a new FlyCameraInputsManager.
  37133. * @param camera Defines the camera the inputs belong to.
  37134. */
  37135. constructor(camera: FlyCamera);
  37136. /**
  37137. * Add keyboard input support to the input manager.
  37138. * @returns the new FlyCameraKeyboardMoveInput().
  37139. */
  37140. addKeyboard(): FlyCameraInputsManager;
  37141. /**
  37142. * Add mouse input support to the input manager.
  37143. * @param touchEnabled Enable touch screen support.
  37144. * @returns the new FlyCameraMouseInput().
  37145. */
  37146. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37147. }
  37148. }
  37149. declare module "babylonjs/Cameras/flyCamera" {
  37150. import { Scene } from "babylonjs/scene";
  37151. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37153. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37154. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37155. /**
  37156. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37157. * such as in a 3D Space Shooter or a Flight Simulator.
  37158. */
  37159. export class FlyCamera extends TargetCamera {
  37160. /**
  37161. * Define the collision ellipsoid of the camera.
  37162. * This is helpful for simulating a camera body, like a player's body.
  37163. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37164. */
  37165. ellipsoid: Vector3;
  37166. /**
  37167. * Define an offset for the position of the ellipsoid around the camera.
  37168. * This can be helpful if the camera is attached away from the player's body center,
  37169. * such as at its head.
  37170. */
  37171. ellipsoidOffset: Vector3;
  37172. /**
  37173. * Enable or disable collisions of the camera with the rest of the scene objects.
  37174. */
  37175. checkCollisions: boolean;
  37176. /**
  37177. * Enable or disable gravity on the camera.
  37178. */
  37179. applyGravity: boolean;
  37180. /**
  37181. * Define the current direction the camera is moving to.
  37182. */
  37183. cameraDirection: Vector3;
  37184. /**
  37185. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37186. * This overrides and empties cameraRotation.
  37187. */
  37188. rotationQuaternion: Quaternion;
  37189. /**
  37190. * Track Roll to maintain the wanted Rolling when looking around.
  37191. */
  37192. _trackRoll: number;
  37193. /**
  37194. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37195. */
  37196. rollCorrect: number;
  37197. /**
  37198. * Mimic a banked turn, Rolling the camera when Yawing.
  37199. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37200. */
  37201. bankedTurn: boolean;
  37202. /**
  37203. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37204. */
  37205. bankedTurnLimit: number;
  37206. /**
  37207. * Value of 0 disables the banked Roll.
  37208. * Value of 1 is equal to the Yaw angle in radians.
  37209. */
  37210. bankedTurnMultiplier: number;
  37211. /**
  37212. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37213. */
  37214. inputs: FlyCameraInputsManager;
  37215. /**
  37216. * Gets the input sensibility for mouse input.
  37217. * Higher values reduce sensitivity.
  37218. */
  37219. /**
  37220. * Sets the input sensibility for a mouse input.
  37221. * Higher values reduce sensitivity.
  37222. */
  37223. angularSensibility: number;
  37224. /**
  37225. * Get the keys for camera movement forward.
  37226. */
  37227. /**
  37228. * Set the keys for camera movement forward.
  37229. */
  37230. keysForward: number[];
  37231. /**
  37232. * Get the keys for camera movement backward.
  37233. */
  37234. keysBackward: number[];
  37235. /**
  37236. * Get the keys for camera movement up.
  37237. */
  37238. /**
  37239. * Set the keys for camera movement up.
  37240. */
  37241. keysUp: number[];
  37242. /**
  37243. * Get the keys for camera movement down.
  37244. */
  37245. /**
  37246. * Set the keys for camera movement down.
  37247. */
  37248. keysDown: number[];
  37249. /**
  37250. * Get the keys for camera movement left.
  37251. */
  37252. /**
  37253. * Set the keys for camera movement left.
  37254. */
  37255. keysLeft: number[];
  37256. /**
  37257. * Set the keys for camera movement right.
  37258. */
  37259. /**
  37260. * Set the keys for camera movement right.
  37261. */
  37262. keysRight: number[];
  37263. /**
  37264. * Event raised when the camera collides with a mesh in the scene.
  37265. */
  37266. onCollide: (collidedMesh: AbstractMesh) => void;
  37267. private _collider;
  37268. private _needMoveForGravity;
  37269. private _oldPosition;
  37270. private _diffPosition;
  37271. private _newPosition;
  37272. /** @hidden */
  37273. _localDirection: Vector3;
  37274. /** @hidden */
  37275. _transformedDirection: Vector3;
  37276. /**
  37277. * Instantiates a FlyCamera.
  37278. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37279. * such as in a 3D Space Shooter or a Flight Simulator.
  37280. * @param name Define the name of the camera in the scene.
  37281. * @param position Define the starting position of the camera in the scene.
  37282. * @param scene Define the scene the camera belongs to.
  37283. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37284. */
  37285. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37286. /**
  37287. * Attach a control to the HTML DOM element.
  37288. * @param element Defines the element that listens to the input events.
  37289. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37290. */
  37291. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37292. /**
  37293. * Detach a control from the HTML DOM element.
  37294. * The camera will stop reacting to that input.
  37295. * @param element Defines the element that listens to the input events.
  37296. */
  37297. detachControl(element: HTMLElement): void;
  37298. private _collisionMask;
  37299. /**
  37300. * Get the mask that the camera ignores in collision events.
  37301. */
  37302. /**
  37303. * Set the mask that the camera ignores in collision events.
  37304. */
  37305. collisionMask: number;
  37306. /** @hidden */
  37307. _collideWithWorld(displacement: Vector3): void;
  37308. /** @hidden */
  37309. private _onCollisionPositionChange;
  37310. /** @hidden */
  37311. _checkInputs(): void;
  37312. /** @hidden */
  37313. _decideIfNeedsToMove(): boolean;
  37314. /** @hidden */
  37315. _updatePosition(): void;
  37316. /**
  37317. * Restore the Roll to its target value at the rate specified.
  37318. * @param rate - Higher means slower restoring.
  37319. * @hidden
  37320. */
  37321. restoreRoll(rate: number): void;
  37322. /**
  37323. * Destroy the camera and release the current resources held by it.
  37324. */
  37325. dispose(): void;
  37326. /**
  37327. * Get the current object class name.
  37328. * @returns the class name.
  37329. */
  37330. getClassName(): string;
  37331. }
  37332. }
  37333. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37334. import { Nullable } from "babylonjs/types";
  37335. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37336. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37337. /**
  37338. * Listen to keyboard events to control the camera.
  37339. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37340. */
  37341. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37342. /**
  37343. * Defines the camera the input is attached to.
  37344. */
  37345. camera: FlyCamera;
  37346. /**
  37347. * The list of keyboard keys used to control the forward move of the camera.
  37348. */
  37349. keysForward: number[];
  37350. /**
  37351. * The list of keyboard keys used to control the backward move of the camera.
  37352. */
  37353. keysBackward: number[];
  37354. /**
  37355. * The list of keyboard keys used to control the forward move of the camera.
  37356. */
  37357. keysUp: number[];
  37358. /**
  37359. * The list of keyboard keys used to control the backward move of the camera.
  37360. */
  37361. keysDown: number[];
  37362. /**
  37363. * The list of keyboard keys used to control the right strafe move of the camera.
  37364. */
  37365. keysRight: number[];
  37366. /**
  37367. * The list of keyboard keys used to control the left strafe move of the camera.
  37368. */
  37369. keysLeft: number[];
  37370. private _keys;
  37371. private _onCanvasBlurObserver;
  37372. private _onKeyboardObserver;
  37373. private _engine;
  37374. private _scene;
  37375. /**
  37376. * Attach the input controls to a specific dom element to get the input from.
  37377. * @param element Defines the element the controls should be listened from
  37378. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37379. */
  37380. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37381. /**
  37382. * Detach the current controls from the specified dom element.
  37383. * @param element Defines the element to stop listening the inputs from
  37384. */
  37385. detachControl(element: Nullable<HTMLElement>): void;
  37386. /**
  37387. * Gets the class name of the current intput.
  37388. * @returns the class name
  37389. */
  37390. getClassName(): string;
  37391. /** @hidden */
  37392. _onLostFocus(e: FocusEvent): void;
  37393. /**
  37394. * Get the friendly name associated with the input class.
  37395. * @returns the input friendly name
  37396. */
  37397. getSimpleName(): string;
  37398. /**
  37399. * Update the current camera state depending on the inputs that have been used this frame.
  37400. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37401. */
  37402. checkInputs(): void;
  37403. }
  37404. }
  37405. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37406. import { Nullable } from "babylonjs/types";
  37407. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37408. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37409. /**
  37410. * Manage the mouse wheel inputs to control a follow camera.
  37411. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37412. */
  37413. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37414. /**
  37415. * Defines the camera the input is attached to.
  37416. */
  37417. camera: FollowCamera;
  37418. /**
  37419. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37420. */
  37421. axisControlRadius: boolean;
  37422. /**
  37423. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37424. */
  37425. axisControlHeight: boolean;
  37426. /**
  37427. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37428. */
  37429. axisControlRotation: boolean;
  37430. /**
  37431. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37432. * relation to mouseWheel events.
  37433. */
  37434. wheelPrecision: number;
  37435. /**
  37436. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37437. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37438. */
  37439. wheelDeltaPercentage: number;
  37440. private _wheel;
  37441. private _observer;
  37442. /**
  37443. * Attach the input controls to a specific dom element to get the input from.
  37444. * @param element Defines the element the controls should be listened from
  37445. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37446. */
  37447. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37448. /**
  37449. * Detach the current controls from the specified dom element.
  37450. * @param element Defines the element to stop listening the inputs from
  37451. */
  37452. detachControl(element: Nullable<HTMLElement>): void;
  37453. /**
  37454. * Gets the class name of the current intput.
  37455. * @returns the class name
  37456. */
  37457. getClassName(): string;
  37458. /**
  37459. * Get the friendly name associated with the input class.
  37460. * @returns the input friendly name
  37461. */
  37462. getSimpleName(): string;
  37463. }
  37464. }
  37465. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37466. import { Nullable } from "babylonjs/types";
  37467. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37468. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37469. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37470. /**
  37471. * Manage the pointers inputs to control an follow camera.
  37472. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37473. */
  37474. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37475. /**
  37476. * Defines the camera the input is attached to.
  37477. */
  37478. camera: FollowCamera;
  37479. /**
  37480. * Gets the class name of the current input.
  37481. * @returns the class name
  37482. */
  37483. getClassName(): string;
  37484. /**
  37485. * Defines the pointer angular sensibility along the X axis or how fast is
  37486. * the camera rotating.
  37487. * A negative number will reverse the axis direction.
  37488. */
  37489. angularSensibilityX: number;
  37490. /**
  37491. * Defines the pointer angular sensibility along the Y axis or how fast is
  37492. * the camera rotating.
  37493. * A negative number will reverse the axis direction.
  37494. */
  37495. angularSensibilityY: number;
  37496. /**
  37497. * Defines the pointer pinch precision or how fast is the camera zooming.
  37498. * A negative number will reverse the axis direction.
  37499. */
  37500. pinchPrecision: number;
  37501. /**
  37502. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37503. * from 0.
  37504. * It defines the percentage of current camera.radius to use as delta when
  37505. * pinch zoom is used.
  37506. */
  37507. pinchDeltaPercentage: number;
  37508. /**
  37509. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37510. */
  37511. axisXControlRadius: boolean;
  37512. /**
  37513. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37514. */
  37515. axisXControlHeight: boolean;
  37516. /**
  37517. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37518. */
  37519. axisXControlRotation: boolean;
  37520. /**
  37521. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37522. */
  37523. axisYControlRadius: boolean;
  37524. /**
  37525. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37526. */
  37527. axisYControlHeight: boolean;
  37528. /**
  37529. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37530. */
  37531. axisYControlRotation: boolean;
  37532. /**
  37533. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37534. */
  37535. axisPinchControlRadius: boolean;
  37536. /**
  37537. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37538. */
  37539. axisPinchControlHeight: boolean;
  37540. /**
  37541. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37542. */
  37543. axisPinchControlRotation: boolean;
  37544. /**
  37545. * Log error messages if basic misconfiguration has occurred.
  37546. */
  37547. warningEnable: boolean;
  37548. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37549. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37550. private _warningCounter;
  37551. private _warning;
  37552. }
  37553. }
  37554. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37555. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37556. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37557. /**
  37558. * Default Inputs manager for the FollowCamera.
  37559. * It groups all the default supported inputs for ease of use.
  37560. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37561. */
  37562. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37563. /**
  37564. * Instantiates a new FollowCameraInputsManager.
  37565. * @param camera Defines the camera the inputs belong to
  37566. */
  37567. constructor(camera: FollowCamera);
  37568. /**
  37569. * Add keyboard input support to the input manager.
  37570. * @returns the current input manager
  37571. */
  37572. addKeyboard(): FollowCameraInputsManager;
  37573. /**
  37574. * Add mouse wheel input support to the input manager.
  37575. * @returns the current input manager
  37576. */
  37577. addMouseWheel(): FollowCameraInputsManager;
  37578. /**
  37579. * Add pointers input support to the input manager.
  37580. * @returns the current input manager
  37581. */
  37582. addPointers(): FollowCameraInputsManager;
  37583. /**
  37584. * Add orientation input support to the input manager.
  37585. * @returns the current input manager
  37586. */
  37587. addVRDeviceOrientation(): FollowCameraInputsManager;
  37588. }
  37589. }
  37590. declare module "babylonjs/Cameras/followCamera" {
  37591. import { Nullable } from "babylonjs/types";
  37592. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37593. import { Scene } from "babylonjs/scene";
  37594. import { Vector3 } from "babylonjs/Maths/math";
  37595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37596. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37597. /**
  37598. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37599. * an arc rotate version arcFollowCamera are available.
  37600. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37601. */
  37602. export class FollowCamera extends TargetCamera {
  37603. /**
  37604. * Distance the follow camera should follow an object at
  37605. */
  37606. radius: number;
  37607. /**
  37608. * Minimum allowed distance of the camera to the axis of rotation
  37609. * (The camera can not get closer).
  37610. * This can help limiting how the Camera is able to move in the scene.
  37611. */
  37612. lowerRadiusLimit: Nullable<number>;
  37613. /**
  37614. * Maximum allowed distance of the camera to the axis of rotation
  37615. * (The camera can not get further).
  37616. * This can help limiting how the Camera is able to move in the scene.
  37617. */
  37618. upperRadiusLimit: Nullable<number>;
  37619. /**
  37620. * Define a rotation offset between the camera and the object it follows
  37621. */
  37622. rotationOffset: number;
  37623. /**
  37624. * Minimum allowed angle to camera position relative to target object.
  37625. * This can help limiting how the Camera is able to move in the scene.
  37626. */
  37627. lowerRotationOffsetLimit: Nullable<number>;
  37628. /**
  37629. * Maximum allowed angle to camera position relative to target object.
  37630. * This can help limiting how the Camera is able to move in the scene.
  37631. */
  37632. upperRotationOffsetLimit: Nullable<number>;
  37633. /**
  37634. * Define a height offset between the camera and the object it follows.
  37635. * It can help following an object from the top (like a car chaing a plane)
  37636. */
  37637. heightOffset: number;
  37638. /**
  37639. * Minimum allowed height of camera position relative to target object.
  37640. * This can help limiting how the Camera is able to move in the scene.
  37641. */
  37642. lowerHeightOffsetLimit: Nullable<number>;
  37643. /**
  37644. * Maximum allowed height of camera position relative to target object.
  37645. * This can help limiting how the Camera is able to move in the scene.
  37646. */
  37647. upperHeightOffsetLimit: Nullable<number>;
  37648. /**
  37649. * Define how fast the camera can accelerate to follow it s target.
  37650. */
  37651. cameraAcceleration: number;
  37652. /**
  37653. * Define the speed limit of the camera following an object.
  37654. */
  37655. maxCameraSpeed: number;
  37656. /**
  37657. * Define the target of the camera.
  37658. */
  37659. lockedTarget: Nullable<AbstractMesh>;
  37660. /**
  37661. * Defines the input associated with the camera.
  37662. */
  37663. inputs: FollowCameraInputsManager;
  37664. /**
  37665. * Instantiates the follow camera.
  37666. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37667. * @param name Define the name of the camera in the scene
  37668. * @param position Define the position of the camera
  37669. * @param scene Define the scene the camera belong to
  37670. * @param lockedTarget Define the target of the camera
  37671. */
  37672. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37673. private _follow;
  37674. /**
  37675. * Attached controls to the current camera.
  37676. * @param element Defines the element the controls should be listened from
  37677. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37678. */
  37679. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37680. /**
  37681. * Detach the current controls from the camera.
  37682. * The camera will stop reacting to inputs.
  37683. * @param element Defines the element to stop listening the inputs from
  37684. */
  37685. detachControl(element: HTMLElement): void;
  37686. /** @hidden */
  37687. _checkInputs(): void;
  37688. private _checkLimits;
  37689. /**
  37690. * Gets the camera class name.
  37691. * @returns the class name
  37692. */
  37693. getClassName(): string;
  37694. }
  37695. /**
  37696. * Arc Rotate version of the follow camera.
  37697. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37698. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37699. */
  37700. export class ArcFollowCamera extends TargetCamera {
  37701. /** The longitudinal angle of the camera */
  37702. alpha: number;
  37703. /** The latitudinal angle of the camera */
  37704. beta: number;
  37705. /** The radius of the camera from its target */
  37706. radius: number;
  37707. /** Define the camera target (the messh it should follow) */
  37708. target: Nullable<AbstractMesh>;
  37709. private _cartesianCoordinates;
  37710. /**
  37711. * Instantiates a new ArcFollowCamera
  37712. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37713. * @param name Define the name of the camera
  37714. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37715. * @param beta Define the rotation angle of the camera around the elevation axis
  37716. * @param radius Define the radius of the camera from its target point
  37717. * @param target Define the target of the camera
  37718. * @param scene Define the scene the camera belongs to
  37719. */
  37720. constructor(name: string,
  37721. /** The longitudinal angle of the camera */
  37722. alpha: number,
  37723. /** The latitudinal angle of the camera */
  37724. beta: number,
  37725. /** The radius of the camera from its target */
  37726. radius: number,
  37727. /** Define the camera target (the messh it should follow) */
  37728. target: Nullable<AbstractMesh>, scene: Scene);
  37729. private _follow;
  37730. /** @hidden */
  37731. _checkInputs(): void;
  37732. /**
  37733. * Returns the class name of the object.
  37734. * It is mostly used internally for serialization purposes.
  37735. */
  37736. getClassName(): string;
  37737. }
  37738. }
  37739. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37740. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37741. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37742. import { Nullable } from "babylonjs/types";
  37743. /**
  37744. * Manage the keyboard inputs to control the movement of a follow camera.
  37745. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37746. */
  37747. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37748. /**
  37749. * Defines the camera the input is attached to.
  37750. */
  37751. camera: FollowCamera;
  37752. /**
  37753. * Defines the list of key codes associated with the up action (increase heightOffset)
  37754. */
  37755. keysHeightOffsetIncr: number[];
  37756. /**
  37757. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37758. */
  37759. keysHeightOffsetDecr: number[];
  37760. /**
  37761. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37762. */
  37763. keysHeightOffsetModifierAlt: boolean;
  37764. /**
  37765. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37766. */
  37767. keysHeightOffsetModifierCtrl: boolean;
  37768. /**
  37769. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37770. */
  37771. keysHeightOffsetModifierShift: boolean;
  37772. /**
  37773. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37774. */
  37775. keysRotationOffsetIncr: number[];
  37776. /**
  37777. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37778. */
  37779. keysRotationOffsetDecr: number[];
  37780. /**
  37781. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37782. */
  37783. keysRotationOffsetModifierAlt: boolean;
  37784. /**
  37785. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37786. */
  37787. keysRotationOffsetModifierCtrl: boolean;
  37788. /**
  37789. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37790. */
  37791. keysRotationOffsetModifierShift: boolean;
  37792. /**
  37793. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37794. */
  37795. keysRadiusIncr: number[];
  37796. /**
  37797. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37798. */
  37799. keysRadiusDecr: number[];
  37800. /**
  37801. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37802. */
  37803. keysRadiusModifierAlt: boolean;
  37804. /**
  37805. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37806. */
  37807. keysRadiusModifierCtrl: boolean;
  37808. /**
  37809. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37810. */
  37811. keysRadiusModifierShift: boolean;
  37812. /**
  37813. * Defines the rate of change of heightOffset.
  37814. */
  37815. heightSensibility: number;
  37816. /**
  37817. * Defines the rate of change of rotationOffset.
  37818. */
  37819. rotationSensibility: number;
  37820. /**
  37821. * Defines the rate of change of radius.
  37822. */
  37823. radiusSensibility: number;
  37824. private _keys;
  37825. private _ctrlPressed;
  37826. private _altPressed;
  37827. private _shiftPressed;
  37828. private _onCanvasBlurObserver;
  37829. private _onKeyboardObserver;
  37830. private _engine;
  37831. private _scene;
  37832. /**
  37833. * Attach the input controls to a specific dom element to get the input from.
  37834. * @param element Defines the element the controls should be listened from
  37835. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37836. */
  37837. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37838. /**
  37839. * Detach the current controls from the specified dom element.
  37840. * @param element Defines the element to stop listening the inputs from
  37841. */
  37842. detachControl(element: Nullable<HTMLElement>): void;
  37843. /**
  37844. * Update the current camera state depending on the inputs that have been used this frame.
  37845. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37846. */
  37847. checkInputs(): void;
  37848. /**
  37849. * Gets the class name of the current input.
  37850. * @returns the class name
  37851. */
  37852. getClassName(): string;
  37853. /**
  37854. * Get the friendly name associated with the input class.
  37855. * @returns the input friendly name
  37856. */
  37857. getSimpleName(): string;
  37858. /**
  37859. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37860. * allow modification of the heightOffset value.
  37861. */
  37862. private _modifierHeightOffset;
  37863. /**
  37864. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37865. * allow modification of the rotationOffset value.
  37866. */
  37867. private _modifierRotationOffset;
  37868. /**
  37869. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37870. * allow modification of the radius value.
  37871. */
  37872. private _modifierRadius;
  37873. }
  37874. }
  37875. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37876. import { Nullable } from "babylonjs/types";
  37877. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37878. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37879. import { Observable } from "babylonjs/Misc/observable";
  37880. module "babylonjs/Cameras/freeCameraInputsManager" {
  37881. interface FreeCameraInputsManager {
  37882. /**
  37883. * @hidden
  37884. */
  37885. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37886. /**
  37887. * Add orientation input support to the input manager.
  37888. * @returns the current input manager
  37889. */
  37890. addDeviceOrientation(): FreeCameraInputsManager;
  37891. }
  37892. }
  37893. /**
  37894. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37895. * Screen rotation is taken into account.
  37896. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37897. */
  37898. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37899. private _camera;
  37900. private _screenOrientationAngle;
  37901. private _constantTranform;
  37902. private _screenQuaternion;
  37903. private _alpha;
  37904. private _beta;
  37905. private _gamma;
  37906. /**
  37907. * @hidden
  37908. */
  37909. _onDeviceOrientationChangedObservable: Observable<void>;
  37910. /**
  37911. * Instantiates a new input
  37912. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37913. */
  37914. constructor();
  37915. /**
  37916. * Define the camera controlled by the input.
  37917. */
  37918. camera: FreeCamera;
  37919. /**
  37920. * Attach the input controls to a specific dom element to get the input from.
  37921. * @param element Defines the element the controls should be listened from
  37922. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37923. */
  37924. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37925. private _orientationChanged;
  37926. private _deviceOrientation;
  37927. /**
  37928. * Detach the current controls from the specified dom element.
  37929. * @param element Defines the element to stop listening the inputs from
  37930. */
  37931. detachControl(element: Nullable<HTMLElement>): void;
  37932. /**
  37933. * Update the current camera state depending on the inputs that have been used this frame.
  37934. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37935. */
  37936. checkInputs(): void;
  37937. /**
  37938. * Gets the class name of the current intput.
  37939. * @returns the class name
  37940. */
  37941. getClassName(): string;
  37942. /**
  37943. * Get the friendly name associated with the input class.
  37944. * @returns the input friendly name
  37945. */
  37946. getSimpleName(): string;
  37947. }
  37948. }
  37949. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37950. import { Nullable } from "babylonjs/types";
  37951. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37952. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37953. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37954. /**
  37955. * Manage the gamepad inputs to control a free camera.
  37956. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37957. */
  37958. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37959. /**
  37960. * Define the camera the input is attached to.
  37961. */
  37962. camera: FreeCamera;
  37963. /**
  37964. * Define the Gamepad controlling the input
  37965. */
  37966. gamepad: Nullable<Gamepad>;
  37967. /**
  37968. * Defines the gamepad rotation sensiblity.
  37969. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37970. */
  37971. gamepadAngularSensibility: number;
  37972. /**
  37973. * Defines the gamepad move sensiblity.
  37974. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37975. */
  37976. gamepadMoveSensibility: number;
  37977. private _onGamepadConnectedObserver;
  37978. private _onGamepadDisconnectedObserver;
  37979. private _cameraTransform;
  37980. private _deltaTransform;
  37981. private _vector3;
  37982. private _vector2;
  37983. /**
  37984. * Attach the input controls to a specific dom element to get the input from.
  37985. * @param element Defines the element the controls should be listened from
  37986. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37987. */
  37988. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37989. /**
  37990. * Detach the current controls from the specified dom element.
  37991. * @param element Defines the element to stop listening the inputs from
  37992. */
  37993. detachControl(element: Nullable<HTMLElement>): void;
  37994. /**
  37995. * Update the current camera state depending on the inputs that have been used this frame.
  37996. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37997. */
  37998. checkInputs(): void;
  37999. /**
  38000. * Gets the class name of the current intput.
  38001. * @returns the class name
  38002. */
  38003. getClassName(): string;
  38004. /**
  38005. * Get the friendly name associated with the input class.
  38006. * @returns the input friendly name
  38007. */
  38008. getSimpleName(): string;
  38009. }
  38010. }
  38011. declare module "babylonjs/Misc/virtualJoystick" {
  38012. import { Nullable } from "babylonjs/types";
  38013. import { Vector3 } from "babylonjs/Maths/math";
  38014. /**
  38015. * Defines the potential axis of a Joystick
  38016. */
  38017. export enum JoystickAxis {
  38018. /** X axis */
  38019. X = 0,
  38020. /** Y axis */
  38021. Y = 1,
  38022. /** Z axis */
  38023. Z = 2
  38024. }
  38025. /**
  38026. * Class used to define virtual joystick (used in touch mode)
  38027. */
  38028. export class VirtualJoystick {
  38029. /**
  38030. * Gets or sets a boolean indicating that left and right values must be inverted
  38031. */
  38032. reverseLeftRight: boolean;
  38033. /**
  38034. * Gets or sets a boolean indicating that up and down values must be inverted
  38035. */
  38036. reverseUpDown: boolean;
  38037. /**
  38038. * Gets the offset value for the position (ie. the change of the position value)
  38039. */
  38040. deltaPosition: Vector3;
  38041. /**
  38042. * Gets a boolean indicating if the virtual joystick was pressed
  38043. */
  38044. pressed: boolean;
  38045. /**
  38046. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38047. */
  38048. static Canvas: Nullable<HTMLCanvasElement>;
  38049. private static _globalJoystickIndex;
  38050. private static vjCanvasContext;
  38051. private static vjCanvasWidth;
  38052. private static vjCanvasHeight;
  38053. private static halfWidth;
  38054. private _action;
  38055. private _axisTargetedByLeftAndRight;
  38056. private _axisTargetedByUpAndDown;
  38057. private _joystickSensibility;
  38058. private _inversedSensibility;
  38059. private _joystickPointerID;
  38060. private _joystickColor;
  38061. private _joystickPointerPos;
  38062. private _joystickPreviousPointerPos;
  38063. private _joystickPointerStartPos;
  38064. private _deltaJoystickVector;
  38065. private _leftJoystick;
  38066. private _touches;
  38067. private _onPointerDownHandlerRef;
  38068. private _onPointerMoveHandlerRef;
  38069. private _onPointerUpHandlerRef;
  38070. private _onResize;
  38071. /**
  38072. * Creates a new virtual joystick
  38073. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38074. */
  38075. constructor(leftJoystick?: boolean);
  38076. /**
  38077. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38078. * @param newJoystickSensibility defines the new sensibility
  38079. */
  38080. setJoystickSensibility(newJoystickSensibility: number): void;
  38081. private _onPointerDown;
  38082. private _onPointerMove;
  38083. private _onPointerUp;
  38084. /**
  38085. * Change the color of the virtual joystick
  38086. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38087. */
  38088. setJoystickColor(newColor: string): void;
  38089. /**
  38090. * Defines a callback to call when the joystick is touched
  38091. * @param action defines the callback
  38092. */
  38093. setActionOnTouch(action: () => any): void;
  38094. /**
  38095. * Defines which axis you'd like to control for left & right
  38096. * @param axis defines the axis to use
  38097. */
  38098. setAxisForLeftRight(axis: JoystickAxis): void;
  38099. /**
  38100. * Defines which axis you'd like to control for up & down
  38101. * @param axis defines the axis to use
  38102. */
  38103. setAxisForUpDown(axis: JoystickAxis): void;
  38104. private _drawVirtualJoystick;
  38105. /**
  38106. * Release internal HTML canvas
  38107. */
  38108. releaseCanvas(): void;
  38109. }
  38110. }
  38111. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38112. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38113. import { Nullable } from "babylonjs/types";
  38114. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38115. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38116. module "babylonjs/Cameras/freeCameraInputsManager" {
  38117. interface FreeCameraInputsManager {
  38118. /**
  38119. * Add virtual joystick input support to the input manager.
  38120. * @returns the current input manager
  38121. */
  38122. addVirtualJoystick(): FreeCameraInputsManager;
  38123. }
  38124. }
  38125. /**
  38126. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38127. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38128. */
  38129. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38130. /**
  38131. * Defines the camera the input is attached to.
  38132. */
  38133. camera: FreeCamera;
  38134. private _leftjoystick;
  38135. private _rightjoystick;
  38136. /**
  38137. * Gets the left stick of the virtual joystick.
  38138. * @returns The virtual Joystick
  38139. */
  38140. getLeftJoystick(): VirtualJoystick;
  38141. /**
  38142. * Gets the right stick of the virtual joystick.
  38143. * @returns The virtual Joystick
  38144. */
  38145. getRightJoystick(): VirtualJoystick;
  38146. /**
  38147. * Update the current camera state depending on the inputs that have been used this frame.
  38148. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38149. */
  38150. checkInputs(): void;
  38151. /**
  38152. * Attach the input controls to a specific dom element to get the input from.
  38153. * @param element Defines the element the controls should be listened from
  38154. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38155. */
  38156. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38157. /**
  38158. * Detach the current controls from the specified dom element.
  38159. * @param element Defines the element to stop listening the inputs from
  38160. */
  38161. detachControl(element: Nullable<HTMLElement>): void;
  38162. /**
  38163. * Gets the class name of the current intput.
  38164. * @returns the class name
  38165. */
  38166. getClassName(): string;
  38167. /**
  38168. * Get the friendly name associated with the input class.
  38169. * @returns the input friendly name
  38170. */
  38171. getSimpleName(): string;
  38172. }
  38173. }
  38174. declare module "babylonjs/Cameras/Inputs/index" {
  38175. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38176. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38177. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38178. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38179. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38180. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38181. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38182. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38183. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38184. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38185. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38186. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38187. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38188. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38189. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38190. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38191. }
  38192. declare module "babylonjs/Cameras/touchCamera" {
  38193. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38194. import { Scene } from "babylonjs/scene";
  38195. import { Vector3 } from "babylonjs/Maths/math";
  38196. /**
  38197. * This represents a FPS type of camera controlled by touch.
  38198. * This is like a universal camera minus the Gamepad controls.
  38199. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38200. */
  38201. export class TouchCamera extends FreeCamera {
  38202. /**
  38203. * Defines the touch sensibility for rotation.
  38204. * The higher the faster.
  38205. */
  38206. touchAngularSensibility: number;
  38207. /**
  38208. * Defines the touch sensibility for move.
  38209. * The higher the faster.
  38210. */
  38211. touchMoveSensibility: number;
  38212. /**
  38213. * Instantiates a new touch camera.
  38214. * This represents a FPS type of camera controlled by touch.
  38215. * This is like a universal camera minus the Gamepad controls.
  38216. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38217. * @param name Define the name of the camera in the scene
  38218. * @param position Define the start position of the camera in the scene
  38219. * @param scene Define the scene the camera belongs to
  38220. */
  38221. constructor(name: string, position: Vector3, scene: Scene);
  38222. /**
  38223. * Gets the current object class name.
  38224. * @return the class name
  38225. */
  38226. getClassName(): string;
  38227. /** @hidden */
  38228. _setupInputs(): void;
  38229. }
  38230. }
  38231. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38232. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38233. import { Scene } from "babylonjs/scene";
  38234. import { Vector3, Axis } from "babylonjs/Maths/math";
  38235. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38236. /**
  38237. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38238. * being tilted forward or back and left or right.
  38239. */
  38240. export class DeviceOrientationCamera extends FreeCamera {
  38241. private _initialQuaternion;
  38242. private _quaternionCache;
  38243. private _tmpDragQuaternion;
  38244. /**
  38245. * Creates a new device orientation camera
  38246. * @param name The name of the camera
  38247. * @param position The start position camera
  38248. * @param scene The scene the camera belongs to
  38249. */
  38250. constructor(name: string, position: Vector3, scene: Scene);
  38251. /**
  38252. * Disabled pointer input on first orientation sensor update (Default: true)
  38253. */
  38254. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38255. private _dragFactor;
  38256. /**
  38257. * Enabled turning on the y axis when the orientation sensor is active
  38258. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38259. */
  38260. enableHorizontalDragging(dragFactor?: number): void;
  38261. /**
  38262. * Gets the current instance class name ("DeviceOrientationCamera").
  38263. * This helps avoiding instanceof at run time.
  38264. * @returns the class name
  38265. */
  38266. getClassName(): string;
  38267. /**
  38268. * @hidden
  38269. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38270. */
  38271. _checkInputs(): void;
  38272. /**
  38273. * Reset the camera to its default orientation on the specified axis only.
  38274. * @param axis The axis to reset
  38275. */
  38276. resetToCurrentRotation(axis?: Axis): void;
  38277. }
  38278. }
  38279. declare module "babylonjs/Cameras/universalCamera" {
  38280. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38281. import { Scene } from "babylonjs/scene";
  38282. import { Vector3 } from "babylonjs/Maths/math";
  38283. /**
  38284. * 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,
  38285. * which still works and will still be found in many Playgrounds.
  38286. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38287. */
  38288. export class UniversalCamera extends TouchCamera {
  38289. /**
  38290. * Defines the gamepad rotation sensiblity.
  38291. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38292. */
  38293. gamepadAngularSensibility: number;
  38294. /**
  38295. * Defines the gamepad move sensiblity.
  38296. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38297. */
  38298. gamepadMoveSensibility: number;
  38299. /**
  38300. * 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,
  38301. * which still works and will still be found in many Playgrounds.
  38302. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38303. * @param name Define the name of the camera in the scene
  38304. * @param position Define the start position of the camera in the scene
  38305. * @param scene Define the scene the camera belongs to
  38306. */
  38307. constructor(name: string, position: Vector3, scene: Scene);
  38308. /**
  38309. * Gets the current object class name.
  38310. * @return the class name
  38311. */
  38312. getClassName(): string;
  38313. }
  38314. }
  38315. declare module "babylonjs/Cameras/gamepadCamera" {
  38316. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38317. import { Scene } from "babylonjs/scene";
  38318. import { Vector3 } from "babylonjs/Maths/math";
  38319. /**
  38320. * This represents a FPS type of camera. This is only here for back compat purpose.
  38321. * Please use the UniversalCamera instead as both are identical.
  38322. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38323. */
  38324. export class GamepadCamera extends UniversalCamera {
  38325. /**
  38326. * Instantiates a new Gamepad Camera
  38327. * This represents a FPS type of camera. This is only here for back compat purpose.
  38328. * Please use the UniversalCamera instead as both are identical.
  38329. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38330. * @param name Define the name of the camera in the scene
  38331. * @param position Define the start position of the camera in the scene
  38332. * @param scene Define the scene the camera belongs to
  38333. */
  38334. constructor(name: string, position: Vector3, scene: Scene);
  38335. /**
  38336. * Gets the current object class name.
  38337. * @return the class name
  38338. */
  38339. getClassName(): string;
  38340. }
  38341. }
  38342. declare module "babylonjs/Shaders/pass.fragment" {
  38343. /** @hidden */
  38344. export var passPixelShader: {
  38345. name: string;
  38346. shader: string;
  38347. };
  38348. }
  38349. declare module "babylonjs/Shaders/passCube.fragment" {
  38350. /** @hidden */
  38351. export var passCubePixelShader: {
  38352. name: string;
  38353. shader: string;
  38354. };
  38355. }
  38356. declare module "babylonjs/PostProcesses/passPostProcess" {
  38357. import { Nullable } from "babylonjs/types";
  38358. import { Camera } from "babylonjs/Cameras/camera";
  38359. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38360. import { Engine } from "babylonjs/Engines/engine";
  38361. import "babylonjs/Shaders/pass.fragment";
  38362. import "babylonjs/Shaders/passCube.fragment";
  38363. /**
  38364. * PassPostProcess which produces an output the same as it's input
  38365. */
  38366. export class PassPostProcess extends PostProcess {
  38367. /**
  38368. * Creates the PassPostProcess
  38369. * @param name The name of the effect.
  38370. * @param options The required width/height ratio to downsize to before computing the render pass.
  38371. * @param camera The camera to apply the render pass to.
  38372. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38373. * @param engine The engine which the post process will be applied. (default: current engine)
  38374. * @param reusable If the post process can be reused on the same frame. (default: false)
  38375. * @param textureType The type of texture to be used when performing the post processing.
  38376. * @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)
  38377. */
  38378. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38379. }
  38380. /**
  38381. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38382. */
  38383. export class PassCubePostProcess extends PostProcess {
  38384. private _face;
  38385. /**
  38386. * Gets or sets the cube face to display.
  38387. * * 0 is +X
  38388. * * 1 is -X
  38389. * * 2 is +Y
  38390. * * 3 is -Y
  38391. * * 4 is +Z
  38392. * * 5 is -Z
  38393. */
  38394. face: number;
  38395. /**
  38396. * Creates the PassCubePostProcess
  38397. * @param name The name of the effect.
  38398. * @param options The required width/height ratio to downsize to before computing the render pass.
  38399. * @param camera The camera to apply the render pass to.
  38400. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38401. * @param engine The engine which the post process will be applied. (default: current engine)
  38402. * @param reusable If the post process can be reused on the same frame. (default: false)
  38403. * @param textureType The type of texture to be used when performing the post processing.
  38404. * @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)
  38405. */
  38406. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38407. }
  38408. }
  38409. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38410. /** @hidden */
  38411. export var anaglyphPixelShader: {
  38412. name: string;
  38413. shader: string;
  38414. };
  38415. }
  38416. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38417. import { Engine } from "babylonjs/Engines/engine";
  38418. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38419. import { Camera } from "babylonjs/Cameras/camera";
  38420. import "babylonjs/Shaders/anaglyph.fragment";
  38421. /**
  38422. * Postprocess used to generate anaglyphic rendering
  38423. */
  38424. export class AnaglyphPostProcess extends PostProcess {
  38425. private _passedProcess;
  38426. /**
  38427. * Creates a new AnaglyphPostProcess
  38428. * @param name defines postprocess name
  38429. * @param options defines creation options or target ratio scale
  38430. * @param rigCameras defines cameras using this postprocess
  38431. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38432. * @param engine defines hosting engine
  38433. * @param reusable defines if the postprocess will be reused multiple times per frame
  38434. */
  38435. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38436. }
  38437. }
  38438. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38439. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38440. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38441. import { Scene } from "babylonjs/scene";
  38442. import { Vector3 } from "babylonjs/Maths/math";
  38443. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38444. /**
  38445. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38446. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38447. */
  38448. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38449. /**
  38450. * Creates a new AnaglyphArcRotateCamera
  38451. * @param name defines camera name
  38452. * @param alpha defines alpha angle (in radians)
  38453. * @param beta defines beta angle (in radians)
  38454. * @param radius defines radius
  38455. * @param target defines camera target
  38456. * @param interaxialDistance defines distance between each color axis
  38457. * @param scene defines the hosting scene
  38458. */
  38459. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38460. /**
  38461. * Gets camera class name
  38462. * @returns AnaglyphArcRotateCamera
  38463. */
  38464. getClassName(): string;
  38465. }
  38466. }
  38467. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38468. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38469. import { Scene } from "babylonjs/scene";
  38470. import { Vector3 } from "babylonjs/Maths/math";
  38471. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38472. /**
  38473. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38474. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38475. */
  38476. export class AnaglyphFreeCamera extends FreeCamera {
  38477. /**
  38478. * Creates a new AnaglyphFreeCamera
  38479. * @param name defines camera name
  38480. * @param position defines initial position
  38481. * @param interaxialDistance defines distance between each color axis
  38482. * @param scene defines the hosting scene
  38483. */
  38484. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38485. /**
  38486. * Gets camera class name
  38487. * @returns AnaglyphFreeCamera
  38488. */
  38489. getClassName(): string;
  38490. }
  38491. }
  38492. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38493. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38494. import { Scene } from "babylonjs/scene";
  38495. import { Vector3 } from "babylonjs/Maths/math";
  38496. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38497. /**
  38498. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38499. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38500. */
  38501. export class AnaglyphGamepadCamera extends GamepadCamera {
  38502. /**
  38503. * Creates a new AnaglyphGamepadCamera
  38504. * @param name defines camera name
  38505. * @param position defines initial position
  38506. * @param interaxialDistance defines distance between each color axis
  38507. * @param scene defines the hosting scene
  38508. */
  38509. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38510. /**
  38511. * Gets camera class name
  38512. * @returns AnaglyphGamepadCamera
  38513. */
  38514. getClassName(): string;
  38515. }
  38516. }
  38517. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38518. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38519. import { Scene } from "babylonjs/scene";
  38520. import { Vector3 } from "babylonjs/Maths/math";
  38521. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38522. /**
  38523. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38524. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38525. */
  38526. export class AnaglyphUniversalCamera extends UniversalCamera {
  38527. /**
  38528. * Creates a new AnaglyphUniversalCamera
  38529. * @param name defines camera name
  38530. * @param position defines initial position
  38531. * @param interaxialDistance defines distance between each color axis
  38532. * @param scene defines the hosting scene
  38533. */
  38534. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38535. /**
  38536. * Gets camera class name
  38537. * @returns AnaglyphUniversalCamera
  38538. */
  38539. getClassName(): string;
  38540. }
  38541. }
  38542. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38543. /** @hidden */
  38544. export var stereoscopicInterlacePixelShader: {
  38545. name: string;
  38546. shader: string;
  38547. };
  38548. }
  38549. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38550. import { Camera } from "babylonjs/Cameras/camera";
  38551. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38552. import { Engine } from "babylonjs/Engines/engine";
  38553. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38554. /**
  38555. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38556. */
  38557. export class StereoscopicInterlacePostProcess extends PostProcess {
  38558. private _stepSize;
  38559. private _passedProcess;
  38560. /**
  38561. * Initializes a StereoscopicInterlacePostProcess
  38562. * @param name The name of the effect.
  38563. * @param rigCameras The rig cameras to be appled to the post process
  38564. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38565. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38566. * @param engine The engine which the post process will be applied. (default: current engine)
  38567. * @param reusable If the post process can be reused on the same frame. (default: false)
  38568. */
  38569. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38570. }
  38571. }
  38572. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38573. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38574. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38575. import { Scene } from "babylonjs/scene";
  38576. import { Vector3 } from "babylonjs/Maths/math";
  38577. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38578. /**
  38579. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38580. * @see http://doc.babylonjs.com/features/cameras
  38581. */
  38582. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38583. /**
  38584. * Creates a new StereoscopicArcRotateCamera
  38585. * @param name defines camera name
  38586. * @param alpha defines alpha angle (in radians)
  38587. * @param beta defines beta angle (in radians)
  38588. * @param radius defines radius
  38589. * @param target defines camera target
  38590. * @param interaxialDistance defines distance between each color axis
  38591. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38592. * @param scene defines the hosting scene
  38593. */
  38594. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38595. /**
  38596. * Gets camera class name
  38597. * @returns StereoscopicArcRotateCamera
  38598. */
  38599. getClassName(): string;
  38600. }
  38601. }
  38602. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38603. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38604. import { Scene } from "babylonjs/scene";
  38605. import { Vector3 } from "babylonjs/Maths/math";
  38606. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38607. /**
  38608. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38609. * @see http://doc.babylonjs.com/features/cameras
  38610. */
  38611. export class StereoscopicFreeCamera extends FreeCamera {
  38612. /**
  38613. * Creates a new StereoscopicFreeCamera
  38614. * @param name defines camera name
  38615. * @param position defines initial position
  38616. * @param interaxialDistance defines distance between each color axis
  38617. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38618. * @param scene defines the hosting scene
  38619. */
  38620. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38621. /**
  38622. * Gets camera class name
  38623. * @returns StereoscopicFreeCamera
  38624. */
  38625. getClassName(): string;
  38626. }
  38627. }
  38628. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38629. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38630. import { Scene } from "babylonjs/scene";
  38631. import { Vector3 } from "babylonjs/Maths/math";
  38632. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38633. /**
  38634. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38635. * @see http://doc.babylonjs.com/features/cameras
  38636. */
  38637. export class StereoscopicGamepadCamera extends GamepadCamera {
  38638. /**
  38639. * Creates a new StereoscopicGamepadCamera
  38640. * @param name defines camera name
  38641. * @param position defines initial position
  38642. * @param interaxialDistance defines distance between each color axis
  38643. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38644. * @param scene defines the hosting scene
  38645. */
  38646. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38647. /**
  38648. * Gets camera class name
  38649. * @returns StereoscopicGamepadCamera
  38650. */
  38651. getClassName(): string;
  38652. }
  38653. }
  38654. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38655. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38656. import { Scene } from "babylonjs/scene";
  38657. import { Vector3 } from "babylonjs/Maths/math";
  38658. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38659. /**
  38660. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38661. * @see http://doc.babylonjs.com/features/cameras
  38662. */
  38663. export class StereoscopicUniversalCamera extends UniversalCamera {
  38664. /**
  38665. * Creates a new StereoscopicUniversalCamera
  38666. * @param name defines camera name
  38667. * @param position defines initial position
  38668. * @param interaxialDistance defines distance between each color axis
  38669. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38670. * @param scene defines the hosting scene
  38671. */
  38672. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38673. /**
  38674. * Gets camera class name
  38675. * @returns StereoscopicUniversalCamera
  38676. */
  38677. getClassName(): string;
  38678. }
  38679. }
  38680. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38681. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38682. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38683. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38684. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38685. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38686. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38687. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38688. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38689. }
  38690. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38691. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38692. import { Scene } from "babylonjs/scene";
  38693. import { Vector3 } from "babylonjs/Maths/math";
  38694. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38695. /**
  38696. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38697. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38698. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38699. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38700. */
  38701. export class VirtualJoysticksCamera extends FreeCamera {
  38702. /**
  38703. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38704. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38705. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38706. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38707. * @param name Define the name of the camera in the scene
  38708. * @param position Define the start position of the camera in the scene
  38709. * @param scene Define the scene the camera belongs to
  38710. */
  38711. constructor(name: string, position: Vector3, scene: Scene);
  38712. /**
  38713. * Gets the current object class name.
  38714. * @return the class name
  38715. */
  38716. getClassName(): string;
  38717. }
  38718. }
  38719. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38720. import { Matrix } from "babylonjs/Maths/math";
  38721. /**
  38722. * This represents all the required metrics to create a VR camera.
  38723. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38724. */
  38725. export class VRCameraMetrics {
  38726. /**
  38727. * Define the horizontal resolution off the screen.
  38728. */
  38729. hResolution: number;
  38730. /**
  38731. * Define the vertical resolution off the screen.
  38732. */
  38733. vResolution: number;
  38734. /**
  38735. * Define the horizontal screen size.
  38736. */
  38737. hScreenSize: number;
  38738. /**
  38739. * Define the vertical screen size.
  38740. */
  38741. vScreenSize: number;
  38742. /**
  38743. * Define the vertical screen center position.
  38744. */
  38745. vScreenCenter: number;
  38746. /**
  38747. * Define the distance of the eyes to the screen.
  38748. */
  38749. eyeToScreenDistance: number;
  38750. /**
  38751. * Define the distance between both lenses
  38752. */
  38753. lensSeparationDistance: number;
  38754. /**
  38755. * Define the distance between both viewer's eyes.
  38756. */
  38757. interpupillaryDistance: number;
  38758. /**
  38759. * Define the distortion factor of the VR postprocess.
  38760. * Please, touch with care.
  38761. */
  38762. distortionK: number[];
  38763. /**
  38764. * Define the chromatic aberration correction factors for the VR post process.
  38765. */
  38766. chromaAbCorrection: number[];
  38767. /**
  38768. * Define the scale factor of the post process.
  38769. * The smaller the better but the slower.
  38770. */
  38771. postProcessScaleFactor: number;
  38772. /**
  38773. * Define an offset for the lens center.
  38774. */
  38775. lensCenterOffset: number;
  38776. /**
  38777. * Define if the current vr camera should compensate the distortion of the lense or not.
  38778. */
  38779. compensateDistortion: boolean;
  38780. /**
  38781. * Defines if multiview should be enabled when rendering (Default: false)
  38782. */
  38783. multiviewEnabled: boolean;
  38784. /**
  38785. * Gets the rendering aspect ratio based on the provided resolutions.
  38786. */
  38787. readonly aspectRatio: number;
  38788. /**
  38789. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38790. */
  38791. readonly aspectRatioFov: number;
  38792. /**
  38793. * @hidden
  38794. */
  38795. readonly leftHMatrix: Matrix;
  38796. /**
  38797. * @hidden
  38798. */
  38799. readonly rightHMatrix: Matrix;
  38800. /**
  38801. * @hidden
  38802. */
  38803. readonly leftPreViewMatrix: Matrix;
  38804. /**
  38805. * @hidden
  38806. */
  38807. readonly rightPreViewMatrix: Matrix;
  38808. /**
  38809. * Get the default VRMetrics based on the most generic setup.
  38810. * @returns the default vr metrics
  38811. */
  38812. static GetDefault(): VRCameraMetrics;
  38813. }
  38814. }
  38815. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38816. /** @hidden */
  38817. export var vrDistortionCorrectionPixelShader: {
  38818. name: string;
  38819. shader: string;
  38820. };
  38821. }
  38822. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38823. import { Camera } from "babylonjs/Cameras/camera";
  38824. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38825. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38826. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38827. /**
  38828. * VRDistortionCorrectionPostProcess used for mobile VR
  38829. */
  38830. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38831. private _isRightEye;
  38832. private _distortionFactors;
  38833. private _postProcessScaleFactor;
  38834. private _lensCenterOffset;
  38835. private _scaleIn;
  38836. private _scaleFactor;
  38837. private _lensCenter;
  38838. /**
  38839. * Initializes the VRDistortionCorrectionPostProcess
  38840. * @param name The name of the effect.
  38841. * @param camera The camera to apply the render pass to.
  38842. * @param isRightEye If this is for the right eye distortion
  38843. * @param vrMetrics All the required metrics for the VR camera
  38844. */
  38845. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38846. }
  38847. }
  38848. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38849. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38850. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38851. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38852. import { Scene } from "babylonjs/scene";
  38853. import { Vector3 } from "babylonjs/Maths/math";
  38854. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38855. import "babylonjs/Cameras/RigModes/vrRigMode";
  38856. /**
  38857. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38858. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38859. */
  38860. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38861. /**
  38862. * Creates a new VRDeviceOrientationArcRotateCamera
  38863. * @param name defines camera name
  38864. * @param alpha defines the camera rotation along the logitudinal axis
  38865. * @param beta defines the camera rotation along the latitudinal axis
  38866. * @param radius defines the camera distance from its target
  38867. * @param target defines the camera target
  38868. * @param scene defines the scene the camera belongs to
  38869. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38870. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38871. */
  38872. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38873. /**
  38874. * Gets camera class name
  38875. * @returns VRDeviceOrientationArcRotateCamera
  38876. */
  38877. getClassName(): string;
  38878. }
  38879. }
  38880. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38881. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38882. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38883. import { Scene } from "babylonjs/scene";
  38884. import { Vector3 } from "babylonjs/Maths/math";
  38885. import "babylonjs/Cameras/RigModes/vrRigMode";
  38886. /**
  38887. * Camera used to simulate VR rendering (based on FreeCamera)
  38888. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38889. */
  38890. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38891. /**
  38892. * Creates a new VRDeviceOrientationFreeCamera
  38893. * @param name defines camera name
  38894. * @param position defines the start position of the camera
  38895. * @param scene defines the scene the camera belongs to
  38896. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38897. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38898. */
  38899. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38900. /**
  38901. * Gets camera class name
  38902. * @returns VRDeviceOrientationFreeCamera
  38903. */
  38904. getClassName(): string;
  38905. }
  38906. }
  38907. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38908. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38909. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38910. import { Scene } from "babylonjs/scene";
  38911. import { Vector3 } from "babylonjs/Maths/math";
  38912. /**
  38913. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38914. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38915. */
  38916. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38917. /**
  38918. * Creates a new VRDeviceOrientationGamepadCamera
  38919. * @param name defines camera name
  38920. * @param position defines the start position of the camera
  38921. * @param scene defines the scene the camera belongs to
  38922. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38923. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38924. */
  38925. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38926. /**
  38927. * Gets camera class name
  38928. * @returns VRDeviceOrientationGamepadCamera
  38929. */
  38930. getClassName(): string;
  38931. }
  38932. }
  38933. declare module "babylonjs/Gamepads/xboxGamepad" {
  38934. import { Observable } from "babylonjs/Misc/observable";
  38935. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38936. /**
  38937. * Defines supported buttons for XBox360 compatible gamepads
  38938. */
  38939. export enum Xbox360Button {
  38940. /** A */
  38941. A = 0,
  38942. /** B */
  38943. B = 1,
  38944. /** X */
  38945. X = 2,
  38946. /** Y */
  38947. Y = 3,
  38948. /** Start */
  38949. Start = 4,
  38950. /** Back */
  38951. Back = 5,
  38952. /** Left button */
  38953. LB = 6,
  38954. /** Right button */
  38955. RB = 7,
  38956. /** Left stick */
  38957. LeftStick = 8,
  38958. /** Right stick */
  38959. RightStick = 9
  38960. }
  38961. /** Defines values for XBox360 DPad */
  38962. export enum Xbox360Dpad {
  38963. /** Up */
  38964. Up = 0,
  38965. /** Down */
  38966. Down = 1,
  38967. /** Left */
  38968. Left = 2,
  38969. /** Right */
  38970. Right = 3
  38971. }
  38972. /**
  38973. * Defines a XBox360 gamepad
  38974. */
  38975. export class Xbox360Pad extends Gamepad {
  38976. private _leftTrigger;
  38977. private _rightTrigger;
  38978. private _onlefttriggerchanged;
  38979. private _onrighttriggerchanged;
  38980. private _onbuttondown;
  38981. private _onbuttonup;
  38982. private _ondpaddown;
  38983. private _ondpadup;
  38984. /** Observable raised when a button is pressed */
  38985. onButtonDownObservable: Observable<Xbox360Button>;
  38986. /** Observable raised when a button is released */
  38987. onButtonUpObservable: Observable<Xbox360Button>;
  38988. /** Observable raised when a pad is pressed */
  38989. onPadDownObservable: Observable<Xbox360Dpad>;
  38990. /** Observable raised when a pad is released */
  38991. onPadUpObservable: Observable<Xbox360Dpad>;
  38992. private _buttonA;
  38993. private _buttonB;
  38994. private _buttonX;
  38995. private _buttonY;
  38996. private _buttonBack;
  38997. private _buttonStart;
  38998. private _buttonLB;
  38999. private _buttonRB;
  39000. private _buttonLeftStick;
  39001. private _buttonRightStick;
  39002. private _dPadUp;
  39003. private _dPadDown;
  39004. private _dPadLeft;
  39005. private _dPadRight;
  39006. private _isXboxOnePad;
  39007. /**
  39008. * Creates a new XBox360 gamepad object
  39009. * @param id defines the id of this gamepad
  39010. * @param index defines its index
  39011. * @param gamepad defines the internal HTML gamepad object
  39012. * @param xboxOne defines if it is a XBox One gamepad
  39013. */
  39014. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39015. /**
  39016. * Defines the callback to call when left trigger is pressed
  39017. * @param callback defines the callback to use
  39018. */
  39019. onlefttriggerchanged(callback: (value: number) => void): void;
  39020. /**
  39021. * Defines the callback to call when right trigger is pressed
  39022. * @param callback defines the callback to use
  39023. */
  39024. onrighttriggerchanged(callback: (value: number) => void): void;
  39025. /**
  39026. * Gets the left trigger value
  39027. */
  39028. /**
  39029. * Sets the left trigger value
  39030. */
  39031. leftTrigger: number;
  39032. /**
  39033. * Gets the right trigger value
  39034. */
  39035. /**
  39036. * Sets the right trigger value
  39037. */
  39038. rightTrigger: number;
  39039. /**
  39040. * Defines the callback to call when a button is pressed
  39041. * @param callback defines the callback to use
  39042. */
  39043. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39044. /**
  39045. * Defines the callback to call when a button is released
  39046. * @param callback defines the callback to use
  39047. */
  39048. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39049. /**
  39050. * Defines the callback to call when a pad is pressed
  39051. * @param callback defines the callback to use
  39052. */
  39053. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39054. /**
  39055. * Defines the callback to call when a pad is released
  39056. * @param callback defines the callback to use
  39057. */
  39058. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39059. private _setButtonValue;
  39060. private _setDPadValue;
  39061. /**
  39062. * Gets the value of the `A` button
  39063. */
  39064. /**
  39065. * Sets the value of the `A` button
  39066. */
  39067. buttonA: number;
  39068. /**
  39069. * Gets the value of the `B` button
  39070. */
  39071. /**
  39072. * Sets the value of the `B` button
  39073. */
  39074. buttonB: number;
  39075. /**
  39076. * Gets the value of the `X` button
  39077. */
  39078. /**
  39079. * Sets the value of the `X` button
  39080. */
  39081. buttonX: number;
  39082. /**
  39083. * Gets the value of the `Y` button
  39084. */
  39085. /**
  39086. * Sets the value of the `Y` button
  39087. */
  39088. buttonY: number;
  39089. /**
  39090. * Gets the value of the `Start` button
  39091. */
  39092. /**
  39093. * Sets the value of the `Start` button
  39094. */
  39095. buttonStart: number;
  39096. /**
  39097. * Gets the value of the `Back` button
  39098. */
  39099. /**
  39100. * Sets the value of the `Back` button
  39101. */
  39102. buttonBack: number;
  39103. /**
  39104. * Gets the value of the `Left` button
  39105. */
  39106. /**
  39107. * Sets the value of the `Left` button
  39108. */
  39109. buttonLB: number;
  39110. /**
  39111. * Gets the value of the `Right` button
  39112. */
  39113. /**
  39114. * Sets the value of the `Right` button
  39115. */
  39116. buttonRB: number;
  39117. /**
  39118. * Gets the value of the Left joystick
  39119. */
  39120. /**
  39121. * Sets the value of the Left joystick
  39122. */
  39123. buttonLeftStick: number;
  39124. /**
  39125. * Gets the value of the Right joystick
  39126. */
  39127. /**
  39128. * Sets the value of the Right joystick
  39129. */
  39130. buttonRightStick: number;
  39131. /**
  39132. * Gets the value of D-pad up
  39133. */
  39134. /**
  39135. * Sets the value of D-pad up
  39136. */
  39137. dPadUp: number;
  39138. /**
  39139. * Gets the value of D-pad down
  39140. */
  39141. /**
  39142. * Sets the value of D-pad down
  39143. */
  39144. dPadDown: number;
  39145. /**
  39146. * Gets the value of D-pad left
  39147. */
  39148. /**
  39149. * Sets the value of D-pad left
  39150. */
  39151. dPadLeft: number;
  39152. /**
  39153. * Gets the value of D-pad right
  39154. */
  39155. /**
  39156. * Sets the value of D-pad right
  39157. */
  39158. dPadRight: number;
  39159. /**
  39160. * Force the gamepad to synchronize with device values
  39161. */
  39162. update(): void;
  39163. /**
  39164. * Disposes the gamepad
  39165. */
  39166. dispose(): void;
  39167. }
  39168. }
  39169. declare module "babylonjs/Materials/pushMaterial" {
  39170. import { Nullable } from "babylonjs/types";
  39171. import { Scene } from "babylonjs/scene";
  39172. import { Matrix } from "babylonjs/Maths/math";
  39173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39174. import { Mesh } from "babylonjs/Meshes/mesh";
  39175. import { Material } from "babylonjs/Materials/material";
  39176. import { Effect } from "babylonjs/Materials/effect";
  39177. /**
  39178. * Base class of materials working in push mode in babylon JS
  39179. * @hidden
  39180. */
  39181. export class PushMaterial extends Material {
  39182. protected _activeEffect: Effect;
  39183. protected _normalMatrix: Matrix;
  39184. /**
  39185. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39186. * This means that the material can keep using a previous shader while a new one is being compiled.
  39187. * This is mostly used when shader parallel compilation is supported (true by default)
  39188. */
  39189. allowShaderHotSwapping: boolean;
  39190. constructor(name: string, scene: Scene);
  39191. getEffect(): Effect;
  39192. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39193. /**
  39194. * Binds the given world matrix to the active effect
  39195. *
  39196. * @param world the matrix to bind
  39197. */
  39198. bindOnlyWorldMatrix(world: Matrix): void;
  39199. /**
  39200. * Binds the given normal matrix to the active effect
  39201. *
  39202. * @param normalMatrix the matrix to bind
  39203. */
  39204. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39205. bind(world: Matrix, mesh?: Mesh): void;
  39206. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39207. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39208. }
  39209. }
  39210. declare module "babylonjs/Materials/materialFlags" {
  39211. /**
  39212. * This groups all the flags used to control the materials channel.
  39213. */
  39214. export class MaterialFlags {
  39215. private static _DiffuseTextureEnabled;
  39216. /**
  39217. * Are diffuse textures enabled in the application.
  39218. */
  39219. static DiffuseTextureEnabled: boolean;
  39220. private static _AmbientTextureEnabled;
  39221. /**
  39222. * Are ambient textures enabled in the application.
  39223. */
  39224. static AmbientTextureEnabled: boolean;
  39225. private static _OpacityTextureEnabled;
  39226. /**
  39227. * Are opacity textures enabled in the application.
  39228. */
  39229. static OpacityTextureEnabled: boolean;
  39230. private static _ReflectionTextureEnabled;
  39231. /**
  39232. * Are reflection textures enabled in the application.
  39233. */
  39234. static ReflectionTextureEnabled: boolean;
  39235. private static _EmissiveTextureEnabled;
  39236. /**
  39237. * Are emissive textures enabled in the application.
  39238. */
  39239. static EmissiveTextureEnabled: boolean;
  39240. private static _SpecularTextureEnabled;
  39241. /**
  39242. * Are specular textures enabled in the application.
  39243. */
  39244. static SpecularTextureEnabled: boolean;
  39245. private static _BumpTextureEnabled;
  39246. /**
  39247. * Are bump textures enabled in the application.
  39248. */
  39249. static BumpTextureEnabled: boolean;
  39250. private static _LightmapTextureEnabled;
  39251. /**
  39252. * Are lightmap textures enabled in the application.
  39253. */
  39254. static LightmapTextureEnabled: boolean;
  39255. private static _RefractionTextureEnabled;
  39256. /**
  39257. * Are refraction textures enabled in the application.
  39258. */
  39259. static RefractionTextureEnabled: boolean;
  39260. private static _ColorGradingTextureEnabled;
  39261. /**
  39262. * Are color grading textures enabled in the application.
  39263. */
  39264. static ColorGradingTextureEnabled: boolean;
  39265. private static _FresnelEnabled;
  39266. /**
  39267. * Are fresnels enabled in the application.
  39268. */
  39269. static FresnelEnabled: boolean;
  39270. private static _ClearCoatTextureEnabled;
  39271. /**
  39272. * Are clear coat textures enabled in the application.
  39273. */
  39274. static ClearCoatTextureEnabled: boolean;
  39275. private static _ClearCoatBumpTextureEnabled;
  39276. /**
  39277. * Are clear coat bump textures enabled in the application.
  39278. */
  39279. static ClearCoatBumpTextureEnabled: boolean;
  39280. private static _ClearCoatTintTextureEnabled;
  39281. /**
  39282. * Are clear coat tint textures enabled in the application.
  39283. */
  39284. static ClearCoatTintTextureEnabled: boolean;
  39285. private static _SheenTextureEnabled;
  39286. /**
  39287. * Are sheen textures enabled in the application.
  39288. */
  39289. static SheenTextureEnabled: boolean;
  39290. private static _AnisotropicTextureEnabled;
  39291. /**
  39292. * Are anisotropic textures enabled in the application.
  39293. */
  39294. static AnisotropicTextureEnabled: boolean;
  39295. private static _ThicknessTextureEnabled;
  39296. /**
  39297. * Are thickness textures enabled in the application.
  39298. */
  39299. static ThicknessTextureEnabled: boolean;
  39300. }
  39301. }
  39302. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39303. /** @hidden */
  39304. export var defaultFragmentDeclaration: {
  39305. name: string;
  39306. shader: string;
  39307. };
  39308. }
  39309. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39310. /** @hidden */
  39311. export var defaultUboDeclaration: {
  39312. name: string;
  39313. shader: string;
  39314. };
  39315. }
  39316. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39317. /** @hidden */
  39318. export var lightFragmentDeclaration: {
  39319. name: string;
  39320. shader: string;
  39321. };
  39322. }
  39323. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39324. /** @hidden */
  39325. export var lightUboDeclaration: {
  39326. name: string;
  39327. shader: string;
  39328. };
  39329. }
  39330. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39331. /** @hidden */
  39332. export var lightsFragmentFunctions: {
  39333. name: string;
  39334. shader: string;
  39335. };
  39336. }
  39337. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39338. /** @hidden */
  39339. export var shadowsFragmentFunctions: {
  39340. name: string;
  39341. shader: string;
  39342. };
  39343. }
  39344. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39345. /** @hidden */
  39346. export var fresnelFunction: {
  39347. name: string;
  39348. shader: string;
  39349. };
  39350. }
  39351. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39352. /** @hidden */
  39353. export var reflectionFunction: {
  39354. name: string;
  39355. shader: string;
  39356. };
  39357. }
  39358. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39359. /** @hidden */
  39360. export var bumpFragmentFunctions: {
  39361. name: string;
  39362. shader: string;
  39363. };
  39364. }
  39365. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39366. /** @hidden */
  39367. export var logDepthDeclaration: {
  39368. name: string;
  39369. shader: string;
  39370. };
  39371. }
  39372. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39373. /** @hidden */
  39374. export var bumpFragment: {
  39375. name: string;
  39376. shader: string;
  39377. };
  39378. }
  39379. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39380. /** @hidden */
  39381. export var depthPrePass: {
  39382. name: string;
  39383. shader: string;
  39384. };
  39385. }
  39386. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39387. /** @hidden */
  39388. export var lightFragment: {
  39389. name: string;
  39390. shader: string;
  39391. };
  39392. }
  39393. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39394. /** @hidden */
  39395. export var logDepthFragment: {
  39396. name: string;
  39397. shader: string;
  39398. };
  39399. }
  39400. declare module "babylonjs/Shaders/default.fragment" {
  39401. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39402. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39403. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39404. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39405. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39406. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39407. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39408. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39409. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39410. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39411. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39412. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39413. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39414. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39415. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39416. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39417. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39418. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39419. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39420. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39421. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39422. /** @hidden */
  39423. export var defaultPixelShader: {
  39424. name: string;
  39425. shader: string;
  39426. };
  39427. }
  39428. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39429. /** @hidden */
  39430. export var defaultVertexDeclaration: {
  39431. name: string;
  39432. shader: string;
  39433. };
  39434. }
  39435. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39436. /** @hidden */
  39437. export var bumpVertexDeclaration: {
  39438. name: string;
  39439. shader: string;
  39440. };
  39441. }
  39442. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39443. /** @hidden */
  39444. export var bumpVertex: {
  39445. name: string;
  39446. shader: string;
  39447. };
  39448. }
  39449. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39450. /** @hidden */
  39451. export var fogVertex: {
  39452. name: string;
  39453. shader: string;
  39454. };
  39455. }
  39456. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39457. /** @hidden */
  39458. export var shadowsVertex: {
  39459. name: string;
  39460. shader: string;
  39461. };
  39462. }
  39463. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39464. /** @hidden */
  39465. export var pointCloudVertex: {
  39466. name: string;
  39467. shader: string;
  39468. };
  39469. }
  39470. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39471. /** @hidden */
  39472. export var logDepthVertex: {
  39473. name: string;
  39474. shader: string;
  39475. };
  39476. }
  39477. declare module "babylonjs/Shaders/default.vertex" {
  39478. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39479. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39480. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39481. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39482. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39483. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39484. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39485. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39486. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39487. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39488. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39489. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39490. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39491. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39492. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39493. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39494. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39495. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39496. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39497. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39498. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39499. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39500. /** @hidden */
  39501. export var defaultVertexShader: {
  39502. name: string;
  39503. shader: string;
  39504. };
  39505. }
  39506. declare module "babylonjs/Materials/standardMaterial" {
  39507. import { SmartArray } from "babylonjs/Misc/smartArray";
  39508. import { IAnimatable } from "babylonjs/Misc/tools";
  39509. import { Nullable } from "babylonjs/types";
  39510. import { Scene } from "babylonjs/scene";
  39511. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39512. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39513. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39514. import { Mesh } from "babylonjs/Meshes/mesh";
  39515. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39516. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39517. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39518. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39519. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39520. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39521. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39522. import "babylonjs/Shaders/default.fragment";
  39523. import "babylonjs/Shaders/default.vertex";
  39524. /** @hidden */
  39525. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39526. MAINUV1: boolean;
  39527. MAINUV2: boolean;
  39528. DIFFUSE: boolean;
  39529. DIFFUSEDIRECTUV: number;
  39530. AMBIENT: boolean;
  39531. AMBIENTDIRECTUV: number;
  39532. OPACITY: boolean;
  39533. OPACITYDIRECTUV: number;
  39534. OPACITYRGB: boolean;
  39535. REFLECTION: boolean;
  39536. EMISSIVE: boolean;
  39537. EMISSIVEDIRECTUV: number;
  39538. SPECULAR: boolean;
  39539. SPECULARDIRECTUV: number;
  39540. BUMP: boolean;
  39541. BUMPDIRECTUV: number;
  39542. PARALLAX: boolean;
  39543. PARALLAXOCCLUSION: boolean;
  39544. SPECULAROVERALPHA: boolean;
  39545. CLIPPLANE: boolean;
  39546. CLIPPLANE2: boolean;
  39547. CLIPPLANE3: boolean;
  39548. CLIPPLANE4: boolean;
  39549. ALPHATEST: boolean;
  39550. DEPTHPREPASS: boolean;
  39551. ALPHAFROMDIFFUSE: boolean;
  39552. POINTSIZE: boolean;
  39553. FOG: boolean;
  39554. SPECULARTERM: boolean;
  39555. DIFFUSEFRESNEL: boolean;
  39556. OPACITYFRESNEL: boolean;
  39557. REFLECTIONFRESNEL: boolean;
  39558. REFRACTIONFRESNEL: boolean;
  39559. EMISSIVEFRESNEL: boolean;
  39560. FRESNEL: boolean;
  39561. NORMAL: boolean;
  39562. UV1: boolean;
  39563. UV2: boolean;
  39564. VERTEXCOLOR: boolean;
  39565. VERTEXALPHA: boolean;
  39566. NUM_BONE_INFLUENCERS: number;
  39567. BonesPerMesh: number;
  39568. BONETEXTURE: boolean;
  39569. INSTANCES: boolean;
  39570. GLOSSINESS: boolean;
  39571. ROUGHNESS: boolean;
  39572. EMISSIVEASILLUMINATION: boolean;
  39573. LINKEMISSIVEWITHDIFFUSE: boolean;
  39574. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39575. LIGHTMAP: boolean;
  39576. LIGHTMAPDIRECTUV: number;
  39577. OBJECTSPACE_NORMALMAP: boolean;
  39578. USELIGHTMAPASSHADOWMAP: boolean;
  39579. REFLECTIONMAP_3D: boolean;
  39580. REFLECTIONMAP_SPHERICAL: boolean;
  39581. REFLECTIONMAP_PLANAR: boolean;
  39582. REFLECTIONMAP_CUBIC: boolean;
  39583. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39584. REFLECTIONMAP_PROJECTION: boolean;
  39585. REFLECTIONMAP_SKYBOX: boolean;
  39586. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39587. REFLECTIONMAP_EXPLICIT: boolean;
  39588. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39589. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39590. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39591. INVERTCUBICMAP: boolean;
  39592. LOGARITHMICDEPTH: boolean;
  39593. REFRACTION: boolean;
  39594. REFRACTIONMAP_3D: boolean;
  39595. REFLECTIONOVERALPHA: boolean;
  39596. TWOSIDEDLIGHTING: boolean;
  39597. SHADOWFLOAT: boolean;
  39598. MORPHTARGETS: boolean;
  39599. MORPHTARGETS_NORMAL: boolean;
  39600. MORPHTARGETS_TANGENT: boolean;
  39601. NUM_MORPH_INFLUENCERS: number;
  39602. NONUNIFORMSCALING: boolean;
  39603. PREMULTIPLYALPHA: boolean;
  39604. IMAGEPROCESSING: boolean;
  39605. VIGNETTE: boolean;
  39606. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39607. VIGNETTEBLENDMODEOPAQUE: boolean;
  39608. TONEMAPPING: boolean;
  39609. TONEMAPPING_ACES: boolean;
  39610. CONTRAST: boolean;
  39611. COLORCURVES: boolean;
  39612. COLORGRADING: boolean;
  39613. COLORGRADING3D: boolean;
  39614. SAMPLER3DGREENDEPTH: boolean;
  39615. SAMPLER3DBGRMAP: boolean;
  39616. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39617. MULTIVIEW: boolean;
  39618. /**
  39619. * If the reflection texture on this material is in linear color space
  39620. * @hidden
  39621. */
  39622. IS_REFLECTION_LINEAR: boolean;
  39623. /**
  39624. * If the refraction texture on this material is in linear color space
  39625. * @hidden
  39626. */
  39627. IS_REFRACTION_LINEAR: boolean;
  39628. EXPOSURE: boolean;
  39629. constructor();
  39630. setReflectionMode(modeToEnable: string): void;
  39631. }
  39632. /**
  39633. * This is the default material used in Babylon. It is the best trade off between quality
  39634. * and performances.
  39635. * @see http://doc.babylonjs.com/babylon101/materials
  39636. */
  39637. export class StandardMaterial extends PushMaterial {
  39638. private _diffuseTexture;
  39639. /**
  39640. * The basic texture of the material as viewed under a light.
  39641. */
  39642. diffuseTexture: Nullable<BaseTexture>;
  39643. private _ambientTexture;
  39644. /**
  39645. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39646. */
  39647. ambientTexture: Nullable<BaseTexture>;
  39648. private _opacityTexture;
  39649. /**
  39650. * Define the transparency of the material from a texture.
  39651. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39652. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39653. */
  39654. opacityTexture: Nullable<BaseTexture>;
  39655. private _reflectionTexture;
  39656. /**
  39657. * Define the texture used to display the reflection.
  39658. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39659. */
  39660. reflectionTexture: Nullable<BaseTexture>;
  39661. private _emissiveTexture;
  39662. /**
  39663. * Define texture of the material as if self lit.
  39664. * This will be mixed in the final result even in the absence of light.
  39665. */
  39666. emissiveTexture: Nullable<BaseTexture>;
  39667. private _specularTexture;
  39668. /**
  39669. * Define how the color and intensity of the highlight given by the light in the material.
  39670. */
  39671. specularTexture: Nullable<BaseTexture>;
  39672. private _bumpTexture;
  39673. /**
  39674. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39675. * 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.
  39676. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39677. */
  39678. bumpTexture: Nullable<BaseTexture>;
  39679. private _lightmapTexture;
  39680. /**
  39681. * Complex lighting can be computationally expensive to compute at runtime.
  39682. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39683. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39684. */
  39685. lightmapTexture: Nullable<BaseTexture>;
  39686. private _refractionTexture;
  39687. /**
  39688. * Define the texture used to display the refraction.
  39689. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39690. */
  39691. refractionTexture: Nullable<BaseTexture>;
  39692. /**
  39693. * The color of the material lit by the environmental background lighting.
  39694. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39695. */
  39696. ambientColor: Color3;
  39697. /**
  39698. * The basic color of the material as viewed under a light.
  39699. */
  39700. diffuseColor: Color3;
  39701. /**
  39702. * Define how the color and intensity of the highlight given by the light in the material.
  39703. */
  39704. specularColor: Color3;
  39705. /**
  39706. * Define the color of the material as if self lit.
  39707. * This will be mixed in the final result even in the absence of light.
  39708. */
  39709. emissiveColor: Color3;
  39710. /**
  39711. * Defines how sharp are the highlights in the material.
  39712. * The bigger the value the sharper giving a more glossy feeling to the result.
  39713. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39714. */
  39715. specularPower: number;
  39716. private _useAlphaFromDiffuseTexture;
  39717. /**
  39718. * Does the transparency come from the diffuse texture alpha channel.
  39719. */
  39720. useAlphaFromDiffuseTexture: boolean;
  39721. private _useEmissiveAsIllumination;
  39722. /**
  39723. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39724. */
  39725. useEmissiveAsIllumination: boolean;
  39726. private _linkEmissiveWithDiffuse;
  39727. /**
  39728. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39729. * the emissive level when the final color is close to one.
  39730. */
  39731. linkEmissiveWithDiffuse: boolean;
  39732. private _useSpecularOverAlpha;
  39733. /**
  39734. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39735. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39736. */
  39737. useSpecularOverAlpha: boolean;
  39738. private _useReflectionOverAlpha;
  39739. /**
  39740. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39741. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39742. */
  39743. useReflectionOverAlpha: boolean;
  39744. private _disableLighting;
  39745. /**
  39746. * Does lights from the scene impacts this material.
  39747. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39748. */
  39749. disableLighting: boolean;
  39750. private _useObjectSpaceNormalMap;
  39751. /**
  39752. * Allows using an object space normal map (instead of tangent space).
  39753. */
  39754. useObjectSpaceNormalMap: boolean;
  39755. private _useParallax;
  39756. /**
  39757. * Is parallax enabled or not.
  39758. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39759. */
  39760. useParallax: boolean;
  39761. private _useParallaxOcclusion;
  39762. /**
  39763. * Is parallax occlusion enabled or not.
  39764. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39765. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39766. */
  39767. useParallaxOcclusion: boolean;
  39768. /**
  39769. * 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.
  39770. */
  39771. parallaxScaleBias: number;
  39772. private _roughness;
  39773. /**
  39774. * Helps to define how blurry the reflections should appears in the material.
  39775. */
  39776. roughness: number;
  39777. /**
  39778. * In case of refraction, define the value of the indice of refraction.
  39779. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39780. */
  39781. indexOfRefraction: number;
  39782. /**
  39783. * Invert the refraction texture alongside the y axis.
  39784. * It can be useful with procedural textures or probe for instance.
  39785. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39786. */
  39787. invertRefractionY: boolean;
  39788. /**
  39789. * Defines the alpha limits in alpha test mode.
  39790. */
  39791. alphaCutOff: number;
  39792. private _useLightmapAsShadowmap;
  39793. /**
  39794. * In case of light mapping, define whether the map contains light or shadow informations.
  39795. */
  39796. useLightmapAsShadowmap: boolean;
  39797. private _diffuseFresnelParameters;
  39798. /**
  39799. * Define the diffuse fresnel parameters of the material.
  39800. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39801. */
  39802. diffuseFresnelParameters: FresnelParameters;
  39803. private _opacityFresnelParameters;
  39804. /**
  39805. * Define the opacity fresnel parameters of the material.
  39806. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39807. */
  39808. opacityFresnelParameters: FresnelParameters;
  39809. private _reflectionFresnelParameters;
  39810. /**
  39811. * Define the reflection fresnel parameters of the material.
  39812. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39813. */
  39814. reflectionFresnelParameters: FresnelParameters;
  39815. private _refractionFresnelParameters;
  39816. /**
  39817. * Define the refraction fresnel parameters of the material.
  39818. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39819. */
  39820. refractionFresnelParameters: FresnelParameters;
  39821. private _emissiveFresnelParameters;
  39822. /**
  39823. * Define the emissive fresnel parameters of the material.
  39824. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39825. */
  39826. emissiveFresnelParameters: FresnelParameters;
  39827. private _useReflectionFresnelFromSpecular;
  39828. /**
  39829. * If true automatically deducts the fresnels values from the material specularity.
  39830. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39831. */
  39832. useReflectionFresnelFromSpecular: boolean;
  39833. private _useGlossinessFromSpecularMapAlpha;
  39834. /**
  39835. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39836. */
  39837. useGlossinessFromSpecularMapAlpha: boolean;
  39838. private _maxSimultaneousLights;
  39839. /**
  39840. * Defines the maximum number of lights that can be used in the material
  39841. */
  39842. maxSimultaneousLights: number;
  39843. private _invertNormalMapX;
  39844. /**
  39845. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39846. */
  39847. invertNormalMapX: boolean;
  39848. private _invertNormalMapY;
  39849. /**
  39850. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39851. */
  39852. invertNormalMapY: boolean;
  39853. private _twoSidedLighting;
  39854. /**
  39855. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39856. */
  39857. twoSidedLighting: boolean;
  39858. /**
  39859. * Default configuration related to image processing available in the standard Material.
  39860. */
  39861. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39862. /**
  39863. * Gets the image processing configuration used either in this material.
  39864. */
  39865. /**
  39866. * Sets the Default image processing configuration used either in the this material.
  39867. *
  39868. * If sets to null, the scene one is in use.
  39869. */
  39870. imageProcessingConfiguration: ImageProcessingConfiguration;
  39871. /**
  39872. * Keep track of the image processing observer to allow dispose and replace.
  39873. */
  39874. private _imageProcessingObserver;
  39875. /**
  39876. * Attaches a new image processing configuration to the Standard Material.
  39877. * @param configuration
  39878. */
  39879. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39880. /**
  39881. * Gets wether the color curves effect is enabled.
  39882. */
  39883. /**
  39884. * Sets wether the color curves effect is enabled.
  39885. */
  39886. cameraColorCurvesEnabled: boolean;
  39887. /**
  39888. * Gets wether the color grading effect is enabled.
  39889. */
  39890. /**
  39891. * Gets wether the color grading effect is enabled.
  39892. */
  39893. cameraColorGradingEnabled: boolean;
  39894. /**
  39895. * Gets wether tonemapping is enabled or not.
  39896. */
  39897. /**
  39898. * Sets wether tonemapping is enabled or not
  39899. */
  39900. cameraToneMappingEnabled: boolean;
  39901. /**
  39902. * The camera exposure used on this material.
  39903. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39904. * This corresponds to a photographic exposure.
  39905. */
  39906. /**
  39907. * The camera exposure used on this material.
  39908. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39909. * This corresponds to a photographic exposure.
  39910. */
  39911. cameraExposure: number;
  39912. /**
  39913. * Gets The camera contrast used on this material.
  39914. */
  39915. /**
  39916. * Sets The camera contrast used on this material.
  39917. */
  39918. cameraContrast: number;
  39919. /**
  39920. * Gets the Color Grading 2D Lookup Texture.
  39921. */
  39922. /**
  39923. * Sets the Color Grading 2D Lookup Texture.
  39924. */
  39925. cameraColorGradingTexture: Nullable<BaseTexture>;
  39926. /**
  39927. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39928. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39929. * 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;
  39930. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39931. */
  39932. /**
  39933. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39934. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39935. * 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;
  39936. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39937. */
  39938. cameraColorCurves: Nullable<ColorCurves>;
  39939. /**
  39940. * Custom callback helping to override the default shader used in the material.
  39941. */
  39942. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39943. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39944. protected _worldViewProjectionMatrix: Matrix;
  39945. protected _globalAmbientColor: Color3;
  39946. protected _useLogarithmicDepth: boolean;
  39947. /**
  39948. * Instantiates a new standard material.
  39949. * This is the default material used in Babylon. It is the best trade off between quality
  39950. * and performances.
  39951. * @see http://doc.babylonjs.com/babylon101/materials
  39952. * @param name Define the name of the material in the scene
  39953. * @param scene Define the scene the material belong to
  39954. */
  39955. constructor(name: string, scene: Scene);
  39956. /**
  39957. * Gets a boolean indicating that current material needs to register RTT
  39958. */
  39959. readonly hasRenderTargetTextures: boolean;
  39960. /**
  39961. * Gets the current class name of the material e.g. "StandardMaterial"
  39962. * Mainly use in serialization.
  39963. * @returns the class name
  39964. */
  39965. getClassName(): string;
  39966. /**
  39967. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39968. * You can try switching to logarithmic depth.
  39969. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39970. */
  39971. useLogarithmicDepth: boolean;
  39972. /**
  39973. * Specifies if the material will require alpha blending
  39974. * @returns a boolean specifying if alpha blending is needed
  39975. */
  39976. needAlphaBlending(): boolean;
  39977. /**
  39978. * Specifies if this material should be rendered in alpha test mode
  39979. * @returns a boolean specifying if an alpha test is needed.
  39980. */
  39981. needAlphaTesting(): boolean;
  39982. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39983. /**
  39984. * Get the texture used for alpha test purpose.
  39985. * @returns the diffuse texture in case of the standard material.
  39986. */
  39987. getAlphaTestTexture(): Nullable<BaseTexture>;
  39988. /**
  39989. * Get if the submesh is ready to be used and all its information available.
  39990. * Child classes can use it to update shaders
  39991. * @param mesh defines the mesh to check
  39992. * @param subMesh defines which submesh to check
  39993. * @param useInstances specifies that instances should be used
  39994. * @returns a boolean indicating that the submesh is ready or not
  39995. */
  39996. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39997. /**
  39998. * Builds the material UBO layouts.
  39999. * Used internally during the effect preparation.
  40000. */
  40001. buildUniformLayout(): void;
  40002. /**
  40003. * Unbinds the material from the mesh
  40004. */
  40005. unbind(): void;
  40006. /**
  40007. * Binds the submesh to this material by preparing the effect and shader to draw
  40008. * @param world defines the world transformation matrix
  40009. * @param mesh defines the mesh containing the submesh
  40010. * @param subMesh defines the submesh to bind the material to
  40011. */
  40012. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40013. /**
  40014. * Get the list of animatables in the material.
  40015. * @returns the list of animatables object used in the material
  40016. */
  40017. getAnimatables(): IAnimatable[];
  40018. /**
  40019. * Gets the active textures from the material
  40020. * @returns an array of textures
  40021. */
  40022. getActiveTextures(): BaseTexture[];
  40023. /**
  40024. * Specifies if the material uses a texture
  40025. * @param texture defines the texture to check against the material
  40026. * @returns a boolean specifying if the material uses the texture
  40027. */
  40028. hasTexture(texture: BaseTexture): boolean;
  40029. /**
  40030. * Disposes the material
  40031. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40032. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40033. */
  40034. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40035. /**
  40036. * Makes a duplicate of the material, and gives it a new name
  40037. * @param name defines the new name for the duplicated material
  40038. * @returns the cloned material
  40039. */
  40040. clone(name: string): StandardMaterial;
  40041. /**
  40042. * Serializes this material in a JSON representation
  40043. * @returns the serialized material object
  40044. */
  40045. serialize(): any;
  40046. /**
  40047. * Creates a standard material from parsed material data
  40048. * @param source defines the JSON representation of the material
  40049. * @param scene defines the hosting scene
  40050. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40051. * @returns a new standard material
  40052. */
  40053. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40054. /**
  40055. * Are diffuse textures enabled in the application.
  40056. */
  40057. static DiffuseTextureEnabled: boolean;
  40058. /**
  40059. * Are ambient textures enabled in the application.
  40060. */
  40061. static AmbientTextureEnabled: boolean;
  40062. /**
  40063. * Are opacity textures enabled in the application.
  40064. */
  40065. static OpacityTextureEnabled: boolean;
  40066. /**
  40067. * Are reflection textures enabled in the application.
  40068. */
  40069. static ReflectionTextureEnabled: boolean;
  40070. /**
  40071. * Are emissive textures enabled in the application.
  40072. */
  40073. static EmissiveTextureEnabled: boolean;
  40074. /**
  40075. * Are specular textures enabled in the application.
  40076. */
  40077. static SpecularTextureEnabled: boolean;
  40078. /**
  40079. * Are bump textures enabled in the application.
  40080. */
  40081. static BumpTextureEnabled: boolean;
  40082. /**
  40083. * Are lightmap textures enabled in the application.
  40084. */
  40085. static LightmapTextureEnabled: boolean;
  40086. /**
  40087. * Are refraction textures enabled in the application.
  40088. */
  40089. static RefractionTextureEnabled: boolean;
  40090. /**
  40091. * Are color grading textures enabled in the application.
  40092. */
  40093. static ColorGradingTextureEnabled: boolean;
  40094. /**
  40095. * Are fresnels enabled in the application.
  40096. */
  40097. static FresnelEnabled: boolean;
  40098. }
  40099. }
  40100. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40101. import { Scene } from "babylonjs/scene";
  40102. import { Texture } from "babylonjs/Materials/Textures/texture";
  40103. /**
  40104. * A class extending Texture allowing drawing on a texture
  40105. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40106. */
  40107. export class DynamicTexture extends Texture {
  40108. private _generateMipMaps;
  40109. private _canvas;
  40110. private _context;
  40111. private _engine;
  40112. /**
  40113. * Creates a DynamicTexture
  40114. * @param name defines the name of the texture
  40115. * @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
  40116. * @param scene defines the scene where you want the texture
  40117. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40118. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40119. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40120. */
  40121. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40122. /**
  40123. * Get the current class name of the texture useful for serialization or dynamic coding.
  40124. * @returns "DynamicTexture"
  40125. */
  40126. getClassName(): string;
  40127. /**
  40128. * Gets the current state of canRescale
  40129. */
  40130. readonly canRescale: boolean;
  40131. private _recreate;
  40132. /**
  40133. * Scales the texture
  40134. * @param ratio the scale factor to apply to both width and height
  40135. */
  40136. scale(ratio: number): void;
  40137. /**
  40138. * Resizes the texture
  40139. * @param width the new width
  40140. * @param height the new height
  40141. */
  40142. scaleTo(width: number, height: number): void;
  40143. /**
  40144. * Gets the context of the canvas used by the texture
  40145. * @returns the canvas context of the dynamic texture
  40146. */
  40147. getContext(): CanvasRenderingContext2D;
  40148. /**
  40149. * Clears the texture
  40150. */
  40151. clear(): void;
  40152. /**
  40153. * Updates the texture
  40154. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40155. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40156. */
  40157. update(invertY?: boolean, premulAlpha?: boolean): void;
  40158. /**
  40159. * Draws text onto the texture
  40160. * @param text defines the text to be drawn
  40161. * @param x defines the placement of the text from the left
  40162. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40163. * @param font defines the font to be used with font-style, font-size, font-name
  40164. * @param color defines the color used for the text
  40165. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40166. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40167. * @param update defines whether texture is immediately update (default is true)
  40168. */
  40169. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40170. /**
  40171. * Clones the texture
  40172. * @returns the clone of the texture.
  40173. */
  40174. clone(): DynamicTexture;
  40175. /**
  40176. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40177. * @returns a serialized dynamic texture object
  40178. */
  40179. serialize(): any;
  40180. /** @hidden */
  40181. _rebuild(): void;
  40182. }
  40183. }
  40184. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40185. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40186. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40187. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40188. /** @hidden */
  40189. export var imageProcessingPixelShader: {
  40190. name: string;
  40191. shader: string;
  40192. };
  40193. }
  40194. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40195. import { Nullable } from "babylonjs/types";
  40196. import { Color4 } from "babylonjs/Maths/math";
  40197. import { Camera } from "babylonjs/Cameras/camera";
  40198. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40199. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40200. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40201. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40202. import { Engine } from "babylonjs/Engines/engine";
  40203. import "babylonjs/Shaders/imageProcessing.fragment";
  40204. import "babylonjs/Shaders/postprocess.vertex";
  40205. /**
  40206. * ImageProcessingPostProcess
  40207. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40208. */
  40209. export class ImageProcessingPostProcess extends PostProcess {
  40210. /**
  40211. * Default configuration related to image processing available in the PBR Material.
  40212. */
  40213. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40214. /**
  40215. * Gets the image processing configuration used either in this material.
  40216. */
  40217. /**
  40218. * Sets the Default image processing configuration used either in the this material.
  40219. *
  40220. * If sets to null, the scene one is in use.
  40221. */
  40222. imageProcessingConfiguration: ImageProcessingConfiguration;
  40223. /**
  40224. * Keep track of the image processing observer to allow dispose and replace.
  40225. */
  40226. private _imageProcessingObserver;
  40227. /**
  40228. * Attaches a new image processing configuration to the PBR Material.
  40229. * @param configuration
  40230. */
  40231. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40232. /**
  40233. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40234. */
  40235. /**
  40236. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40237. */
  40238. colorCurves: Nullable<ColorCurves>;
  40239. /**
  40240. * Gets wether the color curves effect is enabled.
  40241. */
  40242. /**
  40243. * Sets wether the color curves effect is enabled.
  40244. */
  40245. colorCurvesEnabled: boolean;
  40246. /**
  40247. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40248. */
  40249. /**
  40250. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40251. */
  40252. colorGradingTexture: Nullable<BaseTexture>;
  40253. /**
  40254. * Gets wether the color grading effect is enabled.
  40255. */
  40256. /**
  40257. * Gets wether the color grading effect is enabled.
  40258. */
  40259. colorGradingEnabled: boolean;
  40260. /**
  40261. * Gets exposure used in the effect.
  40262. */
  40263. /**
  40264. * Sets exposure used in the effect.
  40265. */
  40266. exposure: number;
  40267. /**
  40268. * Gets wether tonemapping is enabled or not.
  40269. */
  40270. /**
  40271. * Sets wether tonemapping is enabled or not
  40272. */
  40273. toneMappingEnabled: boolean;
  40274. /**
  40275. * Gets the type of tone mapping effect.
  40276. */
  40277. /**
  40278. * Sets the type of tone mapping effect.
  40279. */
  40280. toneMappingType: number;
  40281. /**
  40282. * Gets contrast used in the effect.
  40283. */
  40284. /**
  40285. * Sets contrast used in the effect.
  40286. */
  40287. contrast: number;
  40288. /**
  40289. * Gets Vignette stretch size.
  40290. */
  40291. /**
  40292. * Sets Vignette stretch size.
  40293. */
  40294. vignetteStretch: number;
  40295. /**
  40296. * Gets Vignette centre X Offset.
  40297. */
  40298. /**
  40299. * Sets Vignette centre X Offset.
  40300. */
  40301. vignetteCentreX: number;
  40302. /**
  40303. * Gets Vignette centre Y Offset.
  40304. */
  40305. /**
  40306. * Sets Vignette centre Y Offset.
  40307. */
  40308. vignetteCentreY: number;
  40309. /**
  40310. * Gets Vignette weight or intensity of the vignette effect.
  40311. */
  40312. /**
  40313. * Sets Vignette weight or intensity of the vignette effect.
  40314. */
  40315. vignetteWeight: number;
  40316. /**
  40317. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40318. * if vignetteEnabled is set to true.
  40319. */
  40320. /**
  40321. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40322. * if vignetteEnabled is set to true.
  40323. */
  40324. vignetteColor: Color4;
  40325. /**
  40326. * Gets Camera field of view used by the Vignette effect.
  40327. */
  40328. /**
  40329. * Sets Camera field of view used by the Vignette effect.
  40330. */
  40331. vignetteCameraFov: number;
  40332. /**
  40333. * Gets the vignette blend mode allowing different kind of effect.
  40334. */
  40335. /**
  40336. * Sets the vignette blend mode allowing different kind of effect.
  40337. */
  40338. vignetteBlendMode: number;
  40339. /**
  40340. * Gets wether the vignette effect is enabled.
  40341. */
  40342. /**
  40343. * Sets wether the vignette effect is enabled.
  40344. */
  40345. vignetteEnabled: boolean;
  40346. private _fromLinearSpace;
  40347. /**
  40348. * Gets wether the input of the processing is in Gamma or Linear Space.
  40349. */
  40350. /**
  40351. * Sets wether the input of the processing is in Gamma or Linear Space.
  40352. */
  40353. fromLinearSpace: boolean;
  40354. /**
  40355. * Defines cache preventing GC.
  40356. */
  40357. private _defines;
  40358. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40359. /**
  40360. * "ImageProcessingPostProcess"
  40361. * @returns "ImageProcessingPostProcess"
  40362. */
  40363. getClassName(): string;
  40364. protected _updateParameters(): void;
  40365. dispose(camera?: Camera): void;
  40366. }
  40367. }
  40368. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40369. import { Scene } from "babylonjs/scene";
  40370. import { Color3 } from "babylonjs/Maths/math";
  40371. import { Mesh } from "babylonjs/Meshes/mesh";
  40372. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40373. import { Nullable } from "babylonjs/types";
  40374. /**
  40375. * Class containing static functions to help procedurally build meshes
  40376. */
  40377. export class GroundBuilder {
  40378. /**
  40379. * Creates a ground mesh
  40380. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40381. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40383. * @param name defines the name of the mesh
  40384. * @param options defines the options used to create the mesh
  40385. * @param scene defines the hosting scene
  40386. * @returns the ground mesh
  40387. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40388. */
  40389. static CreateGround(name: string, options: {
  40390. width?: number;
  40391. height?: number;
  40392. subdivisions?: number;
  40393. subdivisionsX?: number;
  40394. subdivisionsY?: number;
  40395. updatable?: boolean;
  40396. }, scene: any): Mesh;
  40397. /**
  40398. * Creates a tiled ground mesh
  40399. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40400. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40401. * * 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
  40402. * * 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
  40403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40404. * @param name defines the name of the mesh
  40405. * @param options defines the options used to create the mesh
  40406. * @param scene defines the hosting scene
  40407. * @returns the tiled ground mesh
  40408. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40409. */
  40410. static CreateTiledGround(name: string, options: {
  40411. xmin: number;
  40412. zmin: number;
  40413. xmax: number;
  40414. zmax: number;
  40415. subdivisions?: {
  40416. w: number;
  40417. h: number;
  40418. };
  40419. precision?: {
  40420. w: number;
  40421. h: number;
  40422. };
  40423. updatable?: boolean;
  40424. }, scene?: Nullable<Scene>): Mesh;
  40425. /**
  40426. * Creates a ground mesh from a height map
  40427. * * The parameter `url` sets the URL of the height map image resource.
  40428. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40429. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40430. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40431. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40432. * * 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.
  40433. * * 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).
  40434. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40436. * @param name defines the name of the mesh
  40437. * @param url defines the url to the height map
  40438. * @param options defines the options used to create the mesh
  40439. * @param scene defines the hosting scene
  40440. * @returns the ground mesh
  40441. * @see https://doc.babylonjs.com/babylon101/height_map
  40442. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40443. */
  40444. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40445. width?: number;
  40446. height?: number;
  40447. subdivisions?: number;
  40448. minHeight?: number;
  40449. maxHeight?: number;
  40450. colorFilter?: Color3;
  40451. alphaFilter?: number;
  40452. updatable?: boolean;
  40453. onReady?: (mesh: GroundMesh) => void;
  40454. }, scene?: Nullable<Scene>): GroundMesh;
  40455. }
  40456. }
  40457. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40458. import { Vector4 } from "babylonjs/Maths/math";
  40459. import { Mesh } from "babylonjs/Meshes/mesh";
  40460. /**
  40461. * Class containing static functions to help procedurally build meshes
  40462. */
  40463. export class TorusBuilder {
  40464. /**
  40465. * Creates a torus mesh
  40466. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40467. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40468. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40469. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40470. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40472. * @param name defines the name of the mesh
  40473. * @param options defines the options used to create the mesh
  40474. * @param scene defines the hosting scene
  40475. * @returns the torus mesh
  40476. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40477. */
  40478. static CreateTorus(name: string, options: {
  40479. diameter?: number;
  40480. thickness?: number;
  40481. tessellation?: number;
  40482. updatable?: boolean;
  40483. sideOrientation?: number;
  40484. frontUVs?: Vector4;
  40485. backUVs?: Vector4;
  40486. }, scene: any): Mesh;
  40487. }
  40488. }
  40489. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40490. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40491. import { Mesh } from "babylonjs/Meshes/mesh";
  40492. /**
  40493. * Class containing static functions to help procedurally build meshes
  40494. */
  40495. export class CylinderBuilder {
  40496. /**
  40497. * Creates a cylinder or a cone mesh
  40498. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40499. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40500. * * 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.
  40501. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40502. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40503. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40504. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40505. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40506. * * 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).
  40507. * * 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
  40508. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40509. * * 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
  40510. * * 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.
  40511. * * If `enclose` is false, a ring surface is one element.
  40512. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40513. * * 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
  40514. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40515. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40517. * @param name defines the name of the mesh
  40518. * @param options defines the options used to create the mesh
  40519. * @param scene defines the hosting scene
  40520. * @returns the cylinder mesh
  40521. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40522. */
  40523. static CreateCylinder(name: string, options: {
  40524. height?: number;
  40525. diameterTop?: number;
  40526. diameterBottom?: number;
  40527. diameter?: number;
  40528. tessellation?: number;
  40529. subdivisions?: number;
  40530. arc?: number;
  40531. faceColors?: Color4[];
  40532. faceUV?: Vector4[];
  40533. updatable?: boolean;
  40534. hasRings?: boolean;
  40535. enclose?: boolean;
  40536. sideOrientation?: number;
  40537. frontUVs?: Vector4;
  40538. backUVs?: Vector4;
  40539. }, scene: any): Mesh;
  40540. }
  40541. }
  40542. declare module "babylonjs/Gamepads/gamepadManager" {
  40543. import { Observable } from "babylonjs/Misc/observable";
  40544. import { Nullable } from "babylonjs/types";
  40545. import { Scene } from "babylonjs/scene";
  40546. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40547. /**
  40548. * Manager for handling gamepads
  40549. */
  40550. export class GamepadManager {
  40551. private _scene?;
  40552. private _babylonGamepads;
  40553. private _oneGamepadConnected;
  40554. /** @hidden */
  40555. _isMonitoring: boolean;
  40556. private _gamepadEventSupported;
  40557. private _gamepadSupport;
  40558. /**
  40559. * observable to be triggered when the gamepad controller has been connected
  40560. */
  40561. onGamepadConnectedObservable: Observable<Gamepad>;
  40562. /**
  40563. * observable to be triggered when the gamepad controller has been disconnected
  40564. */
  40565. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40566. private _onGamepadConnectedEvent;
  40567. private _onGamepadDisconnectedEvent;
  40568. /**
  40569. * Initializes the gamepad manager
  40570. * @param _scene BabylonJS scene
  40571. */
  40572. constructor(_scene?: Scene | undefined);
  40573. /**
  40574. * The gamepads in the game pad manager
  40575. */
  40576. readonly gamepads: Gamepad[];
  40577. /**
  40578. * Get the gamepad controllers based on type
  40579. * @param type The type of gamepad controller
  40580. * @returns Nullable gamepad
  40581. */
  40582. getGamepadByType(type?: number): Nullable<Gamepad>;
  40583. /**
  40584. * Disposes the gamepad manager
  40585. */
  40586. dispose(): void;
  40587. private _addNewGamepad;
  40588. private _startMonitoringGamepads;
  40589. private _stopMonitoringGamepads;
  40590. /** @hidden */
  40591. _checkGamepadsStatus(): void;
  40592. private _updateGamepadObjects;
  40593. }
  40594. }
  40595. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40596. import { Nullable } from "babylonjs/types";
  40597. import { Scene } from "babylonjs/scene";
  40598. import { ISceneComponent } from "babylonjs/sceneComponent";
  40599. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40600. module "babylonjs/scene" {
  40601. interface Scene {
  40602. /** @hidden */
  40603. _gamepadManager: Nullable<GamepadManager>;
  40604. /**
  40605. * Gets the gamepad manager associated with the scene
  40606. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40607. */
  40608. gamepadManager: GamepadManager;
  40609. }
  40610. }
  40611. module "babylonjs/Cameras/freeCameraInputsManager" {
  40612. /**
  40613. * Interface representing a free camera inputs manager
  40614. */
  40615. interface FreeCameraInputsManager {
  40616. /**
  40617. * Adds gamepad input support to the FreeCameraInputsManager.
  40618. * @returns the FreeCameraInputsManager
  40619. */
  40620. addGamepad(): FreeCameraInputsManager;
  40621. }
  40622. }
  40623. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40624. /**
  40625. * Interface representing an arc rotate camera inputs manager
  40626. */
  40627. interface ArcRotateCameraInputsManager {
  40628. /**
  40629. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40630. * @returns the camera inputs manager
  40631. */
  40632. addGamepad(): ArcRotateCameraInputsManager;
  40633. }
  40634. }
  40635. /**
  40636. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40637. */
  40638. export class GamepadSystemSceneComponent implements ISceneComponent {
  40639. /**
  40640. * The component name helpfull to identify the component in the list of scene components.
  40641. */
  40642. readonly name: string;
  40643. /**
  40644. * The scene the component belongs to.
  40645. */
  40646. scene: Scene;
  40647. /**
  40648. * Creates a new instance of the component for the given scene
  40649. * @param scene Defines the scene to register the component in
  40650. */
  40651. constructor(scene: Scene);
  40652. /**
  40653. * Registers the component in a given scene
  40654. */
  40655. register(): void;
  40656. /**
  40657. * Rebuilds the elements related to this component in case of
  40658. * context lost for instance.
  40659. */
  40660. rebuild(): void;
  40661. /**
  40662. * Disposes the component and the associated ressources
  40663. */
  40664. dispose(): void;
  40665. private _beforeCameraUpdate;
  40666. }
  40667. }
  40668. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40669. import { Observable } from "babylonjs/Misc/observable";
  40670. import { Nullable } from "babylonjs/types";
  40671. import { Camera } from "babylonjs/Cameras/camera";
  40672. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40673. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40674. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40675. import { Scene } from "babylonjs/scene";
  40676. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40677. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40679. import { Mesh } from "babylonjs/Meshes/mesh";
  40680. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40681. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40682. import "babylonjs/Meshes/Builders/groundBuilder";
  40683. import "babylonjs/Meshes/Builders/torusBuilder";
  40684. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40685. import "babylonjs/Gamepads/gamepadSceneComponent";
  40686. import "babylonjs/Animations/animatable";
  40687. /**
  40688. * Options to modify the vr teleportation behavior.
  40689. */
  40690. export interface VRTeleportationOptions {
  40691. /**
  40692. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40693. */
  40694. floorMeshName?: string;
  40695. /**
  40696. * A list of meshes to be used as the teleportation floor. (default: empty)
  40697. */
  40698. floorMeshes?: Mesh[];
  40699. }
  40700. /**
  40701. * Options to modify the vr experience helper's behavior.
  40702. */
  40703. export interface VRExperienceHelperOptions extends WebVROptions {
  40704. /**
  40705. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40706. */
  40707. createDeviceOrientationCamera?: boolean;
  40708. /**
  40709. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40710. */
  40711. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40712. /**
  40713. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40714. */
  40715. laserToggle?: boolean;
  40716. /**
  40717. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40718. */
  40719. floorMeshes?: Mesh[];
  40720. /**
  40721. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40722. */
  40723. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40724. }
  40725. /**
  40726. * Event containing information after VR has been entered
  40727. */
  40728. export class OnAfterEnteringVRObservableEvent {
  40729. /**
  40730. * If entering vr was successful
  40731. */
  40732. success: boolean;
  40733. }
  40734. /**
  40735. * Helps to quickly add VR support to an existing scene.
  40736. * See http://doc.babylonjs.com/how_to/webvr_helper
  40737. */
  40738. export class VRExperienceHelper {
  40739. /** Options to modify the vr experience helper's behavior. */
  40740. webVROptions: VRExperienceHelperOptions;
  40741. private _scene;
  40742. private _position;
  40743. private _btnVR;
  40744. private _btnVRDisplayed;
  40745. private _webVRsupported;
  40746. private _webVRready;
  40747. private _webVRrequesting;
  40748. private _webVRpresenting;
  40749. private _hasEnteredVR;
  40750. private _fullscreenVRpresenting;
  40751. private _canvas;
  40752. private _webVRCamera;
  40753. private _vrDeviceOrientationCamera;
  40754. private _deviceOrientationCamera;
  40755. private _existingCamera;
  40756. private _onKeyDown;
  40757. private _onVrDisplayPresentChange;
  40758. private _onVRDisplayChanged;
  40759. private _onVRRequestPresentStart;
  40760. private _onVRRequestPresentComplete;
  40761. /**
  40762. * Observable raised right before entering VR.
  40763. */
  40764. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40765. /**
  40766. * Observable raised when entering VR has completed.
  40767. */
  40768. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40769. /**
  40770. * Observable raised when exiting VR.
  40771. */
  40772. onExitingVRObservable: Observable<VRExperienceHelper>;
  40773. /**
  40774. * Observable raised when controller mesh is loaded.
  40775. */
  40776. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40777. /** Return this.onEnteringVRObservable
  40778. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40779. */
  40780. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40781. /** Return this.onExitingVRObservable
  40782. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40783. */
  40784. readonly onExitingVR: Observable<VRExperienceHelper>;
  40785. /** Return this.onControllerMeshLoadedObservable
  40786. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40787. */
  40788. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40789. private _rayLength;
  40790. private _useCustomVRButton;
  40791. private _teleportationRequested;
  40792. private _teleportActive;
  40793. private _floorMeshName;
  40794. private _floorMeshesCollection;
  40795. private _rotationAllowed;
  40796. private _teleportBackwardsVector;
  40797. private _teleportationTarget;
  40798. private _isDefaultTeleportationTarget;
  40799. private _postProcessMove;
  40800. private _teleportationFillColor;
  40801. private _teleportationBorderColor;
  40802. private _rotationAngle;
  40803. private _haloCenter;
  40804. private _cameraGazer;
  40805. private _padSensibilityUp;
  40806. private _padSensibilityDown;
  40807. private _leftController;
  40808. private _rightController;
  40809. /**
  40810. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40811. */
  40812. onNewMeshSelected: Observable<AbstractMesh>;
  40813. /**
  40814. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40815. */
  40816. onNewMeshPicked: Observable<PickingInfo>;
  40817. private _circleEase;
  40818. /**
  40819. * Observable raised before camera teleportation
  40820. */
  40821. onBeforeCameraTeleport: Observable<Vector3>;
  40822. /**
  40823. * Observable raised after camera teleportation
  40824. */
  40825. onAfterCameraTeleport: Observable<Vector3>;
  40826. /**
  40827. * Observable raised when current selected mesh gets unselected
  40828. */
  40829. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40830. private _raySelectionPredicate;
  40831. /**
  40832. * To be optionaly changed by user to define custom ray selection
  40833. */
  40834. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40835. /**
  40836. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40837. */
  40838. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40839. /**
  40840. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40841. */
  40842. teleportationEnabled: boolean;
  40843. private _defaultHeight;
  40844. private _teleportationInitialized;
  40845. private _interactionsEnabled;
  40846. private _interactionsRequested;
  40847. private _displayGaze;
  40848. private _displayLaserPointer;
  40849. /**
  40850. * The mesh used to display where the user is going to teleport.
  40851. */
  40852. /**
  40853. * Sets the mesh to be used to display where the user is going to teleport.
  40854. */
  40855. teleportationTarget: Mesh;
  40856. /**
  40857. * 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
  40858. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40859. * See http://doc.babylonjs.com/resources/baking_transformations
  40860. */
  40861. gazeTrackerMesh: Mesh;
  40862. /**
  40863. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40864. */
  40865. updateGazeTrackerScale: boolean;
  40866. /**
  40867. * If the gaze trackers color should be updated when selecting meshes
  40868. */
  40869. updateGazeTrackerColor: boolean;
  40870. /**
  40871. * The gaze tracking mesh corresponding to the left controller
  40872. */
  40873. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40874. /**
  40875. * The gaze tracking mesh corresponding to the right controller
  40876. */
  40877. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40878. /**
  40879. * If the ray of the gaze should be displayed.
  40880. */
  40881. /**
  40882. * Sets if the ray of the gaze should be displayed.
  40883. */
  40884. displayGaze: boolean;
  40885. /**
  40886. * If the ray of the LaserPointer should be displayed.
  40887. */
  40888. /**
  40889. * Sets if the ray of the LaserPointer should be displayed.
  40890. */
  40891. displayLaserPointer: boolean;
  40892. /**
  40893. * The deviceOrientationCamera used as the camera when not in VR.
  40894. */
  40895. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40896. /**
  40897. * Based on the current WebVR support, returns the current VR camera used.
  40898. */
  40899. readonly currentVRCamera: Nullable<Camera>;
  40900. /**
  40901. * The webVRCamera which is used when in VR.
  40902. */
  40903. readonly webVRCamera: WebVRFreeCamera;
  40904. /**
  40905. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40906. */
  40907. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40908. private readonly _teleportationRequestInitiated;
  40909. /**
  40910. * Defines wether or not Pointer lock should be requested when switching to
  40911. * full screen.
  40912. */
  40913. requestPointerLockOnFullScreen: boolean;
  40914. /**
  40915. * Instantiates a VRExperienceHelper.
  40916. * Helps to quickly add VR support to an existing scene.
  40917. * @param scene The scene the VRExperienceHelper belongs to.
  40918. * @param webVROptions Options to modify the vr experience helper's behavior.
  40919. */
  40920. constructor(scene: Scene,
  40921. /** Options to modify the vr experience helper's behavior. */
  40922. webVROptions?: VRExperienceHelperOptions);
  40923. private _onDefaultMeshLoaded;
  40924. private _onResize;
  40925. private _onFullscreenChange;
  40926. /**
  40927. * Gets a value indicating if we are currently in VR mode.
  40928. */
  40929. readonly isInVRMode: boolean;
  40930. private onVrDisplayPresentChange;
  40931. private onVRDisplayChanged;
  40932. private moveButtonToBottomRight;
  40933. private displayVRButton;
  40934. private updateButtonVisibility;
  40935. private _cachedAngularSensibility;
  40936. /**
  40937. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40938. * Otherwise, will use the fullscreen API.
  40939. */
  40940. enterVR(): void;
  40941. /**
  40942. * Attempt to exit VR, or fullscreen.
  40943. */
  40944. exitVR(): void;
  40945. /**
  40946. * The position of the vr experience helper.
  40947. */
  40948. /**
  40949. * Sets the position of the vr experience helper.
  40950. */
  40951. position: Vector3;
  40952. /**
  40953. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40954. */
  40955. enableInteractions(): void;
  40956. private readonly _noControllerIsActive;
  40957. private beforeRender;
  40958. private _isTeleportationFloor;
  40959. /**
  40960. * Adds a floor mesh to be used for teleportation.
  40961. * @param floorMesh the mesh to be used for teleportation.
  40962. */
  40963. addFloorMesh(floorMesh: Mesh): void;
  40964. /**
  40965. * Removes a floor mesh from being used for teleportation.
  40966. * @param floorMesh the mesh to be removed.
  40967. */
  40968. removeFloorMesh(floorMesh: Mesh): void;
  40969. /**
  40970. * Enables interactions and teleportation using the VR controllers and gaze.
  40971. * @param vrTeleportationOptions options to modify teleportation behavior.
  40972. */
  40973. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40974. private _onNewGamepadConnected;
  40975. private _tryEnableInteractionOnController;
  40976. private _onNewGamepadDisconnected;
  40977. private _enableInteractionOnController;
  40978. private _checkTeleportWithRay;
  40979. private _checkRotate;
  40980. private _checkTeleportBackwards;
  40981. private _enableTeleportationOnController;
  40982. private _createTeleportationCircles;
  40983. private _displayTeleportationTarget;
  40984. private _hideTeleportationTarget;
  40985. private _rotateCamera;
  40986. private _moveTeleportationSelectorTo;
  40987. private _workingVector;
  40988. private _workingQuaternion;
  40989. private _workingMatrix;
  40990. /**
  40991. * Teleports the users feet to the desired location
  40992. * @param location The location where the user's feet should be placed
  40993. */
  40994. teleportCamera(location: Vector3): void;
  40995. private _convertNormalToDirectionOfRay;
  40996. private _castRayAndSelectObject;
  40997. private _notifySelectedMeshUnselected;
  40998. /**
  40999. * Sets the color of the laser ray from the vr controllers.
  41000. * @param color new color for the ray.
  41001. */
  41002. changeLaserColor(color: Color3): void;
  41003. /**
  41004. * Sets the color of the ray from the vr headsets gaze.
  41005. * @param color new color for the ray.
  41006. */
  41007. changeGazeColor(color: Color3): void;
  41008. /**
  41009. * Exits VR and disposes of the vr experience helper
  41010. */
  41011. dispose(): void;
  41012. /**
  41013. * Gets the name of the VRExperienceHelper class
  41014. * @returns "VRExperienceHelper"
  41015. */
  41016. getClassName(): string;
  41017. }
  41018. }
  41019. declare module "babylonjs/Cameras/VR/index" {
  41020. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41021. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41022. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41023. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41024. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41025. export * from "babylonjs/Cameras/VR/webVRCamera";
  41026. }
  41027. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41028. import { Observable } from "babylonjs/Misc/observable";
  41029. import { Nullable } from "babylonjs/types";
  41030. import { IDisposable, Scene } from "babylonjs/scene";
  41031. import { Vector3 } from "babylonjs/Maths/math";
  41032. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41033. import { Ray } from "babylonjs/Culling/ray";
  41034. /**
  41035. * Manages an XRSession
  41036. * @see https://doc.babylonjs.com/how_to/webxr
  41037. */
  41038. export class WebXRSessionManager implements IDisposable {
  41039. private scene;
  41040. /**
  41041. * Fires every time a new xrFrame arrives which can be used to update the camera
  41042. */
  41043. onXRFrameObservable: Observable<any>;
  41044. /**
  41045. * Fires when the xr session is ended either by the device or manually done
  41046. */
  41047. onXRSessionEnded: Observable<any>;
  41048. /** @hidden */
  41049. _xrSession: XRSession;
  41050. /** @hidden */
  41051. _frameOfReference: XRFrameOfReference;
  41052. /** @hidden */
  41053. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41054. /** @hidden */
  41055. _currentXRFrame: Nullable<XRFrame>;
  41056. private _xrNavigator;
  41057. private _xrDevice;
  41058. private _tmpMatrix;
  41059. /**
  41060. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41061. * @param scene The scene which the session should be created for
  41062. */
  41063. constructor(scene: Scene);
  41064. /**
  41065. * Initializes the manager
  41066. * After initialization enterXR can be called to start an XR session
  41067. * @returns Promise which resolves after it is initialized
  41068. */
  41069. initializeAsync(): Promise<void>;
  41070. /**
  41071. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41072. * @param sessionCreationOptions xr options to create the session with
  41073. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41074. * @returns Promise which resolves after it enters XR
  41075. */
  41076. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41077. /**
  41078. * Stops the xrSession and restores the renderloop
  41079. * @returns Promise which resolves after it exits XR
  41080. */
  41081. exitXRAsync(): Promise<void>;
  41082. /**
  41083. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41084. * @param ray ray to cast into the environment
  41085. * @returns Promise which resolves with a collision point in the environment if it exists
  41086. */
  41087. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41088. /**
  41089. * Checks if a session would be supported for the creation options specified
  41090. * @param options creation options to check if they are supported
  41091. * @returns true if supported
  41092. */
  41093. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41094. /**
  41095. * @hidden
  41096. * Converts the render layer of xrSession to a render target
  41097. * @param session session to create render target for
  41098. * @param scene scene the new render target should be created for
  41099. */
  41100. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41101. /**
  41102. * Disposes of the session manager
  41103. */
  41104. dispose(): void;
  41105. }
  41106. }
  41107. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41108. import { Scene } from "babylonjs/scene";
  41109. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41110. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41111. /**
  41112. * WebXR Camera which holds the views for the xrSession
  41113. * @see https://doc.babylonjs.com/how_to/webxr
  41114. */
  41115. export class WebXRCamera extends FreeCamera {
  41116. private static _TmpMatrix;
  41117. /**
  41118. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41119. * @param name the name of the camera
  41120. * @param scene the scene to add the camera to
  41121. */
  41122. constructor(name: string, scene: Scene);
  41123. private _updateNumberOfRigCameras;
  41124. /** @hidden */
  41125. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41126. /**
  41127. * Updates the cameras position from the current pose information of the XR session
  41128. * @param xrSessionManager the session containing pose information
  41129. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41130. */
  41131. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41132. }
  41133. }
  41134. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41135. import { Nullable } from "babylonjs/types";
  41136. import { Observable } from "babylonjs/Misc/observable";
  41137. import { IDisposable, Scene } from "babylonjs/scene";
  41138. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41139. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41140. import { Ray } from "babylonjs/Culling/ray";
  41141. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41142. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41143. /**
  41144. * States of the webXR experience
  41145. */
  41146. export enum WebXRState {
  41147. /**
  41148. * Transitioning to being in XR mode
  41149. */
  41150. ENTERING_XR = 0,
  41151. /**
  41152. * Transitioning to non XR mode
  41153. */
  41154. EXITING_XR = 1,
  41155. /**
  41156. * In XR mode and presenting
  41157. */
  41158. IN_XR = 2,
  41159. /**
  41160. * Not entered XR mode
  41161. */
  41162. NOT_IN_XR = 3
  41163. }
  41164. /**
  41165. * Helper class used to enable XR
  41166. * @see https://doc.babylonjs.com/how_to/webxr
  41167. */
  41168. export class WebXRExperienceHelper implements IDisposable {
  41169. private scene;
  41170. /**
  41171. * 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
  41172. */
  41173. container: AbstractMesh;
  41174. /**
  41175. * Camera used to render xr content
  41176. */
  41177. camera: WebXRCamera;
  41178. /**
  41179. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41180. */
  41181. state: WebXRState;
  41182. private _setState;
  41183. private static _TmpVector;
  41184. /**
  41185. * Fires when the state of the experience helper has changed
  41186. */
  41187. onStateChangedObservable: Observable<WebXRState>;
  41188. /** @hidden */
  41189. _sessionManager: WebXRSessionManager;
  41190. private _nonVRCamera;
  41191. private _originalSceneAutoClear;
  41192. private _supported;
  41193. /**
  41194. * Creates the experience helper
  41195. * @param scene the scene to attach the experience helper to
  41196. * @returns a promise for the experience helper
  41197. */
  41198. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41199. /**
  41200. * Creates a WebXRExperienceHelper
  41201. * @param scene The scene the helper should be created in
  41202. */
  41203. private constructor();
  41204. /**
  41205. * Exits XR mode and returns the scene to its original state
  41206. * @returns promise that resolves after xr mode has exited
  41207. */
  41208. exitXRAsync(): Promise<void>;
  41209. /**
  41210. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41211. * @param sessionCreationOptions options for the XR session
  41212. * @param frameOfReference frame of reference of the XR session
  41213. * @returns promise that resolves after xr mode has entered
  41214. */
  41215. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41216. /**
  41217. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41218. * @param ray ray to cast into the environment
  41219. * @returns Promise which resolves with a collision point in the environment if it exists
  41220. */
  41221. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41222. /**
  41223. * Updates the global position of the camera by moving the camera's container
  41224. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41225. * @param position The desired global position of the camera
  41226. */
  41227. setPositionOfCameraUsingContainer(position: Vector3): void;
  41228. /**
  41229. * Rotates the xr camera by rotating the camera's container around the camera's position
  41230. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41231. * @param rotation the desired quaternion rotation to apply to the camera
  41232. */
  41233. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41234. /**
  41235. * Checks if the creation options are supported by the xr session
  41236. * @param options creation options
  41237. * @returns true if supported
  41238. */
  41239. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41240. /**
  41241. * Disposes of the experience helper
  41242. */
  41243. dispose(): void;
  41244. }
  41245. }
  41246. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41247. import { Nullable } from "babylonjs/types";
  41248. import { Observable } from "babylonjs/Misc/observable";
  41249. import { IDisposable, Scene } from "babylonjs/scene";
  41250. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41251. /**
  41252. * Button which can be used to enter a different mode of XR
  41253. */
  41254. export class WebXREnterExitUIButton {
  41255. /** button element */
  41256. element: HTMLElement;
  41257. /** XR initialization options for the button */
  41258. initializationOptions: XRSessionCreationOptions;
  41259. /**
  41260. * Creates a WebXREnterExitUIButton
  41261. * @param element button element
  41262. * @param initializationOptions XR initialization options for the button
  41263. */
  41264. constructor(
  41265. /** button element */
  41266. element: HTMLElement,
  41267. /** XR initialization options for the button */
  41268. initializationOptions: XRSessionCreationOptions);
  41269. /**
  41270. * Overwritable function which can be used to update the button's visuals when the state changes
  41271. * @param activeButton the current active button in the UI
  41272. */
  41273. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41274. }
  41275. /**
  41276. * Options to create the webXR UI
  41277. */
  41278. export class WebXREnterExitUIOptions {
  41279. /**
  41280. * Context to enter xr with
  41281. */
  41282. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41283. /**
  41284. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41285. */
  41286. customButtons?: Array<WebXREnterExitUIButton>;
  41287. }
  41288. /**
  41289. * UI to allow the user to enter/exit XR mode
  41290. */
  41291. export class WebXREnterExitUI implements IDisposable {
  41292. private scene;
  41293. private _overlay;
  41294. private _buttons;
  41295. private _activeButton;
  41296. /**
  41297. * Fired every time the active button is changed.
  41298. *
  41299. * When xr is entered via a button that launches xr that button will be the callback parameter
  41300. *
  41301. * When exiting xr the callback parameter will be null)
  41302. */
  41303. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41304. /**
  41305. * Creates UI to allow the user to enter/exit XR mode
  41306. * @param scene the scene to add the ui to
  41307. * @param helper the xr experience helper to enter/exit xr with
  41308. * @param options options to configure the UI
  41309. * @returns the created ui
  41310. */
  41311. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41312. private constructor();
  41313. private _updateButtons;
  41314. /**
  41315. * Disposes of the object
  41316. */
  41317. dispose(): void;
  41318. }
  41319. }
  41320. declare module "babylonjs/Cameras/XR/webXRInput" {
  41321. import { IDisposable, Scene } from "babylonjs/scene";
  41322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41323. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41324. /**
  41325. * Represents an XR input
  41326. */
  41327. export class WebXRController {
  41328. /**
  41329. * 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
  41330. */
  41331. grip?: AbstractMesh;
  41332. /**
  41333. * Pointer which can be used to select objects or attach a visible laser to
  41334. */
  41335. pointer: AbstractMesh;
  41336. /**
  41337. * Creates the controller
  41338. * @see https://doc.babylonjs.com/how_to/webxr
  41339. * @param scene the scene which the controller should be associated to
  41340. */
  41341. constructor(scene: Scene);
  41342. /**
  41343. * Disposes of the object
  41344. */
  41345. dispose(): void;
  41346. }
  41347. /**
  41348. * XR input used to track XR inputs such as controllers/rays
  41349. */
  41350. export class WebXRInput implements IDisposable {
  41351. private helper;
  41352. /**
  41353. * XR controllers being tracked
  41354. */
  41355. controllers: Array<WebXRController>;
  41356. private _tmpMatrix;
  41357. private _frameObserver;
  41358. /**
  41359. * Initializes the WebXRInput
  41360. * @param helper experience helper which the input should be created for
  41361. */
  41362. constructor(helper: WebXRExperienceHelper);
  41363. /**
  41364. * Disposes of the object
  41365. */
  41366. dispose(): void;
  41367. }
  41368. }
  41369. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41370. import { Nullable } from "babylonjs/types";
  41371. import { IDisposable } from "babylonjs/scene";
  41372. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41373. /**
  41374. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41375. */
  41376. export class WebXRManagedOutputCanvas implements IDisposable {
  41377. private _canvas;
  41378. /**
  41379. * xrpresent context of the canvas which can be used to display/mirror xr content
  41380. */
  41381. canvasContext: Nullable<WebGLRenderingContext>;
  41382. /**
  41383. * Initializes the canvas to be added/removed upon entering/exiting xr
  41384. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41385. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41386. */
  41387. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41388. /**
  41389. * Disposes of the object
  41390. */
  41391. dispose(): void;
  41392. private _setManagedOutputCanvas;
  41393. private _addCanvas;
  41394. private _removeCanvas;
  41395. }
  41396. }
  41397. declare module "babylonjs/Cameras/XR/index" {
  41398. export * from "babylonjs/Cameras/XR/webXRCamera";
  41399. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41400. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41401. export * from "babylonjs/Cameras/XR/webXRInput";
  41402. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41403. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41404. }
  41405. declare module "babylonjs/Cameras/RigModes/index" {
  41406. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41407. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41408. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41409. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41410. }
  41411. declare module "babylonjs/Cameras/index" {
  41412. export * from "babylonjs/Cameras/Inputs/index";
  41413. export * from "babylonjs/Cameras/cameraInputsManager";
  41414. export * from "babylonjs/Cameras/camera";
  41415. export * from "babylonjs/Cameras/targetCamera";
  41416. export * from "babylonjs/Cameras/freeCamera";
  41417. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41418. export * from "babylonjs/Cameras/touchCamera";
  41419. export * from "babylonjs/Cameras/arcRotateCamera";
  41420. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41421. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41422. export * from "babylonjs/Cameras/flyCamera";
  41423. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41424. export * from "babylonjs/Cameras/followCamera";
  41425. export * from "babylonjs/Cameras/gamepadCamera";
  41426. export * from "babylonjs/Cameras/Stereoscopic/index";
  41427. export * from "babylonjs/Cameras/universalCamera";
  41428. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41429. export * from "babylonjs/Cameras/VR/index";
  41430. export * from "babylonjs/Cameras/XR/index";
  41431. export * from "babylonjs/Cameras/RigModes/index";
  41432. }
  41433. declare module "babylonjs/Collisions/index" {
  41434. export * from "babylonjs/Collisions/collider";
  41435. export * from "babylonjs/Collisions/collisionCoordinator";
  41436. export * from "babylonjs/Collisions/pickingInfo";
  41437. export * from "babylonjs/Collisions/intersectionInfo";
  41438. }
  41439. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41440. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41441. import { Vector3, Plane } from "babylonjs/Maths/math";
  41442. import { Ray } from "babylonjs/Culling/ray";
  41443. /**
  41444. * Contains an array of blocks representing the octree
  41445. */
  41446. export interface IOctreeContainer<T> {
  41447. /**
  41448. * Blocks within the octree
  41449. */
  41450. blocks: Array<OctreeBlock<T>>;
  41451. }
  41452. /**
  41453. * Class used to store a cell in an octree
  41454. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41455. */
  41456. export class OctreeBlock<T> {
  41457. /**
  41458. * Gets the content of the current block
  41459. */
  41460. entries: T[];
  41461. /**
  41462. * Gets the list of block children
  41463. */
  41464. blocks: Array<OctreeBlock<T>>;
  41465. private _depth;
  41466. private _maxDepth;
  41467. private _capacity;
  41468. private _minPoint;
  41469. private _maxPoint;
  41470. private _boundingVectors;
  41471. private _creationFunc;
  41472. /**
  41473. * Creates a new block
  41474. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41475. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41476. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41477. * @param depth defines the current depth of this block in the octree
  41478. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41479. * @param creationFunc defines a callback to call when an element is added to the block
  41480. */
  41481. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41482. /**
  41483. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41484. */
  41485. readonly capacity: number;
  41486. /**
  41487. * Gets the minimum vector (in world space) of the block's bounding box
  41488. */
  41489. readonly minPoint: Vector3;
  41490. /**
  41491. * Gets the maximum vector (in world space) of the block's bounding box
  41492. */
  41493. readonly maxPoint: Vector3;
  41494. /**
  41495. * Add a new element to this block
  41496. * @param entry defines the element to add
  41497. */
  41498. addEntry(entry: T): void;
  41499. /**
  41500. * Remove an element from this block
  41501. * @param entry defines the element to remove
  41502. */
  41503. removeEntry(entry: T): void;
  41504. /**
  41505. * Add an array of elements to this block
  41506. * @param entries defines the array of elements to add
  41507. */
  41508. addEntries(entries: T[]): void;
  41509. /**
  41510. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41511. * @param frustumPlanes defines the frustum planes to test
  41512. * @param selection defines the array to store current content if selection is positive
  41513. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41514. */
  41515. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41516. /**
  41517. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41518. * @param sphereCenter defines the bounding sphere center
  41519. * @param sphereRadius defines the bounding sphere radius
  41520. * @param selection defines the array to store current content if selection is positive
  41521. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41522. */
  41523. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41524. /**
  41525. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41526. * @param ray defines the ray to test with
  41527. * @param selection defines the array to store current content if selection is positive
  41528. */
  41529. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41530. /**
  41531. * Subdivide the content into child blocks (this block will then be empty)
  41532. */
  41533. createInnerBlocks(): void;
  41534. /**
  41535. * @hidden
  41536. */
  41537. 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;
  41538. }
  41539. }
  41540. declare module "babylonjs/Culling/Octrees/octree" {
  41541. import { SmartArray } from "babylonjs/Misc/smartArray";
  41542. import { Vector3, Plane } from "babylonjs/Maths/math";
  41543. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41545. import { Ray } from "babylonjs/Culling/ray";
  41546. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41547. /**
  41548. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41549. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41550. */
  41551. export class Octree<T> {
  41552. /** 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.) */
  41553. maxDepth: number;
  41554. /**
  41555. * Blocks within the octree containing objects
  41556. */
  41557. blocks: Array<OctreeBlock<T>>;
  41558. /**
  41559. * Content stored in the octree
  41560. */
  41561. dynamicContent: T[];
  41562. private _maxBlockCapacity;
  41563. private _selectionContent;
  41564. private _creationFunc;
  41565. /**
  41566. * Creates a octree
  41567. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41568. * @param creationFunc function to be used to instatiate the octree
  41569. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41570. * @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.)
  41571. */
  41572. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41573. /** 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.) */
  41574. maxDepth?: number);
  41575. /**
  41576. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41577. * @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);
  41578. * @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);
  41579. * @param entries meshes to be added to the octree blocks
  41580. */
  41581. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41582. /**
  41583. * Adds a mesh to the octree
  41584. * @param entry Mesh to add to the octree
  41585. */
  41586. addMesh(entry: T): void;
  41587. /**
  41588. * Remove an element from the octree
  41589. * @param entry defines the element to remove
  41590. */
  41591. removeMesh(entry: T): void;
  41592. /**
  41593. * Selects an array of meshes within the frustum
  41594. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41595. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41596. * @returns array of meshes within the frustum
  41597. */
  41598. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41599. /**
  41600. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41601. * @param sphereCenter defines the bounding sphere center
  41602. * @param sphereRadius defines the bounding sphere radius
  41603. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41604. * @returns an array of objects that intersect the sphere
  41605. */
  41606. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41607. /**
  41608. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41609. * @param ray defines the ray to test with
  41610. * @returns array of intersected objects
  41611. */
  41612. intersectsRay(ray: Ray): SmartArray<T>;
  41613. /**
  41614. * Adds a mesh into the octree block if it intersects the block
  41615. */
  41616. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41617. /**
  41618. * Adds a submesh into the octree block if it intersects the block
  41619. */
  41620. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41621. }
  41622. }
  41623. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41624. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41625. import { Scene } from "babylonjs/scene";
  41626. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41628. import { Ray } from "babylonjs/Culling/ray";
  41629. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41630. import { Collider } from "babylonjs/Collisions/collider";
  41631. module "babylonjs/scene" {
  41632. interface Scene {
  41633. /**
  41634. * @hidden
  41635. * Backing Filed
  41636. */
  41637. _selectionOctree: Octree<AbstractMesh>;
  41638. /**
  41639. * Gets the octree used to boost mesh selection (picking)
  41640. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41641. */
  41642. selectionOctree: Octree<AbstractMesh>;
  41643. /**
  41644. * Creates or updates the octree used to boost selection (picking)
  41645. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41646. * @param maxCapacity defines the maximum capacity per leaf
  41647. * @param maxDepth defines the maximum depth of the octree
  41648. * @returns an octree of AbstractMesh
  41649. */
  41650. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41651. }
  41652. }
  41653. module "babylonjs/Meshes/abstractMesh" {
  41654. interface AbstractMesh {
  41655. /**
  41656. * @hidden
  41657. * Backing Field
  41658. */
  41659. _submeshesOctree: Octree<SubMesh>;
  41660. /**
  41661. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41662. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41663. * @param maxCapacity defines the maximum size of each block (64 by default)
  41664. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41665. * @returns the new octree
  41666. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41667. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41668. */
  41669. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41670. }
  41671. }
  41672. /**
  41673. * Defines the octree scene component responsible to manage any octrees
  41674. * in a given scene.
  41675. */
  41676. export class OctreeSceneComponent {
  41677. /**
  41678. * The component name helpfull to identify the component in the list of scene components.
  41679. */
  41680. readonly name: string;
  41681. /**
  41682. * The scene the component belongs to.
  41683. */
  41684. scene: Scene;
  41685. /**
  41686. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41687. */
  41688. readonly checksIsEnabled: boolean;
  41689. /**
  41690. * Creates a new instance of the component for the given scene
  41691. * @param scene Defines the scene to register the component in
  41692. */
  41693. constructor(scene: Scene);
  41694. /**
  41695. * Registers the component in a given scene
  41696. */
  41697. register(): void;
  41698. /**
  41699. * Return the list of active meshes
  41700. * @returns the list of active meshes
  41701. */
  41702. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41703. /**
  41704. * Return the list of active sub meshes
  41705. * @param mesh The mesh to get the candidates sub meshes from
  41706. * @returns the list of active sub meshes
  41707. */
  41708. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41709. private _tempRay;
  41710. /**
  41711. * Return the list of sub meshes intersecting with a given local ray
  41712. * @param mesh defines the mesh to find the submesh for
  41713. * @param localRay defines the ray in local space
  41714. * @returns the list of intersecting sub meshes
  41715. */
  41716. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41717. /**
  41718. * Return the list of sub meshes colliding with a collider
  41719. * @param mesh defines the mesh to find the submesh for
  41720. * @param collider defines the collider to evaluate the collision against
  41721. * @returns the list of colliding sub meshes
  41722. */
  41723. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41724. /**
  41725. * Rebuilds the elements related to this component in case of
  41726. * context lost for instance.
  41727. */
  41728. rebuild(): void;
  41729. /**
  41730. * Disposes the component and the associated ressources.
  41731. */
  41732. dispose(): void;
  41733. }
  41734. }
  41735. declare module "babylonjs/Culling/Octrees/index" {
  41736. export * from "babylonjs/Culling/Octrees/octree";
  41737. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41738. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41739. }
  41740. declare module "babylonjs/Culling/index" {
  41741. export * from "babylonjs/Culling/boundingBox";
  41742. export * from "babylonjs/Culling/boundingInfo";
  41743. export * from "babylonjs/Culling/boundingSphere";
  41744. export * from "babylonjs/Culling/Octrees/index";
  41745. export * from "babylonjs/Culling/ray";
  41746. }
  41747. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41748. import { IDisposable, Scene } from "babylonjs/scene";
  41749. import { Nullable } from "babylonjs/types";
  41750. import { Observable } from "babylonjs/Misc/observable";
  41751. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41752. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  41753. /**
  41754. * Renders a layer on top of an existing scene
  41755. */
  41756. export class UtilityLayerRenderer implements IDisposable {
  41757. /** the original scene that will be rendered on top of */
  41758. originalScene: Scene;
  41759. private _pointerCaptures;
  41760. private _lastPointerEvents;
  41761. private static _DefaultUtilityLayer;
  41762. private static _DefaultKeepDepthUtilityLayer;
  41763. private _sharedGizmoLight;
  41764. /**
  41765. * @hidden
  41766. * Light which used by gizmos to get light shading
  41767. */
  41768. _getSharedGizmoLight(): HemisphericLight;
  41769. /**
  41770. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41771. */
  41772. pickUtilitySceneFirst: boolean;
  41773. /**
  41774. * 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)
  41775. */
  41776. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41777. /**
  41778. * 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)
  41779. */
  41780. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41781. /**
  41782. * The scene that is rendered on top of the original scene
  41783. */
  41784. utilityLayerScene: Scene;
  41785. /**
  41786. * If the utility layer should automatically be rendered on top of existing scene
  41787. */
  41788. shouldRender: boolean;
  41789. /**
  41790. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41791. */
  41792. onlyCheckPointerDownEvents: boolean;
  41793. /**
  41794. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41795. */
  41796. processAllEvents: boolean;
  41797. /**
  41798. * Observable raised when the pointer move from the utility layer scene to the main scene
  41799. */
  41800. onPointerOutObservable: Observable<number>;
  41801. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41802. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41803. private _afterRenderObserver;
  41804. private _sceneDisposeObserver;
  41805. private _originalPointerObserver;
  41806. /**
  41807. * Instantiates a UtilityLayerRenderer
  41808. * @param originalScene the original scene that will be rendered on top of
  41809. * @param handleEvents boolean indicating if the utility layer should handle events
  41810. */
  41811. constructor(
  41812. /** the original scene that will be rendered on top of */
  41813. originalScene: Scene, handleEvents?: boolean);
  41814. private _notifyObservers;
  41815. /**
  41816. * Renders the utility layers scene on top of the original scene
  41817. */
  41818. render(): void;
  41819. /**
  41820. * Disposes of the renderer
  41821. */
  41822. dispose(): void;
  41823. private _updateCamera;
  41824. }
  41825. }
  41826. declare module "babylonjs/Gizmos/gizmo" {
  41827. import { Nullable } from "babylonjs/types";
  41828. import { IDisposable } from "babylonjs/scene";
  41829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41830. import { Mesh } from "babylonjs/Meshes/mesh";
  41831. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41832. /**
  41833. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41834. */
  41835. export class Gizmo implements IDisposable {
  41836. /** The utility layer the gizmo will be added to */
  41837. gizmoLayer: UtilityLayerRenderer;
  41838. /**
  41839. * The root mesh of the gizmo
  41840. */
  41841. _rootMesh: Mesh;
  41842. private _attachedMesh;
  41843. /**
  41844. * Ratio for the scale of the gizmo (Default: 1)
  41845. */
  41846. scaleRatio: number;
  41847. private _tmpMatrix;
  41848. /**
  41849. * If a custom mesh has been set (Default: false)
  41850. */
  41851. protected _customMeshSet: boolean;
  41852. /**
  41853. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41854. * * When set, interactions will be enabled
  41855. */
  41856. attachedMesh: Nullable<AbstractMesh>;
  41857. /**
  41858. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41859. * @param mesh The mesh to replace the default mesh of the gizmo
  41860. */
  41861. setCustomMesh(mesh: Mesh): void;
  41862. /**
  41863. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41864. */
  41865. updateGizmoRotationToMatchAttachedMesh: boolean;
  41866. /**
  41867. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41868. */
  41869. updateGizmoPositionToMatchAttachedMesh: boolean;
  41870. /**
  41871. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41872. */
  41873. protected _updateScale: boolean;
  41874. protected _interactionsEnabled: boolean;
  41875. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41876. private _beforeRenderObserver;
  41877. /**
  41878. * Creates a gizmo
  41879. * @param gizmoLayer The utility layer the gizmo will be added to
  41880. */
  41881. constructor(
  41882. /** The utility layer the gizmo will be added to */
  41883. gizmoLayer?: UtilityLayerRenderer);
  41884. private _tempVector;
  41885. /**
  41886. * @hidden
  41887. * Updates the gizmo to match the attached mesh's position/rotation
  41888. */
  41889. protected _update(): void;
  41890. /**
  41891. * Disposes of the gizmo
  41892. */
  41893. dispose(): void;
  41894. }
  41895. }
  41896. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41897. import { Observable } from "babylonjs/Misc/observable";
  41898. import { Nullable } from "babylonjs/types";
  41899. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41900. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41902. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41903. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41904. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41905. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41906. import { Scene } from "babylonjs/scene";
  41907. /**
  41908. * Single axis drag gizmo
  41909. */
  41910. export class AxisDragGizmo extends Gizmo {
  41911. /**
  41912. * Drag behavior responsible for the gizmos dragging interactions
  41913. */
  41914. dragBehavior: PointerDragBehavior;
  41915. private _pointerObserver;
  41916. /**
  41917. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41918. */
  41919. snapDistance: number;
  41920. /**
  41921. * Event that fires each time the gizmo snaps to a new location.
  41922. * * snapDistance is the the change in distance
  41923. */
  41924. onSnapObservable: Observable<{
  41925. snapDistance: number;
  41926. }>;
  41927. /** @hidden */
  41928. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41929. /** @hidden */
  41930. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41931. /**
  41932. * Creates an AxisDragGizmo
  41933. * @param gizmoLayer The utility layer the gizmo will be added to
  41934. * @param dragAxis The axis which the gizmo will be able to drag on
  41935. * @param color The color of the gizmo
  41936. */
  41937. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41938. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41939. /**
  41940. * Disposes of the gizmo
  41941. */
  41942. dispose(): void;
  41943. }
  41944. }
  41945. declare module "babylonjs/Debug/axesViewer" {
  41946. import { Vector3 } from "babylonjs/Maths/math";
  41947. import { Nullable } from "babylonjs/types";
  41948. import { Scene } from "babylonjs/scene";
  41949. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41950. /**
  41951. * The Axes viewer will show 3 axes in a specific point in space
  41952. */
  41953. export class AxesViewer {
  41954. private _xAxis;
  41955. private _yAxis;
  41956. private _zAxis;
  41957. private _scaleLinesFactor;
  41958. private _instanced;
  41959. /**
  41960. * Gets the hosting scene
  41961. */
  41962. scene: Scene;
  41963. /**
  41964. * Gets or sets a number used to scale line length
  41965. */
  41966. scaleLines: number;
  41967. /** Gets the node hierarchy used to render x-axis */
  41968. readonly xAxis: TransformNode;
  41969. /** Gets the node hierarchy used to render y-axis */
  41970. readonly yAxis: TransformNode;
  41971. /** Gets the node hierarchy used to render z-axis */
  41972. readonly zAxis: TransformNode;
  41973. /**
  41974. * Creates a new AxesViewer
  41975. * @param scene defines the hosting scene
  41976. * @param scaleLines defines a number used to scale line length (1 by default)
  41977. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41978. * @param xAxis defines the node hierarchy used to render the x-axis
  41979. * @param yAxis defines the node hierarchy used to render the y-axis
  41980. * @param zAxis defines the node hierarchy used to render the z-axis
  41981. */
  41982. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41983. /**
  41984. * Force the viewer to update
  41985. * @param position defines the position of the viewer
  41986. * @param xaxis defines the x axis of the viewer
  41987. * @param yaxis defines the y axis of the viewer
  41988. * @param zaxis defines the z axis of the viewer
  41989. */
  41990. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41991. /**
  41992. * Creates an instance of this axes viewer.
  41993. * @returns a new axes viewer with instanced meshes
  41994. */
  41995. createInstance(): AxesViewer;
  41996. /** Releases resources */
  41997. dispose(): void;
  41998. private static _SetRenderingGroupId;
  41999. }
  42000. }
  42001. declare module "babylonjs/Debug/boneAxesViewer" {
  42002. import { Nullable } from "babylonjs/types";
  42003. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42004. import { Vector3 } from "babylonjs/Maths/math";
  42005. import { Mesh } from "babylonjs/Meshes/mesh";
  42006. import { Bone } from "babylonjs/Bones/bone";
  42007. import { Scene } from "babylonjs/scene";
  42008. /**
  42009. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42010. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42011. */
  42012. export class BoneAxesViewer extends AxesViewer {
  42013. /**
  42014. * Gets or sets the target mesh where to display the axes viewer
  42015. */
  42016. mesh: Nullable<Mesh>;
  42017. /**
  42018. * Gets or sets the target bone where to display the axes viewer
  42019. */
  42020. bone: Nullable<Bone>;
  42021. /** Gets current position */
  42022. pos: Vector3;
  42023. /** Gets direction of X axis */
  42024. xaxis: Vector3;
  42025. /** Gets direction of Y axis */
  42026. yaxis: Vector3;
  42027. /** Gets direction of Z axis */
  42028. zaxis: Vector3;
  42029. /**
  42030. * Creates a new BoneAxesViewer
  42031. * @param scene defines the hosting scene
  42032. * @param bone defines the target bone
  42033. * @param mesh defines the target mesh
  42034. * @param scaleLines defines a scaling factor for line length (1 by default)
  42035. */
  42036. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42037. /**
  42038. * Force the viewer to update
  42039. */
  42040. update(): void;
  42041. /** Releases resources */
  42042. dispose(): void;
  42043. }
  42044. }
  42045. declare module "babylonjs/Debug/debugLayer" {
  42046. import { Observable } from "babylonjs/Misc/observable";
  42047. import { Scene } from "babylonjs/scene";
  42048. /**
  42049. * Interface used to define scene explorer extensibility option
  42050. */
  42051. export interface IExplorerExtensibilityOption {
  42052. /**
  42053. * Define the option label
  42054. */
  42055. label: string;
  42056. /**
  42057. * Defines the action to execute on click
  42058. */
  42059. action: (entity: any) => void;
  42060. }
  42061. /**
  42062. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42063. */
  42064. export interface IExplorerExtensibilityGroup {
  42065. /**
  42066. * Defines a predicate to test if a given type mut be extended
  42067. */
  42068. predicate: (entity: any) => boolean;
  42069. /**
  42070. * Gets the list of options added to a type
  42071. */
  42072. entries: IExplorerExtensibilityOption[];
  42073. }
  42074. /**
  42075. * Interface used to define the options to use to create the Inspector
  42076. */
  42077. export interface IInspectorOptions {
  42078. /**
  42079. * Display in overlay mode (default: false)
  42080. */
  42081. overlay?: boolean;
  42082. /**
  42083. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42084. */
  42085. globalRoot?: HTMLElement;
  42086. /**
  42087. * Display the Scene explorer
  42088. */
  42089. showExplorer?: boolean;
  42090. /**
  42091. * Display the property inspector
  42092. */
  42093. showInspector?: boolean;
  42094. /**
  42095. * Display in embed mode (both panes on the right)
  42096. */
  42097. embedMode?: boolean;
  42098. /**
  42099. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42100. */
  42101. handleResize?: boolean;
  42102. /**
  42103. * Allow the panes to popup (default: true)
  42104. */
  42105. enablePopup?: boolean;
  42106. /**
  42107. * Allow the panes to be closed by users (default: true)
  42108. */
  42109. enableClose?: boolean;
  42110. /**
  42111. * Optional list of extensibility entries
  42112. */
  42113. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42114. /**
  42115. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42116. */
  42117. inspectorURL?: string;
  42118. }
  42119. module "babylonjs/scene" {
  42120. interface Scene {
  42121. /**
  42122. * @hidden
  42123. * Backing field
  42124. */
  42125. _debugLayer: DebugLayer;
  42126. /**
  42127. * Gets the debug layer (aka Inspector) associated with the scene
  42128. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42129. */
  42130. debugLayer: DebugLayer;
  42131. }
  42132. }
  42133. /**
  42134. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42135. * what is happening in your scene
  42136. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42137. */
  42138. export class DebugLayer {
  42139. /**
  42140. * Define the url to get the inspector script from.
  42141. * By default it uses the babylonjs CDN.
  42142. * @ignoreNaming
  42143. */
  42144. static InspectorURL: string;
  42145. private _scene;
  42146. private BJSINSPECTOR;
  42147. /**
  42148. * Observable triggered when a property is changed through the inspector.
  42149. */
  42150. onPropertyChangedObservable: Observable<{
  42151. object: any;
  42152. property: string;
  42153. value: any;
  42154. initialValue: any;
  42155. }>;
  42156. /**
  42157. * Instantiates a new debug layer.
  42158. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42159. * what is happening in your scene
  42160. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42161. * @param scene Defines the scene to inspect
  42162. */
  42163. constructor(scene: Scene);
  42164. /** Creates the inspector window. */
  42165. private _createInspector;
  42166. /**
  42167. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42168. * @param entity defines the entity to select
  42169. * @param lineContainerTitle defines the specific block to highlight
  42170. */
  42171. select(entity: any, lineContainerTitle?: string): void;
  42172. /** Get the inspector from bundle or global */
  42173. private _getGlobalInspector;
  42174. /**
  42175. * Get if the inspector is visible or not.
  42176. * @returns true if visible otherwise, false
  42177. */
  42178. isVisible(): boolean;
  42179. /**
  42180. * Hide the inspector and close its window.
  42181. */
  42182. hide(): void;
  42183. /**
  42184. * Launch the debugLayer.
  42185. * @param config Define the configuration of the inspector
  42186. * @return a promise fulfilled when the debug layer is visible
  42187. */
  42188. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42189. }
  42190. }
  42191. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42192. import { Nullable } from "babylonjs/types";
  42193. import { Scene } from "babylonjs/scene";
  42194. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42195. import { Mesh } from "babylonjs/Meshes/mesh";
  42196. /**
  42197. * Class containing static functions to help procedurally build meshes
  42198. */
  42199. export class BoxBuilder {
  42200. /**
  42201. * Creates a box mesh
  42202. * * The parameter `size` sets the size (float) of each box side (default 1)
  42203. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42204. * * 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)
  42205. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42206. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42207. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42209. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42210. * @param name defines the name of the mesh
  42211. * @param options defines the options used to create the mesh
  42212. * @param scene defines the hosting scene
  42213. * @returns the box mesh
  42214. */
  42215. static CreateBox(name: string, options: {
  42216. size?: number;
  42217. width?: number;
  42218. height?: number;
  42219. depth?: number;
  42220. faceUV?: Vector4[];
  42221. faceColors?: Color4[];
  42222. sideOrientation?: number;
  42223. frontUVs?: Vector4;
  42224. backUVs?: Vector4;
  42225. updatable?: boolean;
  42226. }, scene?: Nullable<Scene>): Mesh;
  42227. }
  42228. }
  42229. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42230. import { Vector4 } from "babylonjs/Maths/math";
  42231. import { Mesh } from "babylonjs/Meshes/mesh";
  42232. /**
  42233. * Class containing static functions to help procedurally build meshes
  42234. */
  42235. export class SphereBuilder {
  42236. /**
  42237. * Creates a sphere mesh
  42238. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42239. * * 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`)
  42240. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42241. * * 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
  42242. * * 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)
  42243. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42244. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42246. * @param name defines the name of the mesh
  42247. * @param options defines the options used to create the mesh
  42248. * @param scene defines the hosting scene
  42249. * @returns the sphere mesh
  42250. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42251. */
  42252. static CreateSphere(name: string, options: {
  42253. segments?: number;
  42254. diameter?: number;
  42255. diameterX?: number;
  42256. diameterY?: number;
  42257. diameterZ?: number;
  42258. arc?: number;
  42259. slice?: number;
  42260. sideOrientation?: number;
  42261. frontUVs?: Vector4;
  42262. backUVs?: Vector4;
  42263. updatable?: boolean;
  42264. }, scene: any): Mesh;
  42265. }
  42266. }
  42267. declare module "babylonjs/Debug/physicsViewer" {
  42268. import { Nullable } from "babylonjs/types";
  42269. import { Scene } from "babylonjs/scene";
  42270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42271. import { Mesh } from "babylonjs/Meshes/mesh";
  42272. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42273. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42274. /**
  42275. * Used to show the physics impostor around the specific mesh
  42276. */
  42277. export class PhysicsViewer {
  42278. /** @hidden */
  42279. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42280. /** @hidden */
  42281. protected _meshes: Array<Nullable<AbstractMesh>>;
  42282. /** @hidden */
  42283. protected _scene: Nullable<Scene>;
  42284. /** @hidden */
  42285. protected _numMeshes: number;
  42286. /** @hidden */
  42287. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42288. private _renderFunction;
  42289. private _utilityLayer;
  42290. private _debugBoxMesh;
  42291. private _debugSphereMesh;
  42292. private _debugCylinderMesh;
  42293. private _debugMaterial;
  42294. private _debugMeshMeshes;
  42295. /**
  42296. * Creates a new PhysicsViewer
  42297. * @param scene defines the hosting scene
  42298. */
  42299. constructor(scene: Scene);
  42300. /** @hidden */
  42301. protected _updateDebugMeshes(): void;
  42302. /**
  42303. * Renders a specified physic impostor
  42304. * @param impostor defines the impostor to render
  42305. * @param targetMesh defines the mesh represented by the impostor
  42306. * @returns the new debug mesh used to render the impostor
  42307. */
  42308. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42309. /**
  42310. * Hides a specified physic impostor
  42311. * @param impostor defines the impostor to hide
  42312. */
  42313. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42314. private _getDebugMaterial;
  42315. private _getDebugBoxMesh;
  42316. private _getDebugSphereMesh;
  42317. private _getDebugCylinderMesh;
  42318. private _getDebugMeshMesh;
  42319. private _getDebugMesh;
  42320. /** Releases all resources */
  42321. dispose(): void;
  42322. }
  42323. }
  42324. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  42325. import { Vector3, Color4 } from "babylonjs/Maths/math";
  42326. import { Nullable } from "babylonjs/types";
  42327. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42328. import { Scene } from "babylonjs/scene";
  42329. /**
  42330. * Class containing static functions to help procedurally build meshes
  42331. */
  42332. export class LinesBuilder {
  42333. /**
  42334. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42335. * * 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
  42336. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42337. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42338. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42339. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42340. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42341. * * 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
  42342. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42344. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42345. * @param name defines the name of the new line system
  42346. * @param options defines the options used to create the line system
  42347. * @param scene defines the hosting scene
  42348. * @returns a new line system mesh
  42349. */
  42350. static CreateLineSystem(name: string, options: {
  42351. lines: Vector3[][];
  42352. updatable?: boolean;
  42353. instance?: Nullable<LinesMesh>;
  42354. colors?: Nullable<Color4[][]>;
  42355. useVertexAlpha?: boolean;
  42356. }, scene: Nullable<Scene>): LinesMesh;
  42357. /**
  42358. * Creates a line mesh
  42359. * 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
  42360. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42361. * * The parameter `points` is an array successive Vector3
  42362. * * 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
  42363. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42364. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42365. * * When updating an instance, remember that only point positions can change, not the number of points
  42366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42367. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42368. * @param name defines the name of the new line system
  42369. * @param options defines the options used to create the line system
  42370. * @param scene defines the hosting scene
  42371. * @returns a new line mesh
  42372. */
  42373. static CreateLines(name: string, options: {
  42374. points: Vector3[];
  42375. updatable?: boolean;
  42376. instance?: Nullable<LinesMesh>;
  42377. colors?: Color4[];
  42378. useVertexAlpha?: boolean;
  42379. }, scene?: Nullable<Scene>): LinesMesh;
  42380. /**
  42381. * Creates a dashed line mesh
  42382. * * 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
  42383. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42384. * * The parameter `points` is an array successive Vector3
  42385. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42386. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42387. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42388. * * 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
  42389. * * When updating an instance, remember that only point positions can change, not the number of points
  42390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42391. * @param name defines the name of the mesh
  42392. * @param options defines the options used to create the mesh
  42393. * @param scene defines the hosting scene
  42394. * @returns the dashed line mesh
  42395. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42396. */
  42397. static CreateDashedLines(name: string, options: {
  42398. points: Vector3[];
  42399. dashSize?: number;
  42400. gapSize?: number;
  42401. dashNb?: number;
  42402. updatable?: boolean;
  42403. instance?: LinesMesh;
  42404. }, scene?: Nullable<Scene>): LinesMesh;
  42405. }
  42406. }
  42407. declare module "babylonjs/Debug/rayHelper" {
  42408. import { Nullable } from "babylonjs/types";
  42409. import { Ray } from "babylonjs/Culling/ray";
  42410. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42411. import { Scene } from "babylonjs/scene";
  42412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42413. import "babylonjs/Meshes/Builders/linesBuilder";
  42414. /**
  42415. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42416. * in order to better appreciate the issue one might have.
  42417. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42418. */
  42419. export class RayHelper {
  42420. /**
  42421. * Defines the ray we are currently tryin to visualize.
  42422. */
  42423. ray: Nullable<Ray>;
  42424. private _renderPoints;
  42425. private _renderLine;
  42426. private _renderFunction;
  42427. private _scene;
  42428. private _updateToMeshFunction;
  42429. private _attachedToMesh;
  42430. private _meshSpaceDirection;
  42431. private _meshSpaceOrigin;
  42432. /**
  42433. * Helper function to create a colored helper in a scene in one line.
  42434. * @param ray Defines the ray we are currently tryin to visualize
  42435. * @param scene Defines the scene the ray is used in
  42436. * @param color Defines the color we want to see the ray in
  42437. * @returns The newly created ray helper.
  42438. */
  42439. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42440. /**
  42441. * Instantiate a new ray helper.
  42442. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42443. * in order to better appreciate the issue one might have.
  42444. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42445. * @param ray Defines the ray we are currently tryin to visualize
  42446. */
  42447. constructor(ray: Ray);
  42448. /**
  42449. * Shows the ray we are willing to debug.
  42450. * @param scene Defines the scene the ray needs to be rendered in
  42451. * @param color Defines the color the ray needs to be rendered in
  42452. */
  42453. show(scene: Scene, color?: Color3): void;
  42454. /**
  42455. * Hides the ray we are debugging.
  42456. */
  42457. hide(): void;
  42458. private _render;
  42459. /**
  42460. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42461. * @param mesh Defines the mesh we want the helper attached to
  42462. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42463. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42464. * @param length Defines the length of the ray
  42465. */
  42466. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42467. /**
  42468. * Detach the ray helper from the mesh it has previously been attached to.
  42469. */
  42470. detachFromMesh(): void;
  42471. private _updateToMesh;
  42472. /**
  42473. * Dispose the helper and release its associated resources.
  42474. */
  42475. dispose(): void;
  42476. }
  42477. }
  42478. declare module "babylonjs/Debug/skeletonViewer" {
  42479. import { Color3 } from "babylonjs/Maths/math";
  42480. import { Scene } from "babylonjs/scene";
  42481. import { Nullable } from "babylonjs/types";
  42482. import { Skeleton } from "babylonjs/Bones/skeleton";
  42483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42484. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42485. /**
  42486. * Class used to render a debug view of a given skeleton
  42487. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42488. */
  42489. export class SkeletonViewer {
  42490. /** defines the skeleton to render */
  42491. skeleton: Skeleton;
  42492. /** defines the mesh attached to the skeleton */
  42493. mesh: AbstractMesh;
  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 the color used to render the skeleton */
  42499. color: Color3;
  42500. private _scene;
  42501. private _debugLines;
  42502. private _debugMesh;
  42503. private _isEnabled;
  42504. private _renderFunction;
  42505. private _utilityLayer;
  42506. /**
  42507. * Returns the mesh used to render the bones
  42508. */
  42509. readonly debugMesh: Nullable<LinesMesh>;
  42510. /**
  42511. * Creates a new SkeletonViewer
  42512. * @param skeleton defines the skeleton to render
  42513. * @param mesh defines the mesh attached to the skeleton
  42514. * @param scene defines the hosting scene
  42515. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42516. * @param renderingGroupId defines the rendering group id to use with the viewer
  42517. */
  42518. constructor(
  42519. /** defines the skeleton to render */
  42520. skeleton: Skeleton,
  42521. /** defines the mesh attached to the skeleton */
  42522. mesh: AbstractMesh, scene: Scene,
  42523. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42524. autoUpdateBonesMatrices?: boolean,
  42525. /** defines the rendering group id to use with the viewer */
  42526. renderingGroupId?: number);
  42527. /** Gets or sets a boolean indicating if the viewer is enabled */
  42528. isEnabled: boolean;
  42529. private _getBonePosition;
  42530. private _getLinesForBonesWithLength;
  42531. private _getLinesForBonesNoLength;
  42532. /** Update the viewer to sync with current skeleton state */
  42533. update(): void;
  42534. /** Release associated resources */
  42535. dispose(): void;
  42536. }
  42537. }
  42538. declare module "babylonjs/Debug/index" {
  42539. export * from "babylonjs/Debug/axesViewer";
  42540. export * from "babylonjs/Debug/boneAxesViewer";
  42541. export * from "babylonjs/Debug/debugLayer";
  42542. export * from "babylonjs/Debug/physicsViewer";
  42543. export * from "babylonjs/Debug/rayHelper";
  42544. export * from "babylonjs/Debug/skeletonViewer";
  42545. }
  42546. declare module "babylonjs/Engines/nullEngine" {
  42547. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42548. import { Scene } from "babylonjs/scene";
  42549. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42550. import { Engine } from "babylonjs/Engines/engine";
  42551. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42552. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42553. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42554. import { Effect } from "babylonjs/Materials/effect";
  42555. /**
  42556. * Options to create the null engine
  42557. */
  42558. export class NullEngineOptions {
  42559. /**
  42560. * Render width (Default: 512)
  42561. */
  42562. renderWidth: number;
  42563. /**
  42564. * Render height (Default: 256)
  42565. */
  42566. renderHeight: number;
  42567. /**
  42568. * Texture size (Default: 512)
  42569. */
  42570. textureSize: number;
  42571. /**
  42572. * If delta time between frames should be constant
  42573. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42574. */
  42575. deterministicLockstep: boolean;
  42576. /**
  42577. * Maximum about of steps between frames (Default: 4)
  42578. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42579. */
  42580. lockstepMaxSteps: number;
  42581. }
  42582. /**
  42583. * The null engine class provides support for headless version of babylon.js.
  42584. * This can be used in server side scenario or for testing purposes
  42585. */
  42586. export class NullEngine extends Engine {
  42587. private _options;
  42588. /**
  42589. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42590. */
  42591. isDeterministicLockStep(): boolean;
  42592. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42593. getLockstepMaxSteps(): number;
  42594. /**
  42595. * Sets hardware scaling, used to save performance if needed
  42596. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42597. */
  42598. getHardwareScalingLevel(): number;
  42599. constructor(options?: NullEngineOptions);
  42600. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42601. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  42602. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42603. getRenderWidth(useScreen?: boolean): number;
  42604. getRenderHeight(useScreen?: boolean): number;
  42605. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42606. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42607. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  42608. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  42609. bindSamplers(effect: Effect): void;
  42610. enableEffect(effect: Effect): void;
  42611. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42612. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42613. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42614. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42615. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42616. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42617. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42618. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42619. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42620. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42621. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42622. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42623. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42624. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42625. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42626. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42627. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42628. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42629. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42630. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42631. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42632. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42633. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42634. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42635. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42636. bindBuffers(vertexBuffers: {
  42637. [key: string]: VertexBuffer;
  42638. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  42639. wipeCaches(bruteForce?: boolean): void;
  42640. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42641. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42642. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42643. /** @hidden */
  42644. _createTexture(): WebGLTexture;
  42645. /** @hidden */
  42646. _releaseTexture(texture: InternalTexture): void;
  42647. 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;
  42648. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42649. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42650. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42651. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42652. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42653. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42654. areAllEffectsReady(): boolean;
  42655. /**
  42656. * @hidden
  42657. * Get the current error code of the webGL context
  42658. * @returns the error code
  42659. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42660. */
  42661. getError(): number;
  42662. /** @hidden */
  42663. _getUnpackAlignement(): number;
  42664. /** @hidden */
  42665. _unpackFlipY(value: boolean): void;
  42666. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42667. /**
  42668. * Updates a dynamic vertex buffer.
  42669. * @param vertexBuffer the vertex buffer to update
  42670. * @param data the data used to update the vertex buffer
  42671. * @param byteOffset the byte offset of the data (optional)
  42672. * @param byteLength the byte length of the data (optional)
  42673. */
  42674. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42675. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42676. /** @hidden */
  42677. _bindTexture(channel: number, texture: InternalTexture): void;
  42678. /** @hidden */
  42679. _releaseBuffer(buffer: WebGLBuffer): boolean;
  42680. releaseEffects(): void;
  42681. displayLoadingUI(): void;
  42682. hideLoadingUI(): void;
  42683. /** @hidden */
  42684. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42685. /** @hidden */
  42686. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42687. /** @hidden */
  42688. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42689. /** @hidden */
  42690. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42691. }
  42692. }
  42693. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42694. import { Nullable, int } from "babylonjs/types";
  42695. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42696. /** @hidden */
  42697. export class _OcclusionDataStorage {
  42698. /** @hidden */
  42699. occlusionInternalRetryCounter: number;
  42700. /** @hidden */
  42701. isOcclusionQueryInProgress: boolean;
  42702. /** @hidden */
  42703. isOccluded: boolean;
  42704. /** @hidden */
  42705. occlusionRetryCount: number;
  42706. /** @hidden */
  42707. occlusionType: number;
  42708. /** @hidden */
  42709. occlusionQueryAlgorithmType: number;
  42710. }
  42711. module "babylonjs/Engines/engine" {
  42712. interface Engine {
  42713. /**
  42714. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42715. * @return the new query
  42716. */
  42717. createQuery(): WebGLQuery;
  42718. /**
  42719. * Delete and release a webGL query
  42720. * @param query defines the query to delete
  42721. * @return the current engine
  42722. */
  42723. deleteQuery(query: WebGLQuery): Engine;
  42724. /**
  42725. * Check if a given query has resolved and got its value
  42726. * @param query defines the query to check
  42727. * @returns true if the query got its value
  42728. */
  42729. isQueryResultAvailable(query: WebGLQuery): boolean;
  42730. /**
  42731. * Gets the value of a given query
  42732. * @param query defines the query to check
  42733. * @returns the value of the query
  42734. */
  42735. getQueryResult(query: WebGLQuery): number;
  42736. /**
  42737. * Initiates an occlusion query
  42738. * @param algorithmType defines the algorithm to use
  42739. * @param query defines the query to use
  42740. * @returns the current engine
  42741. * @see http://doc.babylonjs.com/features/occlusionquery
  42742. */
  42743. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42744. /**
  42745. * Ends an occlusion query
  42746. * @see http://doc.babylonjs.com/features/occlusionquery
  42747. * @param algorithmType defines the algorithm to use
  42748. * @returns the current engine
  42749. */
  42750. endOcclusionQuery(algorithmType: number): Engine;
  42751. /**
  42752. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42753. * Please note that only one query can be issued at a time
  42754. * @returns a time token used to track the time span
  42755. */
  42756. startTimeQuery(): Nullable<_TimeToken>;
  42757. /**
  42758. * Ends a time query
  42759. * @param token defines the token used to measure the time span
  42760. * @returns the time spent (in ns)
  42761. */
  42762. endTimeQuery(token: _TimeToken): int;
  42763. /** @hidden */
  42764. _currentNonTimestampToken: Nullable<_TimeToken>;
  42765. /** @hidden */
  42766. _createTimeQuery(): WebGLQuery;
  42767. /** @hidden */
  42768. _deleteTimeQuery(query: WebGLQuery): void;
  42769. /** @hidden */
  42770. _getGlAlgorithmType(algorithmType: number): number;
  42771. /** @hidden */
  42772. _getTimeQueryResult(query: WebGLQuery): any;
  42773. /** @hidden */
  42774. _getTimeQueryAvailability(query: WebGLQuery): any;
  42775. }
  42776. }
  42777. module "babylonjs/Meshes/abstractMesh" {
  42778. interface AbstractMesh {
  42779. /**
  42780. * Backing filed
  42781. * @hidden
  42782. */
  42783. __occlusionDataStorage: _OcclusionDataStorage;
  42784. /**
  42785. * Access property
  42786. * @hidden
  42787. */
  42788. _occlusionDataStorage: _OcclusionDataStorage;
  42789. /**
  42790. * 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.
  42791. * The default value is -1 which means don't break the query and wait till the result
  42792. * @see http://doc.babylonjs.com/features/occlusionquery
  42793. */
  42794. occlusionRetryCount: number;
  42795. /**
  42796. * 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:
  42797. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42798. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42799. * * 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.
  42800. * @see http://doc.babylonjs.com/features/occlusionquery
  42801. */
  42802. occlusionType: number;
  42803. /**
  42804. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42805. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42806. * * 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.
  42807. * @see http://doc.babylonjs.com/features/occlusionquery
  42808. */
  42809. occlusionQueryAlgorithmType: number;
  42810. /**
  42811. * 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
  42812. * @see http://doc.babylonjs.com/features/occlusionquery
  42813. */
  42814. isOccluded: boolean;
  42815. /**
  42816. * Flag to check the progress status of the query
  42817. * @see http://doc.babylonjs.com/features/occlusionquery
  42818. */
  42819. isOcclusionQueryInProgress: boolean;
  42820. }
  42821. }
  42822. }
  42823. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42824. import { Nullable } from "babylonjs/types";
  42825. /** @hidden */
  42826. export var _forceTransformFeedbackToBundle: boolean;
  42827. module "babylonjs/Engines/engine" {
  42828. interface Engine {
  42829. /**
  42830. * Creates a webGL transform feedback object
  42831. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42832. * @returns the webGL transform feedback object
  42833. */
  42834. createTransformFeedback(): WebGLTransformFeedback;
  42835. /**
  42836. * Delete a webGL transform feedback object
  42837. * @param value defines the webGL transform feedback object to delete
  42838. */
  42839. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42840. /**
  42841. * Bind a webGL transform feedback object to the webgl context
  42842. * @param value defines the webGL transform feedback object to bind
  42843. */
  42844. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42845. /**
  42846. * Begins a transform feedback operation
  42847. * @param usePoints defines if points or triangles must be used
  42848. */
  42849. beginTransformFeedback(usePoints: boolean): void;
  42850. /**
  42851. * Ends a transform feedback operation
  42852. */
  42853. endTransformFeedback(): void;
  42854. /**
  42855. * Specify the varyings to use with transform feedback
  42856. * @param program defines the associated webGL program
  42857. * @param value defines the list of strings representing the varying names
  42858. */
  42859. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42860. /**
  42861. * Bind a webGL buffer for a transform feedback operation
  42862. * @param value defines the webGL buffer to bind
  42863. */
  42864. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42865. }
  42866. }
  42867. }
  42868. declare module "babylonjs/Engines/Extensions/index" {
  42869. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42870. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42871. export * from "babylonjs/Engines/Extensions/engine.multiview";
  42872. }
  42873. declare module "babylonjs/Engines/index" {
  42874. export * from "babylonjs/Engines/constants";
  42875. export * from "babylonjs/Engines/engine";
  42876. export * from "babylonjs/Engines/engineStore";
  42877. export * from "babylonjs/Engines/nullEngine";
  42878. export * from "babylonjs/Engines/Extensions/index";
  42879. }
  42880. declare module "babylonjs/Events/clipboardEvents" {
  42881. /**
  42882. * Gather the list of clipboard event types as constants.
  42883. */
  42884. export class ClipboardEventTypes {
  42885. /**
  42886. * The clipboard event is fired when a copy command is active (pressed).
  42887. */
  42888. static readonly COPY: number;
  42889. /**
  42890. * The clipboard event is fired when a cut command is active (pressed).
  42891. */
  42892. static readonly CUT: number;
  42893. /**
  42894. * The clipboard event is fired when a paste command is active (pressed).
  42895. */
  42896. static readonly PASTE: number;
  42897. }
  42898. /**
  42899. * This class is used to store clipboard related info for the onClipboardObservable event.
  42900. */
  42901. export class ClipboardInfo {
  42902. /**
  42903. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42904. */
  42905. type: number;
  42906. /**
  42907. * Defines the related dom event
  42908. */
  42909. event: ClipboardEvent;
  42910. /**
  42911. *Creates an instance of ClipboardInfo.
  42912. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42913. * @param event Defines the related dom event
  42914. */
  42915. constructor(
  42916. /**
  42917. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42918. */
  42919. type: number,
  42920. /**
  42921. * Defines the related dom event
  42922. */
  42923. event: ClipboardEvent);
  42924. /**
  42925. * Get the clipboard event's type from the keycode.
  42926. * @param keyCode Defines the keyCode for the current keyboard event.
  42927. * @return {number}
  42928. */
  42929. static GetTypeFromCharacter(keyCode: number): number;
  42930. }
  42931. }
  42932. declare module "babylonjs/Events/index" {
  42933. export * from "babylonjs/Events/keyboardEvents";
  42934. export * from "babylonjs/Events/pointerEvents";
  42935. export * from "babylonjs/Events/clipboardEvents";
  42936. }
  42937. declare module "babylonjs/Loading/sceneLoader" {
  42938. import { Observable } from "babylonjs/Misc/observable";
  42939. import { Nullable } from "babylonjs/types";
  42940. import { Scene } from "babylonjs/scene";
  42941. import { Engine } from "babylonjs/Engines/engine";
  42942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42943. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42944. import { AssetContainer } from "babylonjs/assetContainer";
  42945. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42946. import { Skeleton } from "babylonjs/Bones/skeleton";
  42947. /**
  42948. * Class used to represent data loading progression
  42949. */
  42950. export class SceneLoaderProgressEvent {
  42951. /** defines if data length to load can be evaluated */
  42952. readonly lengthComputable: boolean;
  42953. /** defines the loaded data length */
  42954. readonly loaded: number;
  42955. /** defines the data length to load */
  42956. readonly total: number;
  42957. /**
  42958. * Create a new progress event
  42959. * @param lengthComputable defines if data length to load can be evaluated
  42960. * @param loaded defines the loaded data length
  42961. * @param total defines the data length to load
  42962. */
  42963. constructor(
  42964. /** defines if data length to load can be evaluated */
  42965. lengthComputable: boolean,
  42966. /** defines the loaded data length */
  42967. loaded: number,
  42968. /** defines the data length to load */
  42969. total: number);
  42970. /**
  42971. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42972. * @param event defines the source event
  42973. * @returns a new SceneLoaderProgressEvent
  42974. */
  42975. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42976. }
  42977. /**
  42978. * Interface used by SceneLoader plugins to define supported file extensions
  42979. */
  42980. export interface ISceneLoaderPluginExtensions {
  42981. /**
  42982. * Defines the list of supported extensions
  42983. */
  42984. [extension: string]: {
  42985. isBinary: boolean;
  42986. };
  42987. }
  42988. /**
  42989. * Interface used by SceneLoader plugin factory
  42990. */
  42991. export interface ISceneLoaderPluginFactory {
  42992. /**
  42993. * Defines the name of the factory
  42994. */
  42995. name: string;
  42996. /**
  42997. * Function called to create a new plugin
  42998. * @return the new plugin
  42999. */
  43000. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43001. /**
  43002. * Boolean indicating if the plugin can direct load specific data
  43003. */
  43004. canDirectLoad?: (data: string) => boolean;
  43005. }
  43006. /**
  43007. * Interface used to define a SceneLoader plugin
  43008. */
  43009. export interface ISceneLoaderPlugin {
  43010. /**
  43011. * The friendly name of this plugin.
  43012. */
  43013. name: string;
  43014. /**
  43015. * The file extensions supported by this plugin.
  43016. */
  43017. extensions: string | ISceneLoaderPluginExtensions;
  43018. /**
  43019. * Import meshes into a scene.
  43020. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43021. * @param scene The scene to import into
  43022. * @param data The data to import
  43023. * @param rootUrl The root url for scene and resources
  43024. * @param meshes The meshes array to import into
  43025. * @param particleSystems The particle systems array to import into
  43026. * @param skeletons The skeletons array to import into
  43027. * @param onError The callback when import fails
  43028. * @returns True if successful or false otherwise
  43029. */
  43030. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43031. /**
  43032. * Load into a scene.
  43033. * @param scene The scene to load into
  43034. * @param data The data to import
  43035. * @param rootUrl The root url for scene and resources
  43036. * @param onError The callback when import fails
  43037. * @returns true if successful or false otherwise
  43038. */
  43039. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43040. /**
  43041. * The callback that returns true if the data can be directly loaded.
  43042. */
  43043. canDirectLoad?: (data: string) => boolean;
  43044. /**
  43045. * The callback that allows custom handling of the root url based on the response url.
  43046. */
  43047. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43048. /**
  43049. * Load into an asset container.
  43050. * @param scene The scene to load into
  43051. * @param data The data to import
  43052. * @param rootUrl The root url for scene and resources
  43053. * @param onError The callback when import fails
  43054. * @returns The loaded asset container
  43055. */
  43056. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43057. }
  43058. /**
  43059. * Interface used to define an async SceneLoader plugin
  43060. */
  43061. export interface ISceneLoaderPluginAsync {
  43062. /**
  43063. * The friendly name of this plugin.
  43064. */
  43065. name: string;
  43066. /**
  43067. * The file extensions supported by this plugin.
  43068. */
  43069. extensions: string | ISceneLoaderPluginExtensions;
  43070. /**
  43071. * Import meshes into a scene.
  43072. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43073. * @param scene The scene to import into
  43074. * @param data The data to import
  43075. * @param rootUrl The root url for scene and resources
  43076. * @param onProgress The callback when the load progresses
  43077. * @param fileName Defines the name of the file to load
  43078. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43079. */
  43080. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43081. meshes: AbstractMesh[];
  43082. particleSystems: IParticleSystem[];
  43083. skeletons: Skeleton[];
  43084. animationGroups: AnimationGroup[];
  43085. }>;
  43086. /**
  43087. * Load into a scene.
  43088. * @param scene The scene to load into
  43089. * @param data The data to import
  43090. * @param rootUrl The root url for scene and resources
  43091. * @param onProgress The callback when the load progresses
  43092. * @param fileName Defines the name of the file to load
  43093. * @returns Nothing
  43094. */
  43095. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43096. /**
  43097. * The callback that returns true if the data can be directly loaded.
  43098. */
  43099. canDirectLoad?: (data: string) => boolean;
  43100. /**
  43101. * The callback that allows custom handling of the root url based on the response url.
  43102. */
  43103. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43104. /**
  43105. * Load into an asset container.
  43106. * @param scene The scene to load into
  43107. * @param data The data to import
  43108. * @param rootUrl The root url for scene and resources
  43109. * @param onProgress The callback when the load progresses
  43110. * @param fileName Defines the name of the file to load
  43111. * @returns The loaded asset container
  43112. */
  43113. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43114. }
  43115. /**
  43116. * Class used to load scene from various file formats using registered plugins
  43117. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43118. */
  43119. export class SceneLoader {
  43120. /**
  43121. * No logging while loading
  43122. */
  43123. static readonly NO_LOGGING: number;
  43124. /**
  43125. * Minimal logging while loading
  43126. */
  43127. static readonly MINIMAL_LOGGING: number;
  43128. /**
  43129. * Summary logging while loading
  43130. */
  43131. static readonly SUMMARY_LOGGING: number;
  43132. /**
  43133. * Detailled logging while loading
  43134. */
  43135. static readonly DETAILED_LOGGING: number;
  43136. /**
  43137. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43138. */
  43139. static ForceFullSceneLoadingForIncremental: boolean;
  43140. /**
  43141. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43142. */
  43143. static ShowLoadingScreen: boolean;
  43144. /**
  43145. * Defines the current logging level (while loading the scene)
  43146. * @ignorenaming
  43147. */
  43148. static loggingLevel: number;
  43149. /**
  43150. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43151. */
  43152. static CleanBoneMatrixWeights: boolean;
  43153. /**
  43154. * Event raised when a plugin is used to load a scene
  43155. */
  43156. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43157. private static _registeredPlugins;
  43158. private static _getDefaultPlugin;
  43159. private static _getPluginForExtension;
  43160. private static _getPluginForDirectLoad;
  43161. private static _getPluginForFilename;
  43162. private static _getDirectLoad;
  43163. private static _loadData;
  43164. private static _getFileInfo;
  43165. /**
  43166. * Gets a plugin that can load the given extension
  43167. * @param extension defines the extension to load
  43168. * @returns a plugin or null if none works
  43169. */
  43170. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43171. /**
  43172. * Gets a boolean indicating that the given extension can be loaded
  43173. * @param extension defines the extension to load
  43174. * @returns true if the extension is supported
  43175. */
  43176. static IsPluginForExtensionAvailable(extension: string): boolean;
  43177. /**
  43178. * Adds a new plugin to the list of registered plugins
  43179. * @param plugin defines the plugin to add
  43180. */
  43181. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43182. /**
  43183. * Import meshes into a scene
  43184. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43185. * @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)
  43186. * @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)
  43187. * @param scene the instance of BABYLON.Scene to append to
  43188. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43189. * @param onProgress a callback with a progress event for each file being loaded
  43190. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43191. * @param pluginExtension the extension used to determine the plugin
  43192. * @returns The loaded plugin
  43193. */
  43194. 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>;
  43195. /**
  43196. * Import meshes into a scene
  43197. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43198. * @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)
  43199. * @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)
  43200. * @param scene the instance of BABYLON.Scene to append to
  43201. * @param onProgress a callback with a progress event for each file being loaded
  43202. * @param pluginExtension the extension used to determine the plugin
  43203. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43204. */
  43205. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43206. meshes: AbstractMesh[];
  43207. particleSystems: IParticleSystem[];
  43208. skeletons: Skeleton[];
  43209. animationGroups: AnimationGroup[];
  43210. }>;
  43211. /**
  43212. * Load a scene
  43213. * @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)
  43214. * @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)
  43215. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43216. * @param onSuccess a callback with the scene when import succeeds
  43217. * @param onProgress a callback with a progress event for each file being loaded
  43218. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43219. * @param pluginExtension the extension used to determine the plugin
  43220. * @returns The loaded plugin
  43221. */
  43222. 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>;
  43223. /**
  43224. * Load a scene
  43225. * @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)
  43226. * @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)
  43227. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43228. * @param onProgress a callback with a progress event for each file being loaded
  43229. * @param pluginExtension the extension used to determine the plugin
  43230. * @returns The loaded scene
  43231. */
  43232. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43233. /**
  43234. * Append a scene
  43235. * @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)
  43236. * @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)
  43237. * @param scene is the instance of BABYLON.Scene to append to
  43238. * @param onSuccess a callback with the scene when import succeeds
  43239. * @param onProgress a callback with a progress event for each file being loaded
  43240. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43241. * @param pluginExtension the extension used to determine the plugin
  43242. * @returns The loaded plugin
  43243. */
  43244. 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>;
  43245. /**
  43246. * Append a scene
  43247. * @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)
  43248. * @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)
  43249. * @param scene is the instance of BABYLON.Scene to append to
  43250. * @param onProgress a callback with a progress event for each file being loaded
  43251. * @param pluginExtension the extension used to determine the plugin
  43252. * @returns The given scene
  43253. */
  43254. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43255. /**
  43256. * Load a scene into an asset container
  43257. * @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)
  43258. * @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)
  43259. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43260. * @param onSuccess a callback with the scene when import succeeds
  43261. * @param onProgress a callback with a progress event for each file being loaded
  43262. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43263. * @param pluginExtension the extension used to determine the plugin
  43264. * @returns The loaded plugin
  43265. */
  43266. 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>;
  43267. /**
  43268. * Load a scene into an asset container
  43269. * @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)
  43270. * @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)
  43271. * @param scene is the instance of Scene to append to
  43272. * @param onProgress a callback with a progress event for each file being loaded
  43273. * @param pluginExtension the extension used to determine the plugin
  43274. * @returns The loaded asset container
  43275. */
  43276. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43277. }
  43278. }
  43279. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43280. import { Scene } from "babylonjs/scene";
  43281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43282. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43283. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43284. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43285. /**
  43286. * Google Daydream controller
  43287. */
  43288. export class DaydreamController extends WebVRController {
  43289. /**
  43290. * Base Url for the controller model.
  43291. */
  43292. static MODEL_BASE_URL: string;
  43293. /**
  43294. * File name for the controller model.
  43295. */
  43296. static MODEL_FILENAME: string;
  43297. /**
  43298. * Gamepad Id prefix used to identify Daydream Controller.
  43299. */
  43300. static readonly GAMEPAD_ID_PREFIX: string;
  43301. /**
  43302. * Creates a new DaydreamController from a gamepad
  43303. * @param vrGamepad the gamepad that the controller should be created from
  43304. */
  43305. constructor(vrGamepad: any);
  43306. /**
  43307. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43308. * @param scene scene in which to add meshes
  43309. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43310. */
  43311. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43312. /**
  43313. * Called once for each button that changed state since the last frame
  43314. * @param buttonIdx Which button index changed
  43315. * @param state New state of the button
  43316. * @param changes Which properties on the state changed since last frame
  43317. */
  43318. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43319. }
  43320. }
  43321. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43322. import { Scene } from "babylonjs/scene";
  43323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43324. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43325. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43326. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43327. /**
  43328. * Gear VR Controller
  43329. */
  43330. export class GearVRController extends WebVRController {
  43331. /**
  43332. * Base Url for the controller model.
  43333. */
  43334. static MODEL_BASE_URL: string;
  43335. /**
  43336. * File name for the controller model.
  43337. */
  43338. static MODEL_FILENAME: string;
  43339. /**
  43340. * Gamepad Id prefix used to identify this controller.
  43341. */
  43342. static readonly GAMEPAD_ID_PREFIX: string;
  43343. private readonly _buttonIndexToObservableNameMap;
  43344. /**
  43345. * Creates a new GearVRController from a gamepad
  43346. * @param vrGamepad the gamepad that the controller should be created from
  43347. */
  43348. constructor(vrGamepad: any);
  43349. /**
  43350. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43351. * @param scene scene in which to add meshes
  43352. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43353. */
  43354. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43355. /**
  43356. * Called once for each button that changed state since the last frame
  43357. * @param buttonIdx Which button index changed
  43358. * @param state New state of the button
  43359. * @param changes Which properties on the state changed since last frame
  43360. */
  43361. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43362. }
  43363. }
  43364. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43365. import { Scene } from "babylonjs/scene";
  43366. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43367. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43368. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43369. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43370. /**
  43371. * Generic Controller
  43372. */
  43373. export class GenericController extends WebVRController {
  43374. /**
  43375. * Base Url for the controller model.
  43376. */
  43377. static readonly MODEL_BASE_URL: string;
  43378. /**
  43379. * File name for the controller model.
  43380. */
  43381. static readonly MODEL_FILENAME: string;
  43382. /**
  43383. * Creates a new GenericController from a gamepad
  43384. * @param vrGamepad the gamepad that the controller should be created from
  43385. */
  43386. constructor(vrGamepad: any);
  43387. /**
  43388. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43389. * @param scene scene in which to add meshes
  43390. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43391. */
  43392. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43393. /**
  43394. * Called once for each button that changed state since the last frame
  43395. * @param buttonIdx Which button index changed
  43396. * @param state New state of the button
  43397. * @param changes Which properties on the state changed since last frame
  43398. */
  43399. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43400. }
  43401. }
  43402. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43403. import { Observable } from "babylonjs/Misc/observable";
  43404. import { Scene } from "babylonjs/scene";
  43405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43406. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43407. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43408. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43409. /**
  43410. * Oculus Touch Controller
  43411. */
  43412. export class OculusTouchController extends WebVRController {
  43413. /**
  43414. * Base Url for the controller model.
  43415. */
  43416. static MODEL_BASE_URL: string;
  43417. /**
  43418. * File name for the left controller model.
  43419. */
  43420. static MODEL_LEFT_FILENAME: string;
  43421. /**
  43422. * File name for the right controller model.
  43423. */
  43424. static MODEL_RIGHT_FILENAME: string;
  43425. /**
  43426. * Fired when the secondary trigger on this controller is modified
  43427. */
  43428. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43429. /**
  43430. * Fired when the thumb rest on this controller is modified
  43431. */
  43432. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43433. /**
  43434. * Creates a new OculusTouchController from a gamepad
  43435. * @param vrGamepad the gamepad that the controller should be created from
  43436. */
  43437. constructor(vrGamepad: any);
  43438. /**
  43439. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43440. * @param scene scene in which to add meshes
  43441. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43442. */
  43443. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43444. /**
  43445. * Fired when the A button on this controller is modified
  43446. */
  43447. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43448. /**
  43449. * Fired when the B button on this controller is modified
  43450. */
  43451. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43452. /**
  43453. * Fired when the X button on this controller is modified
  43454. */
  43455. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43456. /**
  43457. * Fired when the Y button on this controller is modified
  43458. */
  43459. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43460. /**
  43461. * Called once for each button that changed state since the last frame
  43462. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43463. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43464. * 2) secondary trigger (same)
  43465. * 3) A (right) X (left), touch, pressed = value
  43466. * 4) B / Y
  43467. * 5) thumb rest
  43468. * @param buttonIdx Which button index changed
  43469. * @param state New state of the button
  43470. * @param changes Which properties on the state changed since last frame
  43471. */
  43472. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43473. }
  43474. }
  43475. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43476. import { Scene } from "babylonjs/scene";
  43477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43478. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43479. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43480. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43481. import { Observable } from "babylonjs/Misc/observable";
  43482. /**
  43483. * Vive Controller
  43484. */
  43485. export class ViveController extends WebVRController {
  43486. /**
  43487. * Base Url for the controller model.
  43488. */
  43489. static MODEL_BASE_URL: string;
  43490. /**
  43491. * File name for the controller model.
  43492. */
  43493. static MODEL_FILENAME: string;
  43494. /**
  43495. * Creates a new ViveController from a gamepad
  43496. * @param vrGamepad the gamepad that the controller should be created from
  43497. */
  43498. constructor(vrGamepad: any);
  43499. /**
  43500. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43501. * @param scene scene in which to add meshes
  43502. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43503. */
  43504. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43505. /**
  43506. * Fired when the left button on this controller is modified
  43507. */
  43508. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43509. /**
  43510. * Fired when the right button on this controller is modified
  43511. */
  43512. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43513. /**
  43514. * Fired when the menu button on this controller is modified
  43515. */
  43516. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43517. /**
  43518. * Called once for each button that changed state since the last frame
  43519. * Vive mapping:
  43520. * 0: touchpad
  43521. * 1: trigger
  43522. * 2: left AND right buttons
  43523. * 3: menu button
  43524. * @param buttonIdx Which button index changed
  43525. * @param state New state of the button
  43526. * @param changes Which properties on the state changed since last frame
  43527. */
  43528. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43529. }
  43530. }
  43531. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43532. import { Observable } from "babylonjs/Misc/observable";
  43533. import { Scene } from "babylonjs/scene";
  43534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43535. import { Ray } from "babylonjs/Culling/ray";
  43536. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43537. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43538. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43539. /**
  43540. * Defines the WindowsMotionController object that the state of the windows motion controller
  43541. */
  43542. export class WindowsMotionController extends WebVRController {
  43543. /**
  43544. * The base url used to load the left and right controller models
  43545. */
  43546. static MODEL_BASE_URL: string;
  43547. /**
  43548. * The name of the left controller model file
  43549. */
  43550. static MODEL_LEFT_FILENAME: string;
  43551. /**
  43552. * The name of the right controller model file
  43553. */
  43554. static MODEL_RIGHT_FILENAME: string;
  43555. /**
  43556. * The controller name prefix for this controller type
  43557. */
  43558. static readonly GAMEPAD_ID_PREFIX: string;
  43559. /**
  43560. * The controller id pattern for this controller type
  43561. */
  43562. private static readonly GAMEPAD_ID_PATTERN;
  43563. private _loadedMeshInfo;
  43564. private readonly _mapping;
  43565. /**
  43566. * Fired when the trackpad on this controller is clicked
  43567. */
  43568. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43569. /**
  43570. * Fired when the trackpad on this controller is modified
  43571. */
  43572. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43573. /**
  43574. * The current x and y values of this controller's trackpad
  43575. */
  43576. trackpad: StickValues;
  43577. /**
  43578. * Creates a new WindowsMotionController from a gamepad
  43579. * @param vrGamepad the gamepad that the controller should be created from
  43580. */
  43581. constructor(vrGamepad: any);
  43582. /**
  43583. * Fired when the trigger on this controller is modified
  43584. */
  43585. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43586. /**
  43587. * Fired when the menu button on this controller is modified
  43588. */
  43589. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43590. /**
  43591. * Fired when the grip button on this controller is modified
  43592. */
  43593. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43594. /**
  43595. * Fired when the thumbstick button on this controller is modified
  43596. */
  43597. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43598. /**
  43599. * Fired when the touchpad button on this controller is modified
  43600. */
  43601. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43602. /**
  43603. * Fired when the touchpad values on this controller are modified
  43604. */
  43605. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43606. private _updateTrackpad;
  43607. /**
  43608. * Called once per frame by the engine.
  43609. */
  43610. update(): void;
  43611. /**
  43612. * Called once for each button that changed state since the last frame
  43613. * @param buttonIdx Which button index changed
  43614. * @param state New state of the button
  43615. * @param changes Which properties on the state changed since last frame
  43616. */
  43617. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43618. /**
  43619. * Moves the buttons on the controller mesh based on their current state
  43620. * @param buttonName the name of the button to move
  43621. * @param buttonValue the value of the button which determines the buttons new position
  43622. */
  43623. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43624. /**
  43625. * Moves the axis on the controller mesh based on its current state
  43626. * @param axis the index of the axis
  43627. * @param axisValue the value of the axis which determines the meshes new position
  43628. * @hidden
  43629. */
  43630. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43631. /**
  43632. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43633. * @param scene scene in which to add meshes
  43634. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43635. */
  43636. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43637. /**
  43638. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43639. * can be transformed by button presses and axes values, based on this._mapping.
  43640. *
  43641. * @param scene scene in which the meshes exist
  43642. * @param meshes list of meshes that make up the controller model to process
  43643. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43644. */
  43645. private processModel;
  43646. private createMeshInfo;
  43647. /**
  43648. * Gets the ray of the controller in the direction the controller is pointing
  43649. * @param length the length the resulting ray should be
  43650. * @returns a ray in the direction the controller is pointing
  43651. */
  43652. getForwardRay(length?: number): Ray;
  43653. /**
  43654. * Disposes of the controller
  43655. */
  43656. dispose(): void;
  43657. }
  43658. }
  43659. declare module "babylonjs/Gamepads/Controllers/index" {
  43660. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  43661. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  43662. export * from "babylonjs/Gamepads/Controllers/genericController";
  43663. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  43664. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43665. export * from "babylonjs/Gamepads/Controllers/viveController";
  43666. export * from "babylonjs/Gamepads/Controllers/webVRController";
  43667. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  43668. }
  43669. declare module "babylonjs/Gamepads/index" {
  43670. export * from "babylonjs/Gamepads/Controllers/index";
  43671. export * from "babylonjs/Gamepads/gamepad";
  43672. export * from "babylonjs/Gamepads/gamepadManager";
  43673. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43674. export * from "babylonjs/Gamepads/xboxGamepad";
  43675. }
  43676. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43677. import { Observable } from "babylonjs/Misc/observable";
  43678. import { Nullable } from "babylonjs/types";
  43679. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43681. import { Mesh } from "babylonjs/Meshes/mesh";
  43682. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43683. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43684. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43685. /**
  43686. * Single axis scale gizmo
  43687. */
  43688. export class AxisScaleGizmo extends Gizmo {
  43689. private _coloredMaterial;
  43690. /**
  43691. * Drag behavior responsible for the gizmos dragging interactions
  43692. */
  43693. dragBehavior: PointerDragBehavior;
  43694. private _pointerObserver;
  43695. /**
  43696. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43697. */
  43698. snapDistance: number;
  43699. /**
  43700. * Event that fires each time the gizmo snaps to a new location.
  43701. * * snapDistance is the the change in distance
  43702. */
  43703. onSnapObservable: Observable<{
  43704. snapDistance: number;
  43705. }>;
  43706. /**
  43707. * If the scaling operation should be done on all axis (default: false)
  43708. */
  43709. uniformScaling: boolean;
  43710. /**
  43711. * Creates an AxisScaleGizmo
  43712. * @param gizmoLayer The utility layer the gizmo will be added to
  43713. * @param dragAxis The axis which the gizmo will be able to scale on
  43714. * @param color The color of the gizmo
  43715. */
  43716. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43717. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43718. /**
  43719. * Disposes of the gizmo
  43720. */
  43721. dispose(): void;
  43722. /**
  43723. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43724. * @param mesh The mesh to replace the default mesh of the gizmo
  43725. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43726. */
  43727. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43728. }
  43729. }
  43730. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43731. import { Observable } from "babylonjs/Misc/observable";
  43732. import { Nullable } from "babylonjs/types";
  43733. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43735. import { Mesh } from "babylonjs/Meshes/mesh";
  43736. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43737. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43738. import "babylonjs/Meshes/Builders/boxBuilder";
  43739. /**
  43740. * Bounding box gizmo
  43741. */
  43742. export class BoundingBoxGizmo extends Gizmo {
  43743. private _lineBoundingBox;
  43744. private _rotateSpheresParent;
  43745. private _scaleBoxesParent;
  43746. private _boundingDimensions;
  43747. private _renderObserver;
  43748. private _pointerObserver;
  43749. private _scaleDragSpeed;
  43750. private _tmpQuaternion;
  43751. private _tmpVector;
  43752. private _tmpRotationMatrix;
  43753. /**
  43754. * 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)
  43755. */
  43756. ignoreChildren: boolean;
  43757. /**
  43758. * 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)
  43759. */
  43760. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43761. /**
  43762. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43763. */
  43764. rotationSphereSize: number;
  43765. /**
  43766. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43767. */
  43768. scaleBoxSize: number;
  43769. /**
  43770. * 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)
  43771. */
  43772. fixedDragMeshScreenSize: boolean;
  43773. /**
  43774. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43775. */
  43776. fixedDragMeshScreenSizeDistanceFactor: number;
  43777. /**
  43778. * Fired when a rotation sphere or scale box is dragged
  43779. */
  43780. onDragStartObservable: Observable<{}>;
  43781. /**
  43782. * Fired when a scale box is dragged
  43783. */
  43784. onScaleBoxDragObservable: Observable<{}>;
  43785. /**
  43786. * Fired when a scale box drag is ended
  43787. */
  43788. onScaleBoxDragEndObservable: Observable<{}>;
  43789. /**
  43790. * Fired when a rotation sphere is dragged
  43791. */
  43792. onRotationSphereDragObservable: Observable<{}>;
  43793. /**
  43794. * Fired when a rotation sphere drag is ended
  43795. */
  43796. onRotationSphereDragEndObservable: Observable<{}>;
  43797. /**
  43798. * 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)
  43799. */
  43800. scalePivot: Nullable<Vector3>;
  43801. private _anchorMesh;
  43802. private _existingMeshScale;
  43803. private _dragMesh;
  43804. private pointerDragBehavior;
  43805. private coloredMaterial;
  43806. private hoverColoredMaterial;
  43807. /**
  43808. * Sets the color of the bounding box gizmo
  43809. * @param color the color to set
  43810. */
  43811. setColor(color: Color3): void;
  43812. /**
  43813. * Creates an BoundingBoxGizmo
  43814. * @param gizmoLayer The utility layer the gizmo will be added to
  43815. * @param color The color of the gizmo
  43816. */
  43817. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43818. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43819. private _selectNode;
  43820. /**
  43821. * Updates the bounding box information for the Gizmo
  43822. */
  43823. updateBoundingBox(): void;
  43824. private _updateRotationSpheres;
  43825. private _updateScaleBoxes;
  43826. /**
  43827. * Enables rotation on the specified axis and disables rotation on the others
  43828. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43829. */
  43830. setEnabledRotationAxis(axis: string): void;
  43831. /**
  43832. * Enables/disables scaling
  43833. * @param enable if scaling should be enabled
  43834. */
  43835. setEnabledScaling(enable: boolean): void;
  43836. private _updateDummy;
  43837. /**
  43838. * Enables a pointer drag behavior on the bounding box of the gizmo
  43839. */
  43840. enableDragBehavior(): void;
  43841. /**
  43842. * Disposes of the gizmo
  43843. */
  43844. dispose(): void;
  43845. /**
  43846. * 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)
  43847. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43848. * @returns the bounding box mesh with the passed in mesh as a child
  43849. */
  43850. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43851. /**
  43852. * CustomMeshes are not supported by this gizmo
  43853. * @param mesh The mesh to replace the default mesh of the gizmo
  43854. */
  43855. setCustomMesh(mesh: Mesh): void;
  43856. }
  43857. }
  43858. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43859. import { Observable } from "babylonjs/Misc/observable";
  43860. import { Nullable } from "babylonjs/types";
  43861. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43863. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43864. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43865. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43866. import "babylonjs/Meshes/Builders/linesBuilder";
  43867. /**
  43868. * Single plane rotation gizmo
  43869. */
  43870. export class PlaneRotationGizmo extends Gizmo {
  43871. /**
  43872. * Drag behavior responsible for the gizmos dragging interactions
  43873. */
  43874. dragBehavior: PointerDragBehavior;
  43875. private _pointerObserver;
  43876. /**
  43877. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43878. */
  43879. snapDistance: number;
  43880. /**
  43881. * Event that fires each time the gizmo snaps to a new location.
  43882. * * snapDistance is the the change in distance
  43883. */
  43884. onSnapObservable: Observable<{
  43885. snapDistance: number;
  43886. }>;
  43887. /**
  43888. * Creates a PlaneRotationGizmo
  43889. * @param gizmoLayer The utility layer the gizmo will be added to
  43890. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43891. * @param color The color of the gizmo
  43892. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43893. */
  43894. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43895. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43896. /**
  43897. * Disposes of the gizmo
  43898. */
  43899. dispose(): void;
  43900. }
  43901. }
  43902. declare module "babylonjs/Gizmos/rotationGizmo" {
  43903. import { Observable } from "babylonjs/Misc/observable";
  43904. import { Nullable } from "babylonjs/types";
  43905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43906. import { Mesh } from "babylonjs/Meshes/mesh";
  43907. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43908. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43909. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43910. /**
  43911. * Gizmo that enables rotating a mesh along 3 axis
  43912. */
  43913. export class RotationGizmo extends Gizmo {
  43914. /**
  43915. * Internal gizmo used for interactions on the x axis
  43916. */
  43917. xGizmo: PlaneRotationGizmo;
  43918. /**
  43919. * Internal gizmo used for interactions on the y axis
  43920. */
  43921. yGizmo: PlaneRotationGizmo;
  43922. /**
  43923. * Internal gizmo used for interactions on the z axis
  43924. */
  43925. zGizmo: PlaneRotationGizmo;
  43926. /** Fires an event when any of it's sub gizmos are dragged */
  43927. onDragStartObservable: Observable<{}>;
  43928. /** Fires an event when any of it's sub gizmos are released from dragging */
  43929. onDragEndObservable: Observable<{}>;
  43930. attachedMesh: Nullable<AbstractMesh>;
  43931. /**
  43932. * Creates a RotationGizmo
  43933. * @param gizmoLayer The utility layer the gizmo will be added to
  43934. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43935. */
  43936. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43937. updateGizmoRotationToMatchAttachedMesh: boolean;
  43938. /**
  43939. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43940. */
  43941. snapDistance: number;
  43942. /**
  43943. * Ratio for the scale of the gizmo (Default: 1)
  43944. */
  43945. scaleRatio: number;
  43946. /**
  43947. * Disposes of the gizmo
  43948. */
  43949. dispose(): void;
  43950. /**
  43951. * CustomMeshes are not supported by this gizmo
  43952. * @param mesh The mesh to replace the default mesh of the gizmo
  43953. */
  43954. setCustomMesh(mesh: Mesh): void;
  43955. }
  43956. }
  43957. declare module "babylonjs/Gizmos/positionGizmo" {
  43958. import { Observable } from "babylonjs/Misc/observable";
  43959. import { Nullable } from "babylonjs/types";
  43960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43961. import { Mesh } from "babylonjs/Meshes/mesh";
  43962. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43963. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43964. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43965. /**
  43966. * Gizmo that enables dragging a mesh along 3 axis
  43967. */
  43968. export class PositionGizmo extends Gizmo {
  43969. /**
  43970. * Internal gizmo used for interactions on the x axis
  43971. */
  43972. xGizmo: AxisDragGizmo;
  43973. /**
  43974. * Internal gizmo used for interactions on the y axis
  43975. */
  43976. yGizmo: AxisDragGizmo;
  43977. /**
  43978. * Internal gizmo used for interactions on the z axis
  43979. */
  43980. zGizmo: AxisDragGizmo;
  43981. /** Fires an event when any of it's sub gizmos are dragged */
  43982. onDragStartObservable: Observable<{}>;
  43983. /** Fires an event when any of it's sub gizmos are released from dragging */
  43984. onDragEndObservable: Observable<{}>;
  43985. attachedMesh: Nullable<AbstractMesh>;
  43986. /**
  43987. * Creates a PositionGizmo
  43988. * @param gizmoLayer The utility layer the gizmo will be added to
  43989. */
  43990. constructor(gizmoLayer?: UtilityLayerRenderer);
  43991. updateGizmoRotationToMatchAttachedMesh: boolean;
  43992. /**
  43993. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43994. */
  43995. snapDistance: number;
  43996. /**
  43997. * Ratio for the scale of the gizmo (Default: 1)
  43998. */
  43999. scaleRatio: number;
  44000. /**
  44001. * Disposes of the gizmo
  44002. */
  44003. dispose(): void;
  44004. /**
  44005. * CustomMeshes are not supported by this gizmo
  44006. * @param mesh The mesh to replace the default mesh of the gizmo
  44007. */
  44008. setCustomMesh(mesh: Mesh): void;
  44009. }
  44010. }
  44011. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44012. import { Scene } from "babylonjs/scene";
  44013. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44014. import { Mesh } from "babylonjs/Meshes/mesh";
  44015. import { Nullable } from "babylonjs/types";
  44016. /**
  44017. * Class containing static functions to help procedurally build meshes
  44018. */
  44019. export class PolyhedronBuilder {
  44020. /**
  44021. * Creates a polyhedron mesh
  44022. * * 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
  44023. * * The parameter `size` (positive float, default 1) sets the polygon size
  44024. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44025. * * 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`
  44026. * * 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
  44027. * * 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)`)
  44028. * * 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
  44029. * * 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
  44030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44031. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44033. * @param name defines the name of the mesh
  44034. * @param options defines the options used to create the mesh
  44035. * @param scene defines the hosting scene
  44036. * @returns the polyhedron mesh
  44037. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44038. */
  44039. static CreatePolyhedron(name: string, options: {
  44040. type?: number;
  44041. size?: number;
  44042. sizeX?: number;
  44043. sizeY?: number;
  44044. sizeZ?: number;
  44045. custom?: any;
  44046. faceUV?: Vector4[];
  44047. faceColors?: Color4[];
  44048. flat?: boolean;
  44049. updatable?: boolean;
  44050. sideOrientation?: number;
  44051. frontUVs?: Vector4;
  44052. backUVs?: Vector4;
  44053. }, scene?: Nullable<Scene>): Mesh;
  44054. }
  44055. }
  44056. declare module "babylonjs/Gizmos/scaleGizmo" {
  44057. import { Observable } from "babylonjs/Misc/observable";
  44058. import { Nullable } from "babylonjs/types";
  44059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44060. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44061. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44062. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44063. /**
  44064. * Gizmo that enables scaling a mesh along 3 axis
  44065. */
  44066. export class ScaleGizmo extends Gizmo {
  44067. /**
  44068. * Internal gizmo used for interactions on the x axis
  44069. */
  44070. xGizmo: AxisScaleGizmo;
  44071. /**
  44072. * Internal gizmo used for interactions on the y axis
  44073. */
  44074. yGizmo: AxisScaleGizmo;
  44075. /**
  44076. * Internal gizmo used for interactions on the z axis
  44077. */
  44078. zGizmo: AxisScaleGizmo;
  44079. /**
  44080. * Internal gizmo used to scale all axis equally
  44081. */
  44082. uniformScaleGizmo: AxisScaleGizmo;
  44083. /** Fires an event when any of it's sub gizmos are dragged */
  44084. onDragStartObservable: Observable<{}>;
  44085. /** Fires an event when any of it's sub gizmos are released from dragging */
  44086. onDragEndObservable: Observable<{}>;
  44087. attachedMesh: Nullable<AbstractMesh>;
  44088. /**
  44089. * Creates a ScaleGizmo
  44090. * @param gizmoLayer The utility layer the gizmo will be added to
  44091. */
  44092. constructor(gizmoLayer?: UtilityLayerRenderer);
  44093. updateGizmoRotationToMatchAttachedMesh: boolean;
  44094. /**
  44095. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44096. */
  44097. snapDistance: number;
  44098. /**
  44099. * Ratio for the scale of the gizmo (Default: 1)
  44100. */
  44101. scaleRatio: number;
  44102. /**
  44103. * Disposes of the gizmo
  44104. */
  44105. dispose(): void;
  44106. }
  44107. }
  44108. declare module "babylonjs/Gizmos/gizmoManager" {
  44109. import { Observable } from "babylonjs/Misc/observable";
  44110. import { Nullable } from "babylonjs/types";
  44111. import { Scene, IDisposable } from "babylonjs/scene";
  44112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44113. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44114. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44115. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44116. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44117. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44118. /**
  44119. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44120. */
  44121. export class GizmoManager implements IDisposable {
  44122. private scene;
  44123. /**
  44124. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44125. */
  44126. gizmos: {
  44127. positionGizmo: Nullable<PositionGizmo>;
  44128. rotationGizmo: Nullable<RotationGizmo>;
  44129. scaleGizmo: Nullable<ScaleGizmo>;
  44130. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44131. };
  44132. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44133. clearGizmoOnEmptyPointerEvent: boolean;
  44134. /** Fires an event when the manager is attached to a mesh */
  44135. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44136. private _gizmosEnabled;
  44137. private _pointerObserver;
  44138. private _attachedMesh;
  44139. private _boundingBoxColor;
  44140. private _defaultUtilityLayer;
  44141. private _defaultKeepDepthUtilityLayer;
  44142. /**
  44143. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44144. */
  44145. boundingBoxDragBehavior: SixDofDragBehavior;
  44146. /**
  44147. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44148. */
  44149. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44150. /**
  44151. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44152. */
  44153. usePointerToAttachGizmos: boolean;
  44154. /**
  44155. * Instatiates a gizmo manager
  44156. * @param scene the scene to overlay the gizmos on top of
  44157. */
  44158. constructor(scene: Scene);
  44159. /**
  44160. * Attaches a set of gizmos to the specified mesh
  44161. * @param mesh The mesh the gizmo's should be attached to
  44162. */
  44163. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44164. /**
  44165. * If the position gizmo is enabled
  44166. */
  44167. positionGizmoEnabled: boolean;
  44168. /**
  44169. * If the rotation gizmo is enabled
  44170. */
  44171. rotationGizmoEnabled: boolean;
  44172. /**
  44173. * If the scale gizmo is enabled
  44174. */
  44175. scaleGizmoEnabled: boolean;
  44176. /**
  44177. * If the boundingBox gizmo is enabled
  44178. */
  44179. boundingBoxGizmoEnabled: boolean;
  44180. /**
  44181. * Disposes of the gizmo manager
  44182. */
  44183. dispose(): void;
  44184. }
  44185. }
  44186. declare module "babylonjs/Lights/directionalLight" {
  44187. import { Camera } from "babylonjs/Cameras/camera";
  44188. import { Scene } from "babylonjs/scene";
  44189. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44191. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44192. import { Effect } from "babylonjs/Materials/effect";
  44193. /**
  44194. * A directional light is defined by a direction (what a surprise!).
  44195. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44196. * 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.
  44197. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44198. */
  44199. export class DirectionalLight extends ShadowLight {
  44200. private _shadowFrustumSize;
  44201. /**
  44202. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44203. */
  44204. /**
  44205. * Specifies a fix frustum size for the shadow generation.
  44206. */
  44207. shadowFrustumSize: number;
  44208. private _shadowOrthoScale;
  44209. /**
  44210. * Gets the shadow projection scale against the optimal computed one.
  44211. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44212. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44213. */
  44214. /**
  44215. * Sets the shadow projection scale against the optimal computed one.
  44216. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44217. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44218. */
  44219. shadowOrthoScale: number;
  44220. /**
  44221. * Automatically compute the projection matrix to best fit (including all the casters)
  44222. * on each frame.
  44223. */
  44224. autoUpdateExtends: boolean;
  44225. private _orthoLeft;
  44226. private _orthoRight;
  44227. private _orthoTop;
  44228. private _orthoBottom;
  44229. /**
  44230. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44231. * The directional light is emitted from everywhere in the given direction.
  44232. * It can cast shadows.
  44233. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44234. * @param name The friendly name of the light
  44235. * @param direction The direction of the light
  44236. * @param scene The scene the light belongs to
  44237. */
  44238. constructor(name: string, direction: Vector3, scene: Scene);
  44239. /**
  44240. * Returns the string "DirectionalLight".
  44241. * @return The class name
  44242. */
  44243. getClassName(): string;
  44244. /**
  44245. * Returns the integer 1.
  44246. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44247. */
  44248. getTypeID(): number;
  44249. /**
  44250. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44251. * Returns the DirectionalLight Shadow projection matrix.
  44252. */
  44253. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44254. /**
  44255. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44256. * Returns the DirectionalLight Shadow projection matrix.
  44257. */
  44258. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44259. /**
  44260. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44261. * Returns the DirectionalLight Shadow projection matrix.
  44262. */
  44263. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44264. protected _buildUniformLayout(): void;
  44265. /**
  44266. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44267. * @param effect The effect to update
  44268. * @param lightIndex The index of the light in the effect to update
  44269. * @returns The directional light
  44270. */
  44271. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44272. /**
  44273. * Gets the minZ used for shadow according to both the scene and the light.
  44274. *
  44275. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44276. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44277. * @param activeCamera The camera we are returning the min for
  44278. * @returns the depth min z
  44279. */
  44280. getDepthMinZ(activeCamera: Camera): number;
  44281. /**
  44282. * Gets the maxZ used for shadow according to both the scene and the light.
  44283. *
  44284. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44285. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44286. * @param activeCamera The camera we are returning the max for
  44287. * @returns the depth max z
  44288. */
  44289. getDepthMaxZ(activeCamera: Camera): number;
  44290. /**
  44291. * Prepares the list of defines specific to the light type.
  44292. * @param defines the list of defines
  44293. * @param lightIndex defines the index of the light for the effect
  44294. */
  44295. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44296. }
  44297. }
  44298. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44299. import { Mesh } from "babylonjs/Meshes/mesh";
  44300. /**
  44301. * Class containing static functions to help procedurally build meshes
  44302. */
  44303. export class HemisphereBuilder {
  44304. /**
  44305. * Creates a hemisphere mesh
  44306. * @param name defines the name of the mesh
  44307. * @param options defines the options used to create the mesh
  44308. * @param scene defines the hosting scene
  44309. * @returns the hemisphere mesh
  44310. */
  44311. static CreateHemisphere(name: string, options: {
  44312. segments?: number;
  44313. diameter?: number;
  44314. sideOrientation?: number;
  44315. }, scene: any): Mesh;
  44316. }
  44317. }
  44318. declare module "babylonjs/Lights/spotLight" {
  44319. import { Nullable } from "babylonjs/types";
  44320. import { Scene } from "babylonjs/scene";
  44321. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44323. import { Effect } from "babylonjs/Materials/effect";
  44324. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44325. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44326. /**
  44327. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44328. * These values define a cone of light starting from the position, emitting toward the direction.
  44329. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44330. * and the exponent defines the speed of the decay of the light with distance (reach).
  44331. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44332. */
  44333. export class SpotLight extends ShadowLight {
  44334. private _angle;
  44335. private _innerAngle;
  44336. private _cosHalfAngle;
  44337. private _lightAngleScale;
  44338. private _lightAngleOffset;
  44339. /**
  44340. * Gets the cone angle of the spot light in Radians.
  44341. */
  44342. /**
  44343. * Sets the cone angle of the spot light in Radians.
  44344. */
  44345. angle: number;
  44346. /**
  44347. * Only used in gltf falloff mode, this defines the angle where
  44348. * the directional falloff will start before cutting at angle which could be seen
  44349. * as outer angle.
  44350. */
  44351. /**
  44352. * Only used in gltf falloff mode, this defines the angle where
  44353. * the directional falloff will start before cutting at angle which could be seen
  44354. * as outer angle.
  44355. */
  44356. innerAngle: number;
  44357. private _shadowAngleScale;
  44358. /**
  44359. * Allows scaling the angle of the light for shadow generation only.
  44360. */
  44361. /**
  44362. * Allows scaling the angle of the light for shadow generation only.
  44363. */
  44364. shadowAngleScale: number;
  44365. /**
  44366. * The light decay speed with the distance from the emission spot.
  44367. */
  44368. exponent: number;
  44369. private _projectionTextureMatrix;
  44370. /**
  44371. * Allows reading the projecton texture
  44372. */
  44373. readonly projectionTextureMatrix: Matrix;
  44374. protected _projectionTextureLightNear: number;
  44375. /**
  44376. * Gets the near clip of the Spotlight for texture projection.
  44377. */
  44378. /**
  44379. * Sets the near clip of the Spotlight for texture projection.
  44380. */
  44381. projectionTextureLightNear: number;
  44382. protected _projectionTextureLightFar: number;
  44383. /**
  44384. * Gets the far clip of the Spotlight for texture projection.
  44385. */
  44386. /**
  44387. * Sets the far clip of the Spotlight for texture projection.
  44388. */
  44389. projectionTextureLightFar: number;
  44390. protected _projectionTextureUpDirection: Vector3;
  44391. /**
  44392. * Gets the Up vector of the Spotlight for texture projection.
  44393. */
  44394. /**
  44395. * Sets the Up vector of the Spotlight for texture projection.
  44396. */
  44397. projectionTextureUpDirection: Vector3;
  44398. private _projectionTexture;
  44399. /**
  44400. * Gets the projection texture of the light.
  44401. */
  44402. /**
  44403. * Sets the projection texture of the light.
  44404. */
  44405. projectionTexture: Nullable<BaseTexture>;
  44406. private _projectionTextureViewLightDirty;
  44407. private _projectionTextureProjectionLightDirty;
  44408. private _projectionTextureDirty;
  44409. private _projectionTextureViewTargetVector;
  44410. private _projectionTextureViewLightMatrix;
  44411. private _projectionTextureProjectionLightMatrix;
  44412. private _projectionTextureScalingMatrix;
  44413. /**
  44414. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44415. * It can cast shadows.
  44416. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44417. * @param name The light friendly name
  44418. * @param position The position of the spot light in the scene
  44419. * @param direction The direction of the light in the scene
  44420. * @param angle The cone angle of the light in Radians
  44421. * @param exponent The light decay speed with the distance from the emission spot
  44422. * @param scene The scene the lights belongs to
  44423. */
  44424. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44425. /**
  44426. * Returns the string "SpotLight".
  44427. * @returns the class name
  44428. */
  44429. getClassName(): string;
  44430. /**
  44431. * Returns the integer 2.
  44432. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44433. */
  44434. getTypeID(): number;
  44435. /**
  44436. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44437. */
  44438. protected _setDirection(value: Vector3): void;
  44439. /**
  44440. * Overrides the position setter to recompute the projection texture view light Matrix.
  44441. */
  44442. protected _setPosition(value: Vector3): void;
  44443. /**
  44444. * 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.
  44445. * Returns the SpotLight.
  44446. */
  44447. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44448. protected _computeProjectionTextureViewLightMatrix(): void;
  44449. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44450. /**
  44451. * Main function for light texture projection matrix computing.
  44452. */
  44453. protected _computeProjectionTextureMatrix(): void;
  44454. protected _buildUniformLayout(): void;
  44455. private _computeAngleValues;
  44456. /**
  44457. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44458. * @param effect The effect to update
  44459. * @param lightIndex The index of the light in the effect to update
  44460. * @returns The spot light
  44461. */
  44462. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44463. /**
  44464. * Disposes the light and the associated resources.
  44465. */
  44466. dispose(): void;
  44467. /**
  44468. * Prepares the list of defines specific to the light type.
  44469. * @param defines the list of defines
  44470. * @param lightIndex defines the index of the light for the effect
  44471. */
  44472. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44473. }
  44474. }
  44475. declare module "babylonjs/Gizmos/lightGizmo" {
  44476. import { Nullable } from "babylonjs/types";
  44477. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44478. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44479. import { Light } from "babylonjs/Lights/light";
  44480. /**
  44481. * Gizmo that enables viewing a light
  44482. */
  44483. export class LightGizmo extends Gizmo {
  44484. private _lightMesh;
  44485. private _material;
  44486. /**
  44487. * Creates a LightGizmo
  44488. * @param gizmoLayer The utility layer the gizmo will be added to
  44489. */
  44490. constructor(gizmoLayer?: UtilityLayerRenderer);
  44491. private _light;
  44492. /**
  44493. * The light that the gizmo is attached to
  44494. */
  44495. light: Nullable<Light>;
  44496. /**
  44497. * @hidden
  44498. * Updates the gizmo to match the attached mesh's position/rotation
  44499. */
  44500. protected _update(): void;
  44501. private static _Scale;
  44502. /**
  44503. * Creates the lines for a light mesh
  44504. */
  44505. private static _createLightLines;
  44506. private static _CreateHemisphericLightMesh;
  44507. private static _CreatePointLightMesh;
  44508. private static _CreateSpotLightMesh;
  44509. private static _CreateDirectionalLightMesh;
  44510. }
  44511. }
  44512. declare module "babylonjs/Gizmos/index" {
  44513. export * from "babylonjs/Gizmos/axisDragGizmo";
  44514. export * from "babylonjs/Gizmos/axisScaleGizmo";
  44515. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  44516. export * from "babylonjs/Gizmos/gizmo";
  44517. export * from "babylonjs/Gizmos/gizmoManager";
  44518. export * from "babylonjs/Gizmos/planeRotationGizmo";
  44519. export * from "babylonjs/Gizmos/positionGizmo";
  44520. export * from "babylonjs/Gizmos/rotationGizmo";
  44521. export * from "babylonjs/Gizmos/scaleGizmo";
  44522. export * from "babylonjs/Gizmos/lightGizmo";
  44523. }
  44524. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  44525. /** @hidden */
  44526. export var backgroundFragmentDeclaration: {
  44527. name: string;
  44528. shader: string;
  44529. };
  44530. }
  44531. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  44532. /** @hidden */
  44533. export var backgroundUboDeclaration: {
  44534. name: string;
  44535. shader: string;
  44536. };
  44537. }
  44538. declare module "babylonjs/Shaders/background.fragment" {
  44539. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  44540. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44541. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44542. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44543. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44544. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44545. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44546. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  44547. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44548. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44549. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44550. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44551. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44552. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44553. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44554. /** @hidden */
  44555. export var backgroundPixelShader: {
  44556. name: string;
  44557. shader: string;
  44558. };
  44559. }
  44560. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  44561. /** @hidden */
  44562. export var backgroundVertexDeclaration: {
  44563. name: string;
  44564. shader: string;
  44565. };
  44566. }
  44567. declare module "babylonjs/Shaders/background.vertex" {
  44568. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  44569. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44570. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44571. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44572. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44573. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44574. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44575. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44576. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44577. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44578. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44579. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44580. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44581. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44582. /** @hidden */
  44583. export var backgroundVertexShader: {
  44584. name: string;
  44585. shader: string;
  44586. };
  44587. }
  44588. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  44589. import { Nullable, int, float } from "babylonjs/types";
  44590. import { Scene } from "babylonjs/scene";
  44591. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  44592. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44594. import { Mesh } from "babylonjs/Meshes/mesh";
  44595. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44596. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44597. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44598. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44599. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  44600. import "babylonjs/Shaders/background.fragment";
  44601. import "babylonjs/Shaders/background.vertex";
  44602. /**
  44603. * Background material used to create an efficient environement around your scene.
  44604. */
  44605. export class BackgroundMaterial extends PushMaterial {
  44606. /**
  44607. * Standard reflectance value at parallel view angle.
  44608. */
  44609. static StandardReflectance0: number;
  44610. /**
  44611. * Standard reflectance value at grazing angle.
  44612. */
  44613. static StandardReflectance90: number;
  44614. protected _primaryColor: Color3;
  44615. /**
  44616. * Key light Color (multiply against the environement texture)
  44617. */
  44618. primaryColor: Color3;
  44619. protected __perceptualColor: Nullable<Color3>;
  44620. /**
  44621. * Experimental Internal Use Only.
  44622. *
  44623. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44624. * This acts as a helper to set the primary color to a more "human friendly" value.
  44625. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44626. * output color as close as possible from the chosen value.
  44627. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44628. * part of lighting setup.)
  44629. */
  44630. _perceptualColor: Nullable<Color3>;
  44631. protected _primaryColorShadowLevel: float;
  44632. /**
  44633. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44634. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44635. */
  44636. primaryColorShadowLevel: float;
  44637. protected _primaryColorHighlightLevel: float;
  44638. /**
  44639. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44640. * The primary color is used at the level chosen to define what the white area would look.
  44641. */
  44642. primaryColorHighlightLevel: float;
  44643. protected _reflectionTexture: Nullable<BaseTexture>;
  44644. /**
  44645. * Reflection Texture used in the material.
  44646. * Should be author in a specific way for the best result (refer to the documentation).
  44647. */
  44648. reflectionTexture: Nullable<BaseTexture>;
  44649. protected _reflectionBlur: float;
  44650. /**
  44651. * Reflection Texture level of blur.
  44652. *
  44653. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44654. * texture twice.
  44655. */
  44656. reflectionBlur: float;
  44657. protected _diffuseTexture: Nullable<BaseTexture>;
  44658. /**
  44659. * Diffuse Texture used in the material.
  44660. * Should be author in a specific way for the best result (refer to the documentation).
  44661. */
  44662. diffuseTexture: Nullable<BaseTexture>;
  44663. protected _shadowLights: Nullable<IShadowLight[]>;
  44664. /**
  44665. * Specify the list of lights casting shadow on the material.
  44666. * All scene shadow lights will be included if null.
  44667. */
  44668. shadowLights: Nullable<IShadowLight[]>;
  44669. protected _shadowLevel: float;
  44670. /**
  44671. * Helps adjusting the shadow to a softer level if required.
  44672. * 0 means black shadows and 1 means no shadows.
  44673. */
  44674. shadowLevel: float;
  44675. protected _sceneCenter: Vector3;
  44676. /**
  44677. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44678. * It is usually zero but might be interesting to modify according to your setup.
  44679. */
  44680. sceneCenter: Vector3;
  44681. protected _opacityFresnel: boolean;
  44682. /**
  44683. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44684. * This helps ensuring a nice transition when the camera goes under the ground.
  44685. */
  44686. opacityFresnel: boolean;
  44687. protected _reflectionFresnel: boolean;
  44688. /**
  44689. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44690. * This helps adding a mirror texture on the ground.
  44691. */
  44692. reflectionFresnel: boolean;
  44693. protected _reflectionFalloffDistance: number;
  44694. /**
  44695. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44696. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44697. */
  44698. reflectionFalloffDistance: number;
  44699. protected _reflectionAmount: number;
  44700. /**
  44701. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44702. */
  44703. reflectionAmount: number;
  44704. protected _reflectionReflectance0: number;
  44705. /**
  44706. * This specifies the weight of the reflection at grazing angle.
  44707. */
  44708. reflectionReflectance0: number;
  44709. protected _reflectionReflectance90: number;
  44710. /**
  44711. * This specifies the weight of the reflection at a perpendicular point of view.
  44712. */
  44713. reflectionReflectance90: number;
  44714. /**
  44715. * Sets the reflection reflectance fresnel values according to the default standard
  44716. * empirically know to work well :-)
  44717. */
  44718. reflectionStandardFresnelWeight: number;
  44719. protected _useRGBColor: boolean;
  44720. /**
  44721. * Helps to directly use the maps channels instead of their level.
  44722. */
  44723. useRGBColor: boolean;
  44724. protected _enableNoise: boolean;
  44725. /**
  44726. * This helps reducing the banding effect that could occur on the background.
  44727. */
  44728. enableNoise: boolean;
  44729. /**
  44730. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44731. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44732. * Recommended to be keep at 1.0 except for special cases.
  44733. */
  44734. fovMultiplier: number;
  44735. private _fovMultiplier;
  44736. /**
  44737. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44738. */
  44739. useEquirectangularFOV: boolean;
  44740. private _maxSimultaneousLights;
  44741. /**
  44742. * Number of Simultaneous lights allowed on the material.
  44743. */
  44744. maxSimultaneousLights: int;
  44745. /**
  44746. * Default configuration related to image processing available in the Background Material.
  44747. */
  44748. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44749. /**
  44750. * Keep track of the image processing observer to allow dispose and replace.
  44751. */
  44752. private _imageProcessingObserver;
  44753. /**
  44754. * Attaches a new image processing configuration to the PBR Material.
  44755. * @param configuration (if null the scene configuration will be use)
  44756. */
  44757. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44758. /**
  44759. * Gets the image processing configuration used either in this material.
  44760. */
  44761. /**
  44762. * Sets the Default image processing configuration used either in the this material.
  44763. *
  44764. * If sets to null, the scene one is in use.
  44765. */
  44766. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44767. /**
  44768. * Gets wether the color curves effect is enabled.
  44769. */
  44770. /**
  44771. * Sets wether the color curves effect is enabled.
  44772. */
  44773. cameraColorCurvesEnabled: boolean;
  44774. /**
  44775. * Gets wether the color grading effect is enabled.
  44776. */
  44777. /**
  44778. * Gets wether the color grading effect is enabled.
  44779. */
  44780. cameraColorGradingEnabled: boolean;
  44781. /**
  44782. * Gets wether tonemapping is enabled or not.
  44783. */
  44784. /**
  44785. * Sets wether tonemapping is enabled or not
  44786. */
  44787. cameraToneMappingEnabled: boolean;
  44788. /**
  44789. * The camera exposure used on this material.
  44790. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44791. * This corresponds to a photographic exposure.
  44792. */
  44793. /**
  44794. * The camera exposure used on this material.
  44795. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44796. * This corresponds to a photographic exposure.
  44797. */
  44798. cameraExposure: float;
  44799. /**
  44800. * Gets The camera contrast used on this material.
  44801. */
  44802. /**
  44803. * Sets The camera contrast used on this material.
  44804. */
  44805. cameraContrast: float;
  44806. /**
  44807. * Gets the Color Grading 2D Lookup Texture.
  44808. */
  44809. /**
  44810. * Sets the Color Grading 2D Lookup Texture.
  44811. */
  44812. cameraColorGradingTexture: Nullable<BaseTexture>;
  44813. /**
  44814. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44815. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44816. * 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;
  44817. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44818. */
  44819. /**
  44820. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44821. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44822. * 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;
  44823. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44824. */
  44825. cameraColorCurves: Nullable<ColorCurves>;
  44826. /**
  44827. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44828. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44829. */
  44830. switchToBGR: boolean;
  44831. private _renderTargets;
  44832. private _reflectionControls;
  44833. private _white;
  44834. private _primaryShadowColor;
  44835. private _primaryHighlightColor;
  44836. /**
  44837. * Instantiates a Background Material in the given scene
  44838. * @param name The friendly name of the material
  44839. * @param scene The scene to add the material to
  44840. */
  44841. constructor(name: string, scene: Scene);
  44842. /**
  44843. * Gets a boolean indicating that current material needs to register RTT
  44844. */
  44845. readonly hasRenderTargetTextures: boolean;
  44846. /**
  44847. * The entire material has been created in order to prevent overdraw.
  44848. * @returns false
  44849. */
  44850. needAlphaTesting(): boolean;
  44851. /**
  44852. * The entire material has been created in order to prevent overdraw.
  44853. * @returns true if blending is enable
  44854. */
  44855. needAlphaBlending(): boolean;
  44856. /**
  44857. * Checks wether the material is ready to be rendered for a given mesh.
  44858. * @param mesh The mesh to render
  44859. * @param subMesh The submesh to check against
  44860. * @param useInstances Specify wether or not the material is used with instances
  44861. * @returns true if all the dependencies are ready (Textures, Effects...)
  44862. */
  44863. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44864. /**
  44865. * Compute the primary color according to the chosen perceptual color.
  44866. */
  44867. private _computePrimaryColorFromPerceptualColor;
  44868. /**
  44869. * Compute the highlights and shadow colors according to their chosen levels.
  44870. */
  44871. private _computePrimaryColors;
  44872. /**
  44873. * Build the uniform buffer used in the material.
  44874. */
  44875. buildUniformLayout(): void;
  44876. /**
  44877. * Unbind the material.
  44878. */
  44879. unbind(): void;
  44880. /**
  44881. * Bind only the world matrix to the material.
  44882. * @param world The world matrix to bind.
  44883. */
  44884. bindOnlyWorldMatrix(world: Matrix): void;
  44885. /**
  44886. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44887. * @param world The world matrix to bind.
  44888. * @param subMesh The submesh to bind for.
  44889. */
  44890. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44891. /**
  44892. * Dispose the material.
  44893. * @param forceDisposeEffect Force disposal of the associated effect.
  44894. * @param forceDisposeTextures Force disposal of the associated textures.
  44895. */
  44896. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44897. /**
  44898. * Clones the material.
  44899. * @param name The cloned name.
  44900. * @returns The cloned material.
  44901. */
  44902. clone(name: string): BackgroundMaterial;
  44903. /**
  44904. * Serializes the current material to its JSON representation.
  44905. * @returns The JSON representation.
  44906. */
  44907. serialize(): any;
  44908. /**
  44909. * Gets the class name of the material
  44910. * @returns "BackgroundMaterial"
  44911. */
  44912. getClassName(): string;
  44913. /**
  44914. * Parse a JSON input to create back a background material.
  44915. * @param source The JSON data to parse
  44916. * @param scene The scene to create the parsed material in
  44917. * @param rootUrl The root url of the assets the material depends upon
  44918. * @returns the instantiated BackgroundMaterial.
  44919. */
  44920. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44921. }
  44922. }
  44923. declare module "babylonjs/Helpers/environmentHelper" {
  44924. import { Observable } from "babylonjs/Misc/observable";
  44925. import { Nullable } from "babylonjs/types";
  44926. import { Scene } from "babylonjs/scene";
  44927. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44929. import { Mesh } from "babylonjs/Meshes/mesh";
  44930. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44931. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  44932. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44933. import "babylonjs/Meshes/Builders/planeBuilder";
  44934. import "babylonjs/Meshes/Builders/boxBuilder";
  44935. /**
  44936. * Represents the different options available during the creation of
  44937. * a Environment helper.
  44938. *
  44939. * This can control the default ground, skybox and image processing setup of your scene.
  44940. */
  44941. export interface IEnvironmentHelperOptions {
  44942. /**
  44943. * Specifies wether or not to create a ground.
  44944. * True by default.
  44945. */
  44946. createGround: boolean;
  44947. /**
  44948. * Specifies the ground size.
  44949. * 15 by default.
  44950. */
  44951. groundSize: number;
  44952. /**
  44953. * The texture used on the ground for the main color.
  44954. * Comes from the BabylonJS CDN by default.
  44955. *
  44956. * Remarks: Can be either a texture or a url.
  44957. */
  44958. groundTexture: string | BaseTexture;
  44959. /**
  44960. * The color mixed in the ground texture by default.
  44961. * BabylonJS clearColor by default.
  44962. */
  44963. groundColor: Color3;
  44964. /**
  44965. * Specifies the ground opacity.
  44966. * 1 by default.
  44967. */
  44968. groundOpacity: number;
  44969. /**
  44970. * Enables the ground to receive shadows.
  44971. * True by default.
  44972. */
  44973. enableGroundShadow: boolean;
  44974. /**
  44975. * Helps preventing the shadow to be fully black on the ground.
  44976. * 0.5 by default.
  44977. */
  44978. groundShadowLevel: number;
  44979. /**
  44980. * Creates a mirror texture attach to the ground.
  44981. * false by default.
  44982. */
  44983. enableGroundMirror: boolean;
  44984. /**
  44985. * Specifies the ground mirror size ratio.
  44986. * 0.3 by default as the default kernel is 64.
  44987. */
  44988. groundMirrorSizeRatio: number;
  44989. /**
  44990. * Specifies the ground mirror blur kernel size.
  44991. * 64 by default.
  44992. */
  44993. groundMirrorBlurKernel: number;
  44994. /**
  44995. * Specifies the ground mirror visibility amount.
  44996. * 1 by default
  44997. */
  44998. groundMirrorAmount: number;
  44999. /**
  45000. * Specifies the ground mirror reflectance weight.
  45001. * This uses the standard weight of the background material to setup the fresnel effect
  45002. * of the mirror.
  45003. * 1 by default.
  45004. */
  45005. groundMirrorFresnelWeight: number;
  45006. /**
  45007. * Specifies the ground mirror Falloff distance.
  45008. * This can helps reducing the size of the reflection.
  45009. * 0 by Default.
  45010. */
  45011. groundMirrorFallOffDistance: number;
  45012. /**
  45013. * Specifies the ground mirror texture type.
  45014. * Unsigned Int by Default.
  45015. */
  45016. groundMirrorTextureType: number;
  45017. /**
  45018. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45019. * the shown objects.
  45020. */
  45021. groundYBias: number;
  45022. /**
  45023. * Specifies wether or not to create a skybox.
  45024. * True by default.
  45025. */
  45026. createSkybox: boolean;
  45027. /**
  45028. * Specifies the skybox size.
  45029. * 20 by default.
  45030. */
  45031. skyboxSize: number;
  45032. /**
  45033. * The texture used on the skybox for the main color.
  45034. * Comes from the BabylonJS CDN by default.
  45035. *
  45036. * Remarks: Can be either a texture or a url.
  45037. */
  45038. skyboxTexture: string | BaseTexture;
  45039. /**
  45040. * The color mixed in the skybox texture by default.
  45041. * BabylonJS clearColor by default.
  45042. */
  45043. skyboxColor: Color3;
  45044. /**
  45045. * The background rotation around the Y axis of the scene.
  45046. * This helps aligning the key lights of your scene with the background.
  45047. * 0 by default.
  45048. */
  45049. backgroundYRotation: number;
  45050. /**
  45051. * Compute automatically the size of the elements to best fit with the scene.
  45052. */
  45053. sizeAuto: boolean;
  45054. /**
  45055. * Default position of the rootMesh if autoSize is not true.
  45056. */
  45057. rootPosition: Vector3;
  45058. /**
  45059. * Sets up the image processing in the scene.
  45060. * true by default.
  45061. */
  45062. setupImageProcessing: boolean;
  45063. /**
  45064. * The texture used as your environment texture in the scene.
  45065. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45066. *
  45067. * Remarks: Can be either a texture or a url.
  45068. */
  45069. environmentTexture: string | BaseTexture;
  45070. /**
  45071. * The value of the exposure to apply to the scene.
  45072. * 0.6 by default if setupImageProcessing is true.
  45073. */
  45074. cameraExposure: number;
  45075. /**
  45076. * The value of the contrast to apply to the scene.
  45077. * 1.6 by default if setupImageProcessing is true.
  45078. */
  45079. cameraContrast: number;
  45080. /**
  45081. * Specifies wether or not tonemapping should be enabled in the scene.
  45082. * true by default if setupImageProcessing is true.
  45083. */
  45084. toneMappingEnabled: boolean;
  45085. }
  45086. /**
  45087. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45088. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45089. * It also helps with the default setup of your imageProcessing configuration.
  45090. */
  45091. export class EnvironmentHelper {
  45092. /**
  45093. * Default ground texture URL.
  45094. */
  45095. private static _groundTextureCDNUrl;
  45096. /**
  45097. * Default skybox texture URL.
  45098. */
  45099. private static _skyboxTextureCDNUrl;
  45100. /**
  45101. * Default environment texture URL.
  45102. */
  45103. private static _environmentTextureCDNUrl;
  45104. /**
  45105. * Creates the default options for the helper.
  45106. */
  45107. private static _getDefaultOptions;
  45108. private _rootMesh;
  45109. /**
  45110. * Gets the root mesh created by the helper.
  45111. */
  45112. readonly rootMesh: Mesh;
  45113. private _skybox;
  45114. /**
  45115. * Gets the skybox created by the helper.
  45116. */
  45117. readonly skybox: Nullable<Mesh>;
  45118. private _skyboxTexture;
  45119. /**
  45120. * Gets the skybox texture created by the helper.
  45121. */
  45122. readonly skyboxTexture: Nullable<BaseTexture>;
  45123. private _skyboxMaterial;
  45124. /**
  45125. * Gets the skybox material created by the helper.
  45126. */
  45127. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45128. private _ground;
  45129. /**
  45130. * Gets the ground mesh created by the helper.
  45131. */
  45132. readonly ground: Nullable<Mesh>;
  45133. private _groundTexture;
  45134. /**
  45135. * Gets the ground texture created by the helper.
  45136. */
  45137. readonly groundTexture: Nullable<BaseTexture>;
  45138. private _groundMirror;
  45139. /**
  45140. * Gets the ground mirror created by the helper.
  45141. */
  45142. readonly groundMirror: Nullable<MirrorTexture>;
  45143. /**
  45144. * Gets the ground mirror render list to helps pushing the meshes
  45145. * you wish in the ground reflection.
  45146. */
  45147. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45148. private _groundMaterial;
  45149. /**
  45150. * Gets the ground material created by the helper.
  45151. */
  45152. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45153. /**
  45154. * Stores the creation options.
  45155. */
  45156. private readonly _scene;
  45157. private _options;
  45158. /**
  45159. * This observable will be notified with any error during the creation of the environment,
  45160. * mainly texture creation errors.
  45161. */
  45162. onErrorObservable: Observable<{
  45163. message?: string;
  45164. exception?: any;
  45165. }>;
  45166. /**
  45167. * constructor
  45168. * @param options Defines the options we want to customize the helper
  45169. * @param scene The scene to add the material to
  45170. */
  45171. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45172. /**
  45173. * Updates the background according to the new options
  45174. * @param options
  45175. */
  45176. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45177. /**
  45178. * Sets the primary color of all the available elements.
  45179. * @param color the main color to affect to the ground and the background
  45180. */
  45181. setMainColor(color: Color3): void;
  45182. /**
  45183. * Setup the image processing according to the specified options.
  45184. */
  45185. private _setupImageProcessing;
  45186. /**
  45187. * Setup the environment texture according to the specified options.
  45188. */
  45189. private _setupEnvironmentTexture;
  45190. /**
  45191. * Setup the background according to the specified options.
  45192. */
  45193. private _setupBackground;
  45194. /**
  45195. * Get the scene sizes according to the setup.
  45196. */
  45197. private _getSceneSize;
  45198. /**
  45199. * Setup the ground according to the specified options.
  45200. */
  45201. private _setupGround;
  45202. /**
  45203. * Setup the ground material according to the specified options.
  45204. */
  45205. private _setupGroundMaterial;
  45206. /**
  45207. * Setup the ground diffuse texture according to the specified options.
  45208. */
  45209. private _setupGroundDiffuseTexture;
  45210. /**
  45211. * Setup the ground mirror texture according to the specified options.
  45212. */
  45213. private _setupGroundMirrorTexture;
  45214. /**
  45215. * Setup the ground to receive the mirror texture.
  45216. */
  45217. private _setupMirrorInGroundMaterial;
  45218. /**
  45219. * Setup the skybox according to the specified options.
  45220. */
  45221. private _setupSkybox;
  45222. /**
  45223. * Setup the skybox material according to the specified options.
  45224. */
  45225. private _setupSkyboxMaterial;
  45226. /**
  45227. * Setup the skybox reflection texture according to the specified options.
  45228. */
  45229. private _setupSkyboxReflectionTexture;
  45230. private _errorHandler;
  45231. /**
  45232. * Dispose all the elements created by the Helper.
  45233. */
  45234. dispose(): void;
  45235. }
  45236. }
  45237. declare module "babylonjs/Helpers/photoDome" {
  45238. import { Observable } from "babylonjs/Misc/observable";
  45239. import { Nullable } from "babylonjs/types";
  45240. import { Scene } from "babylonjs/scene";
  45241. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45242. import { Mesh } from "babylonjs/Meshes/mesh";
  45243. import { Texture } from "babylonjs/Materials/Textures/texture";
  45244. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45245. import "babylonjs/Meshes/Builders/sphereBuilder";
  45246. /**
  45247. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45248. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45249. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45250. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45251. */
  45252. export class PhotoDome extends TransformNode {
  45253. private _useDirectMapping;
  45254. /**
  45255. * The texture being displayed on the sphere
  45256. */
  45257. protected _photoTexture: Texture;
  45258. /**
  45259. * Gets or sets the texture being displayed on the sphere
  45260. */
  45261. photoTexture: Texture;
  45262. /**
  45263. * Observable raised when an error occured while loading the 360 image
  45264. */
  45265. onLoadErrorObservable: Observable<string>;
  45266. /**
  45267. * The skybox material
  45268. */
  45269. protected _material: BackgroundMaterial;
  45270. /**
  45271. * The surface used for the skybox
  45272. */
  45273. protected _mesh: Mesh;
  45274. /**
  45275. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45276. * Also see the options.resolution property.
  45277. */
  45278. fovMultiplier: number;
  45279. /**
  45280. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45281. * @param name Element's name, child elements will append suffixes for their own names.
  45282. * @param urlsOfPhoto defines the url of the photo to display
  45283. * @param options defines an object containing optional or exposed sub element properties
  45284. * @param onError defines a callback called when an error occured while loading the texture
  45285. */
  45286. constructor(name: string, urlOfPhoto: string, options: {
  45287. resolution?: number;
  45288. size?: number;
  45289. useDirectMapping?: boolean;
  45290. faceForward?: boolean;
  45291. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45292. /**
  45293. * Releases resources associated with this node.
  45294. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45295. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45296. */
  45297. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45298. }
  45299. }
  45300. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45301. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45302. /** @hidden */
  45303. export var rgbdDecodePixelShader: {
  45304. name: string;
  45305. shader: string;
  45306. };
  45307. }
  45308. declare module "babylonjs/Misc/brdfTextureTools" {
  45309. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45310. import { Scene } from "babylonjs/scene";
  45311. import "babylonjs/Shaders/rgbdDecode.fragment";
  45312. /**
  45313. * Class used to host texture specific utilities
  45314. */
  45315. export class BRDFTextureTools {
  45316. /**
  45317. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45318. * @param texture the texture to expand.
  45319. */
  45320. private static _ExpandDefaultBRDFTexture;
  45321. /**
  45322. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45323. * @param scene defines the hosting scene
  45324. * @returns the environment BRDF texture
  45325. */
  45326. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45327. private static _environmentBRDFBase64Texture;
  45328. }
  45329. }
  45330. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45331. import { Nullable } from "babylonjs/types";
  45332. import { IAnimatable } from "babylonjs/Misc/tools";
  45333. import { Color3 } from "babylonjs/Maths/math";
  45334. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45335. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45336. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45337. import { Engine } from "babylonjs/Engines/engine";
  45338. import { Scene } from "babylonjs/scene";
  45339. /**
  45340. * @hidden
  45341. */
  45342. export interface IMaterialClearCoatDefines {
  45343. CLEARCOAT: boolean;
  45344. CLEARCOAT_DEFAULTIOR: boolean;
  45345. CLEARCOAT_TEXTURE: boolean;
  45346. CLEARCOAT_TEXTUREDIRECTUV: number;
  45347. CLEARCOAT_BUMP: boolean;
  45348. CLEARCOAT_BUMPDIRECTUV: number;
  45349. CLEARCOAT_TINT: boolean;
  45350. CLEARCOAT_TINT_TEXTURE: boolean;
  45351. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45352. /** @hidden */
  45353. _areTexturesDirty: boolean;
  45354. }
  45355. /**
  45356. * Define the code related to the clear coat parameters of the pbr material.
  45357. */
  45358. export class PBRClearCoatConfiguration {
  45359. /**
  45360. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45361. * The default fits with a polyurethane material.
  45362. */
  45363. private static readonly _DefaultIndiceOfRefraction;
  45364. private _isEnabled;
  45365. /**
  45366. * Defines if the clear coat is enabled in the material.
  45367. */
  45368. isEnabled: boolean;
  45369. /**
  45370. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45371. */
  45372. intensity: number;
  45373. /**
  45374. * Defines the clear coat layer roughness.
  45375. */
  45376. roughness: number;
  45377. private _indiceOfRefraction;
  45378. /**
  45379. * Defines the indice of refraction of the clear coat.
  45380. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45381. * The default fits with a polyurethane material.
  45382. * Changing the default value is more performance intensive.
  45383. */
  45384. indiceOfRefraction: number;
  45385. private _texture;
  45386. /**
  45387. * Stores the clear coat values in a texture.
  45388. */
  45389. texture: Nullable<BaseTexture>;
  45390. private _bumpTexture;
  45391. /**
  45392. * Define the clear coat specific bump texture.
  45393. */
  45394. bumpTexture: Nullable<BaseTexture>;
  45395. private _isTintEnabled;
  45396. /**
  45397. * Defines if the clear coat tint is enabled in the material.
  45398. */
  45399. isTintEnabled: boolean;
  45400. /**
  45401. * Defines the clear coat tint of the material.
  45402. * This is only use if tint is enabled
  45403. */
  45404. tintColor: Color3;
  45405. /**
  45406. * Defines the distance at which the tint color should be found in the
  45407. * clear coat media.
  45408. * This is only use if tint is enabled
  45409. */
  45410. tintColorAtDistance: number;
  45411. /**
  45412. * Defines the clear coat layer thickness.
  45413. * This is only use if tint is enabled
  45414. */
  45415. tintThickness: number;
  45416. private _tintTexture;
  45417. /**
  45418. * Stores the clear tint values in a texture.
  45419. * rgb is tint
  45420. * a is a thickness factor
  45421. */
  45422. tintTexture: Nullable<BaseTexture>;
  45423. /** @hidden */
  45424. private _internalMarkAllSubMeshesAsTexturesDirty;
  45425. /** @hidden */
  45426. _markAllSubMeshesAsTexturesDirty(): void;
  45427. /**
  45428. * Instantiate a new istance of clear coat configuration.
  45429. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45430. */
  45431. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45432. /**
  45433. * Gets wehter the submesh is ready to be used or not.
  45434. * @param defines the list of "defines" to update.
  45435. * @param scene defines the scene the material belongs to.
  45436. * @param engine defines the engine the material belongs to.
  45437. * @param disableBumpMap defines wether the material disables bump or not.
  45438. * @returns - boolean indicating that the submesh is ready or not.
  45439. */
  45440. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45441. /**
  45442. * Checks to see if a texture is used in the material.
  45443. * @param defines the list of "defines" to update.
  45444. * @param scene defines the scene to the material belongs to.
  45445. */
  45446. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45447. /**
  45448. * Binds the material data.
  45449. * @param uniformBuffer defines the Uniform buffer to fill in.
  45450. * @param scene defines the scene the material belongs to.
  45451. * @param engine defines the engine the material belongs to.
  45452. * @param disableBumpMap defines wether the material disables bump or not.
  45453. * @param isFrozen defines wether the material is frozen or not.
  45454. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45455. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45456. */
  45457. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45458. /**
  45459. * Checks to see if a texture is used in the material.
  45460. * @param texture - Base texture to use.
  45461. * @returns - Boolean specifying if a texture is used in the material.
  45462. */
  45463. hasTexture(texture: BaseTexture): boolean;
  45464. /**
  45465. * Returns an array of the actively used textures.
  45466. * @param activeTextures Array of BaseTextures
  45467. */
  45468. getActiveTextures(activeTextures: BaseTexture[]): void;
  45469. /**
  45470. * Returns the animatable textures.
  45471. * @param animatables Array of animatable textures.
  45472. */
  45473. getAnimatables(animatables: IAnimatable[]): void;
  45474. /**
  45475. * Disposes the resources of the material.
  45476. * @param forceDisposeTextures - Forces the disposal of all textures.
  45477. */
  45478. dispose(forceDisposeTextures?: boolean): void;
  45479. /**
  45480. * Get the current class name of the texture useful for serialization or dynamic coding.
  45481. * @returns "PBRClearCoatConfiguration"
  45482. */
  45483. getClassName(): string;
  45484. /**
  45485. * Add fallbacks to the effect fallbacks list.
  45486. * @param defines defines the Base texture to use.
  45487. * @param fallbacks defines the current fallback list.
  45488. * @param currentRank defines the current fallback rank.
  45489. * @returns the new fallback rank.
  45490. */
  45491. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45492. /**
  45493. * Add the required uniforms to the current list.
  45494. * @param uniforms defines the current uniform list.
  45495. */
  45496. static AddUniforms(uniforms: string[]): void;
  45497. /**
  45498. * Add the required samplers to the current list.
  45499. * @param samplers defines the current sampler list.
  45500. */
  45501. static AddSamplers(samplers: string[]): void;
  45502. /**
  45503. * Add the required uniforms to the current buffer.
  45504. * @param uniformBuffer defines the current uniform buffer.
  45505. */
  45506. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45507. /**
  45508. * Makes a duplicate of the current configuration into another one.
  45509. * @param clearCoatConfiguration define the config where to copy the info
  45510. */
  45511. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45512. /**
  45513. * Serializes this clear coat configuration.
  45514. * @returns - An object with the serialized config.
  45515. */
  45516. serialize(): any;
  45517. /**
  45518. * Parses a Clear Coat Configuration from a serialized object.
  45519. * @param source - Serialized object.
  45520. */
  45521. parse(source: any): void;
  45522. }
  45523. }
  45524. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  45525. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45526. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45528. import { Vector2 } from "babylonjs/Maths/math";
  45529. import { Scene } from "babylonjs/scene";
  45530. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45531. import { IAnimatable } from "babylonjs/Misc/tools";
  45532. import { Nullable } from "babylonjs/types";
  45533. /**
  45534. * @hidden
  45535. */
  45536. export interface IMaterialAnisotropicDefines {
  45537. ANISOTROPIC: boolean;
  45538. ANISOTROPIC_TEXTURE: boolean;
  45539. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45540. MAINUV1: boolean;
  45541. _areTexturesDirty: boolean;
  45542. _needUVs: boolean;
  45543. }
  45544. /**
  45545. * Define the code related to the anisotropic parameters of the pbr material.
  45546. */
  45547. export class PBRAnisotropicConfiguration {
  45548. private _isEnabled;
  45549. /**
  45550. * Defines if the anisotropy is enabled in the material.
  45551. */
  45552. isEnabled: boolean;
  45553. /**
  45554. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45555. */
  45556. intensity: number;
  45557. /**
  45558. * Defines if the effect is along the tangents, bitangents or in between.
  45559. * By default, the effect is "strectching" the highlights along the tangents.
  45560. */
  45561. direction: Vector2;
  45562. private _texture;
  45563. /**
  45564. * Stores the anisotropy values in a texture.
  45565. * rg is direction (like normal from -1 to 1)
  45566. * b is a intensity
  45567. */
  45568. texture: Nullable<BaseTexture>;
  45569. /** @hidden */
  45570. private _internalMarkAllSubMeshesAsTexturesDirty;
  45571. /** @hidden */
  45572. _markAllSubMeshesAsTexturesDirty(): void;
  45573. /**
  45574. * Instantiate a new istance of anisotropy configuration.
  45575. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45576. */
  45577. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45578. /**
  45579. * Specifies that the submesh is ready to be used.
  45580. * @param defines the list of "defines" to update.
  45581. * @param scene defines the scene the material belongs to.
  45582. * @returns - boolean indicating that the submesh is ready or not.
  45583. */
  45584. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45585. /**
  45586. * Checks to see if a texture is used in the material.
  45587. * @param defines the list of "defines" to update.
  45588. * @param mesh the mesh we are preparing the defines for.
  45589. * @param scene defines the scene the material belongs to.
  45590. */
  45591. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45592. /**
  45593. * Binds the material data.
  45594. * @param uniformBuffer defines the Uniform buffer to fill in.
  45595. * @param scene defines the scene the material belongs to.
  45596. * @param isFrozen defines wether the material is frozen or not.
  45597. */
  45598. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45599. /**
  45600. * Checks to see if a texture is used in the material.
  45601. * @param texture - Base texture to use.
  45602. * @returns - Boolean specifying if a texture is used in the material.
  45603. */
  45604. hasTexture(texture: BaseTexture): boolean;
  45605. /**
  45606. * Returns an array of the actively used textures.
  45607. * @param activeTextures Array of BaseTextures
  45608. */
  45609. getActiveTextures(activeTextures: BaseTexture[]): void;
  45610. /**
  45611. * Returns the animatable textures.
  45612. * @param animatables Array of animatable textures.
  45613. */
  45614. getAnimatables(animatables: IAnimatable[]): void;
  45615. /**
  45616. * Disposes the resources of the material.
  45617. * @param forceDisposeTextures - Forces the disposal of all textures.
  45618. */
  45619. dispose(forceDisposeTextures?: boolean): void;
  45620. /**
  45621. * Get the current class name of the texture useful for serialization or dynamic coding.
  45622. * @returns "PBRAnisotropicConfiguration"
  45623. */
  45624. getClassName(): string;
  45625. /**
  45626. * Add fallbacks to the effect fallbacks list.
  45627. * @param defines defines the Base texture to use.
  45628. * @param fallbacks defines the current fallback list.
  45629. * @param currentRank defines the current fallback rank.
  45630. * @returns the new fallback rank.
  45631. */
  45632. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45633. /**
  45634. * Add the required uniforms to the current list.
  45635. * @param uniforms defines the current uniform list.
  45636. */
  45637. static AddUniforms(uniforms: string[]): void;
  45638. /**
  45639. * Add the required uniforms to the current buffer.
  45640. * @param uniformBuffer defines the current uniform buffer.
  45641. */
  45642. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45643. /**
  45644. * Add the required samplers to the current list.
  45645. * @param samplers defines the current sampler list.
  45646. */
  45647. static AddSamplers(samplers: string[]): void;
  45648. /**
  45649. * Makes a duplicate of the current configuration into another one.
  45650. * @param anisotropicConfiguration define the config where to copy the info
  45651. */
  45652. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45653. /**
  45654. * Serializes this anisotropy configuration.
  45655. * @returns - An object with the serialized config.
  45656. */
  45657. serialize(): any;
  45658. /**
  45659. * Parses a anisotropy Configuration from a serialized object.
  45660. * @param source - Serialized object.
  45661. */
  45662. parse(source: any): void;
  45663. }
  45664. }
  45665. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  45666. /**
  45667. * @hidden
  45668. */
  45669. export interface IMaterialBRDFDefines {
  45670. BRDF_V_HEIGHT_CORRELATED: boolean;
  45671. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45672. /** @hidden */
  45673. _areMiscDirty: boolean;
  45674. }
  45675. /**
  45676. * Define the code related to the BRDF parameters of the pbr material.
  45677. */
  45678. export class PBRBRDFConfiguration {
  45679. /**
  45680. * Default value used for the energy conservation.
  45681. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45682. */
  45683. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45684. /**
  45685. * Default value used for the Smith Visibility Height Correlated mode.
  45686. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45687. */
  45688. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45689. private _useEnergyConservation;
  45690. /**
  45691. * Defines if the material uses energy conservation.
  45692. */
  45693. useEnergyConservation: boolean;
  45694. private _useSmithVisibilityHeightCorrelated;
  45695. /**
  45696. * LEGACY Mode set to false
  45697. * Defines if the material uses height smith correlated visibility term.
  45698. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45699. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45700. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45701. * Not relying on height correlated will also disable energy conservation.
  45702. */
  45703. useSmithVisibilityHeightCorrelated: boolean;
  45704. /** @hidden */
  45705. private _internalMarkAllSubMeshesAsMiscDirty;
  45706. /** @hidden */
  45707. _markAllSubMeshesAsMiscDirty(): void;
  45708. /**
  45709. * Instantiate a new istance of clear coat configuration.
  45710. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45711. */
  45712. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45713. /**
  45714. * Checks to see if a texture is used in the material.
  45715. * @param defines the list of "defines" to update.
  45716. */
  45717. prepareDefines(defines: IMaterialBRDFDefines): void;
  45718. /**
  45719. * Get the current class name of the texture useful for serialization or dynamic coding.
  45720. * @returns "PBRClearCoatConfiguration"
  45721. */
  45722. getClassName(): string;
  45723. /**
  45724. * Makes a duplicate of the current configuration into another one.
  45725. * @param brdfConfiguration define the config where to copy the info
  45726. */
  45727. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45728. /**
  45729. * Serializes this BRDF configuration.
  45730. * @returns - An object with the serialized config.
  45731. */
  45732. serialize(): any;
  45733. /**
  45734. * Parses a BRDF Configuration from a serialized object.
  45735. * @param source - Serialized object.
  45736. */
  45737. parse(source: any): void;
  45738. }
  45739. }
  45740. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  45741. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45742. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45743. import { Color3 } from "babylonjs/Maths/math";
  45744. import { Scene } from "babylonjs/scene";
  45745. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45746. import { IAnimatable } from "babylonjs/Misc/tools";
  45747. import { Nullable } from "babylonjs/types";
  45748. /**
  45749. * @hidden
  45750. */
  45751. export interface IMaterialSheenDefines {
  45752. SHEEN: boolean;
  45753. SHEEN_TEXTURE: boolean;
  45754. SHEEN_TEXTUREDIRECTUV: number;
  45755. SHEEN_LINKWITHALBEDO: boolean;
  45756. /** @hidden */
  45757. _areTexturesDirty: boolean;
  45758. }
  45759. /**
  45760. * Define the code related to the Sheen parameters of the pbr material.
  45761. */
  45762. export class PBRSheenConfiguration {
  45763. private _isEnabled;
  45764. /**
  45765. * Defines if the material uses sheen.
  45766. */
  45767. isEnabled: boolean;
  45768. private _linkSheenWithAlbedo;
  45769. /**
  45770. * Defines if the sheen is linked to the sheen color.
  45771. */
  45772. linkSheenWithAlbedo: boolean;
  45773. /**
  45774. * Defines the sheen intensity.
  45775. */
  45776. intensity: number;
  45777. /**
  45778. * Defines the sheen color.
  45779. */
  45780. color: Color3;
  45781. private _texture;
  45782. /**
  45783. * Stores the sheen tint values in a texture.
  45784. * rgb is tint
  45785. * a is a intensity
  45786. */
  45787. texture: Nullable<BaseTexture>;
  45788. /** @hidden */
  45789. private _internalMarkAllSubMeshesAsTexturesDirty;
  45790. /** @hidden */
  45791. _markAllSubMeshesAsTexturesDirty(): void;
  45792. /**
  45793. * Instantiate a new istance of clear coat configuration.
  45794. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45795. */
  45796. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45797. /**
  45798. * Specifies that the submesh is ready to be used.
  45799. * @param defines the list of "defines" to update.
  45800. * @param scene defines the scene the material belongs to.
  45801. * @returns - boolean indicating that the submesh is ready or not.
  45802. */
  45803. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45804. /**
  45805. * Checks to see if a texture is used in the material.
  45806. * @param defines the list of "defines" to update.
  45807. * @param scene defines the scene the material belongs to.
  45808. */
  45809. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45810. /**
  45811. * Binds the material data.
  45812. * @param uniformBuffer defines the Uniform buffer to fill in.
  45813. * @param scene defines the scene the material belongs to.
  45814. * @param isFrozen defines wether the material is frozen or not.
  45815. */
  45816. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45817. /**
  45818. * Checks to see if a texture is used in the material.
  45819. * @param texture - Base texture to use.
  45820. * @returns - Boolean specifying if a texture is used in the material.
  45821. */
  45822. hasTexture(texture: BaseTexture): boolean;
  45823. /**
  45824. * Returns an array of the actively used textures.
  45825. * @param activeTextures Array of BaseTextures
  45826. */
  45827. getActiveTextures(activeTextures: BaseTexture[]): void;
  45828. /**
  45829. * Returns the animatable textures.
  45830. * @param animatables Array of animatable textures.
  45831. */
  45832. getAnimatables(animatables: IAnimatable[]): void;
  45833. /**
  45834. * Disposes the resources of the material.
  45835. * @param forceDisposeTextures - Forces the disposal of all textures.
  45836. */
  45837. dispose(forceDisposeTextures?: boolean): void;
  45838. /**
  45839. * Get the current class name of the texture useful for serialization or dynamic coding.
  45840. * @returns "PBRSheenConfiguration"
  45841. */
  45842. getClassName(): string;
  45843. /**
  45844. * Add fallbacks to the effect fallbacks list.
  45845. * @param defines defines the Base texture to use.
  45846. * @param fallbacks defines the current fallback list.
  45847. * @param currentRank defines the current fallback rank.
  45848. * @returns the new fallback rank.
  45849. */
  45850. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45851. /**
  45852. * Add the required uniforms to the current list.
  45853. * @param uniforms defines the current uniform list.
  45854. */
  45855. static AddUniforms(uniforms: string[]): void;
  45856. /**
  45857. * Add the required uniforms to the current buffer.
  45858. * @param uniformBuffer defines the current uniform buffer.
  45859. */
  45860. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45861. /**
  45862. * Add the required samplers to the current list.
  45863. * @param samplers defines the current sampler list.
  45864. */
  45865. static AddSamplers(samplers: string[]): void;
  45866. /**
  45867. * Makes a duplicate of the current configuration into another one.
  45868. * @param sheenConfiguration define the config where to copy the info
  45869. */
  45870. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45871. /**
  45872. * Serializes this BRDF configuration.
  45873. * @returns - An object with the serialized config.
  45874. */
  45875. serialize(): any;
  45876. /**
  45877. * Parses a Sheen Configuration from a serialized object.
  45878. * @param source - Serialized object.
  45879. */
  45880. parse(source: any): void;
  45881. }
  45882. }
  45883. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  45884. import { Nullable } from "babylonjs/types";
  45885. import { IAnimatable } from "babylonjs/Misc/tools";
  45886. import { Color3 } from "babylonjs/Maths/math";
  45887. import { SmartArray } from "babylonjs/Misc/smartArray";
  45888. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45889. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45890. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  45891. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45892. import { Engine } from "babylonjs/Engines/engine";
  45893. import { Scene } from "babylonjs/scene";
  45894. /**
  45895. * @hidden
  45896. */
  45897. export interface IMaterialSubSurfaceDefines {
  45898. SUBSURFACE: boolean;
  45899. SS_REFRACTION: boolean;
  45900. SS_TRANSLUCENCY: boolean;
  45901. SS_SCATERRING: boolean;
  45902. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45903. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45904. SS_REFRACTIONMAP_3D: boolean;
  45905. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45906. SS_LODINREFRACTIONALPHA: boolean;
  45907. SS_GAMMAREFRACTION: boolean;
  45908. SS_RGBDREFRACTION: boolean;
  45909. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45910. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45911. /** @hidden */
  45912. _areTexturesDirty: boolean;
  45913. }
  45914. /**
  45915. * Define the code related to the sub surface parameters of the pbr material.
  45916. */
  45917. export class PBRSubSurfaceConfiguration {
  45918. private _isRefractionEnabled;
  45919. /**
  45920. * Defines if the refraction is enabled in the material.
  45921. */
  45922. isRefractionEnabled: boolean;
  45923. private _isTranslucencyEnabled;
  45924. /**
  45925. * Defines if the translucency is enabled in the material.
  45926. */
  45927. isTranslucencyEnabled: boolean;
  45928. private _isScatteringEnabled;
  45929. /**
  45930. * Defines the refraction intensity of the material.
  45931. * The refraction when enabled replaces the Diffuse part of the material.
  45932. * The intensity helps transitionning between diffuse and refraction.
  45933. */
  45934. refractionIntensity: number;
  45935. /**
  45936. * Defines the translucency intensity of the material.
  45937. * When translucency has been enabled, this defines how much of the "translucency"
  45938. * is addded to the diffuse part of the material.
  45939. */
  45940. translucencyIntensity: number;
  45941. /**
  45942. * Defines the scattering intensity of the material.
  45943. * When scattering has been enabled, this defines how much of the "scattered light"
  45944. * is addded to the diffuse part of the material.
  45945. */
  45946. scatteringIntensity: number;
  45947. private _thicknessTexture;
  45948. /**
  45949. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45950. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45951. * 0 would mean minimumThickness
  45952. * 1 would mean maximumThickness
  45953. * The other channels might be use as a mask to vary the different effects intensity.
  45954. */
  45955. thicknessTexture: Nullable<BaseTexture>;
  45956. private _refractionTexture;
  45957. /**
  45958. * Defines the texture to use for refraction.
  45959. */
  45960. refractionTexture: Nullable<BaseTexture>;
  45961. private _indexOfRefraction;
  45962. /**
  45963. * Defines the indice of refraction used in the material.
  45964. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  45965. */
  45966. indexOfRefraction: number;
  45967. private _invertRefractionY;
  45968. /**
  45969. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45970. */
  45971. invertRefractionY: boolean;
  45972. private _linkRefractionWithTransparency;
  45973. /**
  45974. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45975. * Materials half opaque for instance using refraction could benefit from this control.
  45976. */
  45977. linkRefractionWithTransparency: boolean;
  45978. /**
  45979. * Defines the minimum thickness stored in the thickness map.
  45980. * If no thickness map is defined, this value will be used to simulate thickness.
  45981. */
  45982. minimumThickness: number;
  45983. /**
  45984. * Defines the maximum thickness stored in the thickness map.
  45985. */
  45986. maximumThickness: number;
  45987. /**
  45988. * Defines the volume tint of the material.
  45989. * This is used for both translucency and scattering.
  45990. */
  45991. tintColor: Color3;
  45992. /**
  45993. * Defines the distance at which the tint color should be found in the media.
  45994. * This is used for refraction only.
  45995. */
  45996. tintColorAtDistance: number;
  45997. /**
  45998. * Defines how far each channel transmit through the media.
  45999. * It is defined as a color to simplify it selection.
  46000. */
  46001. diffusionDistance: Color3;
  46002. private _useMaskFromThicknessTexture;
  46003. /**
  46004. * Stores the intensity of the different subsurface effects in the thickness texture.
  46005. * * the green channel is the translucency intensity.
  46006. * * the blue channel is the scattering intensity.
  46007. * * the alpha channel is the refraction intensity.
  46008. */
  46009. useMaskFromThicknessTexture: boolean;
  46010. /** @hidden */
  46011. private _internalMarkAllSubMeshesAsTexturesDirty;
  46012. /** @hidden */
  46013. _markAllSubMeshesAsTexturesDirty(): void;
  46014. /**
  46015. * Instantiate a new istance of sub surface configuration.
  46016. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46017. */
  46018. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46019. /**
  46020. * Gets wehter the submesh is ready to be used or not.
  46021. * @param defines the list of "defines" to update.
  46022. * @param scene defines the scene the material belongs to.
  46023. * @returns - boolean indicating that the submesh is ready or not.
  46024. */
  46025. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46026. /**
  46027. * Checks to see if a texture is used in the material.
  46028. * @param defines the list of "defines" to update.
  46029. * @param scene defines the scene to the material belongs to.
  46030. */
  46031. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46032. /**
  46033. * Binds the material data.
  46034. * @param uniformBuffer defines the Uniform buffer to fill in.
  46035. * @param scene defines the scene the material belongs to.
  46036. * @param engine defines the engine the material belongs to.
  46037. * @param isFrozen defines wether the material is frozen or not.
  46038. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46039. */
  46040. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46041. /**
  46042. * Unbinds the material from the mesh.
  46043. * @param activeEffect defines the effect that should be unbound from.
  46044. * @returns true if unbound, otherwise false
  46045. */
  46046. unbind(activeEffect: Effect): boolean;
  46047. /**
  46048. * Returns the texture used for refraction or null if none is used.
  46049. * @param scene defines the scene the material belongs to.
  46050. * @returns - Refraction texture if present. If no refraction texture and refraction
  46051. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46052. */
  46053. private _getRefractionTexture;
  46054. /**
  46055. * Returns true if alpha blending should be disabled.
  46056. */
  46057. readonly disableAlphaBlending: boolean;
  46058. /**
  46059. * Fills the list of render target textures.
  46060. * @param renderTargets the list of render targets to update
  46061. */
  46062. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46063. /**
  46064. * Checks to see if a texture is used in the material.
  46065. * @param texture - Base texture to use.
  46066. * @returns - Boolean specifying if a texture is used in the material.
  46067. */
  46068. hasTexture(texture: BaseTexture): boolean;
  46069. /**
  46070. * Gets a boolean indicating that current material needs to register RTT
  46071. * @returns true if this uses a render target otherwise false.
  46072. */
  46073. hasRenderTargetTextures(): boolean;
  46074. /**
  46075. * Returns an array of the actively used textures.
  46076. * @param activeTextures Array of BaseTextures
  46077. */
  46078. getActiveTextures(activeTextures: BaseTexture[]): void;
  46079. /**
  46080. * Returns the animatable textures.
  46081. * @param animatables Array of animatable textures.
  46082. */
  46083. getAnimatables(animatables: IAnimatable[]): void;
  46084. /**
  46085. * Disposes the resources of the material.
  46086. * @param forceDisposeTextures - Forces the disposal of all textures.
  46087. */
  46088. dispose(forceDisposeTextures?: boolean): void;
  46089. /**
  46090. * Get the current class name of the texture useful for serialization or dynamic coding.
  46091. * @returns "PBRSubSurfaceConfiguration"
  46092. */
  46093. getClassName(): string;
  46094. /**
  46095. * Add fallbacks to the effect fallbacks list.
  46096. * @param defines defines the Base texture to use.
  46097. * @param fallbacks defines the current fallback list.
  46098. * @param currentRank defines the current fallback rank.
  46099. * @returns the new fallback rank.
  46100. */
  46101. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46102. /**
  46103. * Add the required uniforms to the current list.
  46104. * @param uniforms defines the current uniform list.
  46105. */
  46106. static AddUniforms(uniforms: string[]): void;
  46107. /**
  46108. * Add the required samplers to the current list.
  46109. * @param samplers defines the current sampler list.
  46110. */
  46111. static AddSamplers(samplers: string[]): void;
  46112. /**
  46113. * Add the required uniforms to the current buffer.
  46114. * @param uniformBuffer defines the current uniform buffer.
  46115. */
  46116. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46117. /**
  46118. * Makes a duplicate of the current configuration into another one.
  46119. * @param configuration define the config where to copy the info
  46120. */
  46121. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46122. /**
  46123. * Serializes this Sub Surface configuration.
  46124. * @returns - An object with the serialized config.
  46125. */
  46126. serialize(): any;
  46127. /**
  46128. * Parses a Sub Surface Configuration from a serialized object.
  46129. * @param source - Serialized object.
  46130. */
  46131. parse(source: any): void;
  46132. }
  46133. }
  46134. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  46135. /** @hidden */
  46136. export var pbrFragmentDeclaration: {
  46137. name: string;
  46138. shader: string;
  46139. };
  46140. }
  46141. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  46142. /** @hidden */
  46143. export var pbrUboDeclaration: {
  46144. name: string;
  46145. shader: string;
  46146. };
  46147. }
  46148. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  46149. /** @hidden */
  46150. export var pbrFragmentExtraDeclaration: {
  46151. name: string;
  46152. shader: string;
  46153. };
  46154. }
  46155. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  46156. /** @hidden */
  46157. export var pbrFragmentSamplersDeclaration: {
  46158. name: string;
  46159. shader: string;
  46160. };
  46161. }
  46162. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  46163. /** @hidden */
  46164. export var pbrHelperFunctions: {
  46165. name: string;
  46166. shader: string;
  46167. };
  46168. }
  46169. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  46170. /** @hidden */
  46171. export var harmonicsFunctions: {
  46172. name: string;
  46173. shader: string;
  46174. };
  46175. }
  46176. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  46177. /** @hidden */
  46178. export var pbrDirectLightingSetupFunctions: {
  46179. name: string;
  46180. shader: string;
  46181. };
  46182. }
  46183. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  46184. /** @hidden */
  46185. export var pbrDirectLightingFalloffFunctions: {
  46186. name: string;
  46187. shader: string;
  46188. };
  46189. }
  46190. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  46191. /** @hidden */
  46192. export var pbrBRDFFunctions: {
  46193. name: string;
  46194. shader: string;
  46195. };
  46196. }
  46197. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  46198. /** @hidden */
  46199. export var pbrDirectLightingFunctions: {
  46200. name: string;
  46201. shader: string;
  46202. };
  46203. }
  46204. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  46205. /** @hidden */
  46206. export var pbrIBLFunctions: {
  46207. name: string;
  46208. shader: string;
  46209. };
  46210. }
  46211. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  46212. /** @hidden */
  46213. export var pbrDebug: {
  46214. name: string;
  46215. shader: string;
  46216. };
  46217. }
  46218. declare module "babylonjs/Shaders/pbr.fragment" {
  46219. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  46220. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46221. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  46222. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46223. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46224. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  46225. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46226. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46227. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46228. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46229. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46230. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  46231. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46232. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46233. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46234. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  46235. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  46236. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  46237. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  46238. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  46239. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  46240. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46241. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46242. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  46243. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  46244. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46245. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  46246. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46247. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  46248. /** @hidden */
  46249. export var pbrPixelShader: {
  46250. name: string;
  46251. shader: string;
  46252. };
  46253. }
  46254. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  46255. /** @hidden */
  46256. export var pbrVertexDeclaration: {
  46257. name: string;
  46258. shader: string;
  46259. };
  46260. }
  46261. declare module "babylonjs/Shaders/pbr.vertex" {
  46262. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  46263. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46264. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46265. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46266. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46267. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46268. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  46269. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46270. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46271. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46272. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46273. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46274. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46275. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46276. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46277. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46278. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46279. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  46280. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46281. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46282. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46283. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  46284. /** @hidden */
  46285. export var pbrVertexShader: {
  46286. name: string;
  46287. shader: string;
  46288. };
  46289. }
  46290. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46291. import { IAnimatable } from "babylonjs/Misc/tools";
  46292. import { Nullable } from "babylonjs/types";
  46293. import { Scene } from "babylonjs/scene";
  46294. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46295. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46297. import { Mesh } from "babylonjs/Meshes/mesh";
  46298. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46299. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46300. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46301. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46302. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  46303. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46304. import { Material } from "babylonjs/Materials/material";
  46305. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46306. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46307. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46308. import "babylonjs/Shaders/pbr.fragment";
  46309. import "babylonjs/Shaders/pbr.vertex";
  46310. /**
  46311. * Manages the defines for the PBR Material.
  46312. * @hidden
  46313. */
  46314. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46315. PBR: boolean;
  46316. MAINUV1: boolean;
  46317. MAINUV2: boolean;
  46318. UV1: boolean;
  46319. UV2: boolean;
  46320. ALBEDO: boolean;
  46321. ALBEDODIRECTUV: number;
  46322. VERTEXCOLOR: boolean;
  46323. AMBIENT: boolean;
  46324. AMBIENTDIRECTUV: number;
  46325. AMBIENTINGRAYSCALE: boolean;
  46326. OPACITY: boolean;
  46327. VERTEXALPHA: boolean;
  46328. OPACITYDIRECTUV: number;
  46329. OPACITYRGB: boolean;
  46330. ALPHATEST: boolean;
  46331. DEPTHPREPASS: boolean;
  46332. ALPHABLEND: boolean;
  46333. ALPHAFROMALBEDO: boolean;
  46334. ALPHATESTVALUE: string;
  46335. SPECULAROVERALPHA: boolean;
  46336. RADIANCEOVERALPHA: boolean;
  46337. ALPHAFRESNEL: boolean;
  46338. LINEARALPHAFRESNEL: boolean;
  46339. PREMULTIPLYALPHA: boolean;
  46340. EMISSIVE: boolean;
  46341. EMISSIVEDIRECTUV: number;
  46342. REFLECTIVITY: boolean;
  46343. REFLECTIVITYDIRECTUV: number;
  46344. SPECULARTERM: boolean;
  46345. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46346. MICROSURFACEAUTOMATIC: boolean;
  46347. LODBASEDMICROSFURACE: boolean;
  46348. MICROSURFACEMAP: boolean;
  46349. MICROSURFACEMAPDIRECTUV: number;
  46350. METALLICWORKFLOW: boolean;
  46351. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46352. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46353. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46354. AOSTOREINMETALMAPRED: boolean;
  46355. ENVIRONMENTBRDF: boolean;
  46356. ENVIRONMENTBRDF_RGBD: boolean;
  46357. NORMAL: boolean;
  46358. TANGENT: boolean;
  46359. BUMP: boolean;
  46360. BUMPDIRECTUV: number;
  46361. OBJECTSPACE_NORMALMAP: boolean;
  46362. PARALLAX: boolean;
  46363. PARALLAXOCCLUSION: boolean;
  46364. NORMALXYSCALE: boolean;
  46365. LIGHTMAP: boolean;
  46366. LIGHTMAPDIRECTUV: number;
  46367. USELIGHTMAPASSHADOWMAP: boolean;
  46368. GAMMALIGHTMAP: boolean;
  46369. REFLECTION: boolean;
  46370. REFLECTIONMAP_3D: boolean;
  46371. REFLECTIONMAP_SPHERICAL: boolean;
  46372. REFLECTIONMAP_PLANAR: boolean;
  46373. REFLECTIONMAP_CUBIC: boolean;
  46374. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46375. REFLECTIONMAP_PROJECTION: boolean;
  46376. REFLECTIONMAP_SKYBOX: boolean;
  46377. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46378. REFLECTIONMAP_EXPLICIT: boolean;
  46379. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46380. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46381. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46382. INVERTCUBICMAP: boolean;
  46383. USESPHERICALFROMREFLECTIONMAP: boolean;
  46384. USESPHERICALINVERTEX: boolean;
  46385. REFLECTIONMAP_OPPOSITEZ: boolean;
  46386. LODINREFLECTIONALPHA: boolean;
  46387. GAMMAREFLECTION: boolean;
  46388. RGBDREFLECTION: boolean;
  46389. RADIANCEOCCLUSION: boolean;
  46390. HORIZONOCCLUSION: boolean;
  46391. INSTANCES: boolean;
  46392. NUM_BONE_INFLUENCERS: number;
  46393. BonesPerMesh: number;
  46394. BONETEXTURE: boolean;
  46395. NONUNIFORMSCALING: boolean;
  46396. MORPHTARGETS: boolean;
  46397. MORPHTARGETS_NORMAL: boolean;
  46398. MORPHTARGETS_TANGENT: boolean;
  46399. NUM_MORPH_INFLUENCERS: number;
  46400. IMAGEPROCESSING: boolean;
  46401. VIGNETTE: boolean;
  46402. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46403. VIGNETTEBLENDMODEOPAQUE: boolean;
  46404. TONEMAPPING: boolean;
  46405. TONEMAPPING_ACES: boolean;
  46406. CONTRAST: boolean;
  46407. COLORCURVES: boolean;
  46408. COLORGRADING: boolean;
  46409. COLORGRADING3D: boolean;
  46410. SAMPLER3DGREENDEPTH: boolean;
  46411. SAMPLER3DBGRMAP: boolean;
  46412. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46413. EXPOSURE: boolean;
  46414. MULTIVIEW: boolean;
  46415. USEPHYSICALLIGHTFALLOFF: boolean;
  46416. USEGLTFLIGHTFALLOFF: boolean;
  46417. TWOSIDEDLIGHTING: boolean;
  46418. SHADOWFLOAT: boolean;
  46419. CLIPPLANE: boolean;
  46420. CLIPPLANE2: boolean;
  46421. CLIPPLANE3: boolean;
  46422. CLIPPLANE4: boolean;
  46423. POINTSIZE: boolean;
  46424. FOG: boolean;
  46425. LOGARITHMICDEPTH: boolean;
  46426. FORCENORMALFORWARD: boolean;
  46427. SPECULARAA: boolean;
  46428. CLEARCOAT: boolean;
  46429. CLEARCOAT_DEFAULTIOR: boolean;
  46430. CLEARCOAT_TEXTURE: boolean;
  46431. CLEARCOAT_TEXTUREDIRECTUV: number;
  46432. CLEARCOAT_BUMP: boolean;
  46433. CLEARCOAT_BUMPDIRECTUV: number;
  46434. CLEARCOAT_TINT: boolean;
  46435. CLEARCOAT_TINT_TEXTURE: boolean;
  46436. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46437. ANISOTROPIC: boolean;
  46438. ANISOTROPIC_TEXTURE: boolean;
  46439. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46440. BRDF_V_HEIGHT_CORRELATED: boolean;
  46441. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46442. SHEEN: boolean;
  46443. SHEEN_TEXTURE: boolean;
  46444. SHEEN_TEXTUREDIRECTUV: number;
  46445. SHEEN_LINKWITHALBEDO: boolean;
  46446. SUBSURFACE: boolean;
  46447. SS_REFRACTION: boolean;
  46448. SS_TRANSLUCENCY: boolean;
  46449. SS_SCATERRING: boolean;
  46450. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46451. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46452. SS_REFRACTIONMAP_3D: boolean;
  46453. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46454. SS_LODINREFRACTIONALPHA: boolean;
  46455. SS_GAMMAREFRACTION: boolean;
  46456. SS_RGBDREFRACTION: boolean;
  46457. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46458. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46459. UNLIT: boolean;
  46460. DEBUGMODE: number;
  46461. /**
  46462. * Initializes the PBR Material defines.
  46463. */
  46464. constructor();
  46465. /**
  46466. * Resets the PBR Material defines.
  46467. */
  46468. reset(): void;
  46469. }
  46470. /**
  46471. * The Physically based material base class of BJS.
  46472. *
  46473. * This offers the main features of a standard PBR material.
  46474. * For more information, please refer to the documentation :
  46475. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46476. */
  46477. export abstract class PBRBaseMaterial extends PushMaterial {
  46478. /**
  46479. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46480. */
  46481. static readonly PBRMATERIAL_OPAQUE: number;
  46482. /**
  46483. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46484. */
  46485. static readonly PBRMATERIAL_ALPHATEST: number;
  46486. /**
  46487. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46488. */
  46489. static readonly PBRMATERIAL_ALPHABLEND: number;
  46490. /**
  46491. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46492. * They are also discarded below the alpha cutoff threshold to improve performances.
  46493. */
  46494. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46495. /**
  46496. * Defines the default value of how much AO map is occluding the analytical lights
  46497. * (point spot...).
  46498. */
  46499. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46500. /**
  46501. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46502. */
  46503. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46504. /**
  46505. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46506. * to enhance interoperability with other engines.
  46507. */
  46508. static readonly LIGHTFALLOFF_GLTF: number;
  46509. /**
  46510. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46511. * to enhance interoperability with other materials.
  46512. */
  46513. static readonly LIGHTFALLOFF_STANDARD: number;
  46514. /**
  46515. * Intensity of the direct lights e.g. the four lights available in your scene.
  46516. * This impacts both the direct diffuse and specular highlights.
  46517. */
  46518. protected _directIntensity: number;
  46519. /**
  46520. * Intensity of the emissive part of the material.
  46521. * This helps controlling the emissive effect without modifying the emissive color.
  46522. */
  46523. protected _emissiveIntensity: number;
  46524. /**
  46525. * Intensity of the environment e.g. how much the environment will light the object
  46526. * either through harmonics for rough material or through the refelction for shiny ones.
  46527. */
  46528. protected _environmentIntensity: number;
  46529. /**
  46530. * This is a special control allowing the reduction of the specular highlights coming from the
  46531. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46532. */
  46533. protected _specularIntensity: number;
  46534. /**
  46535. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46536. */
  46537. private _lightingInfos;
  46538. /**
  46539. * Debug Control allowing disabling the bump map on this material.
  46540. */
  46541. protected _disableBumpMap: boolean;
  46542. /**
  46543. * AKA Diffuse Texture in standard nomenclature.
  46544. */
  46545. protected _albedoTexture: BaseTexture;
  46546. /**
  46547. * AKA Occlusion Texture in other nomenclature.
  46548. */
  46549. protected _ambientTexture: BaseTexture;
  46550. /**
  46551. * AKA Occlusion Texture Intensity in other nomenclature.
  46552. */
  46553. protected _ambientTextureStrength: number;
  46554. /**
  46555. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46556. * 1 means it completely occludes it
  46557. * 0 mean it has no impact
  46558. */
  46559. protected _ambientTextureImpactOnAnalyticalLights: number;
  46560. /**
  46561. * Stores the alpha values in a texture.
  46562. */
  46563. protected _opacityTexture: BaseTexture;
  46564. /**
  46565. * Stores the reflection values in a texture.
  46566. */
  46567. protected _reflectionTexture: BaseTexture;
  46568. /**
  46569. * Stores the emissive values in a texture.
  46570. */
  46571. protected _emissiveTexture: BaseTexture;
  46572. /**
  46573. * AKA Specular texture in other nomenclature.
  46574. */
  46575. protected _reflectivityTexture: BaseTexture;
  46576. /**
  46577. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46578. */
  46579. protected _metallicTexture: BaseTexture;
  46580. /**
  46581. * Specifies the metallic scalar of the metallic/roughness workflow.
  46582. * Can also be used to scale the metalness values of the metallic texture.
  46583. */
  46584. protected _metallic: Nullable<number>;
  46585. /**
  46586. * Specifies the roughness scalar of the metallic/roughness workflow.
  46587. * Can also be used to scale the roughness values of the metallic texture.
  46588. */
  46589. protected _roughness: Nullable<number>;
  46590. /**
  46591. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46592. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46593. */
  46594. protected _microSurfaceTexture: BaseTexture;
  46595. /**
  46596. * Stores surface normal data used to displace a mesh in a texture.
  46597. */
  46598. protected _bumpTexture: BaseTexture;
  46599. /**
  46600. * Stores the pre-calculated light information of a mesh in a texture.
  46601. */
  46602. protected _lightmapTexture: BaseTexture;
  46603. /**
  46604. * The color of a material in ambient lighting.
  46605. */
  46606. protected _ambientColor: Color3;
  46607. /**
  46608. * AKA Diffuse Color in other nomenclature.
  46609. */
  46610. protected _albedoColor: Color3;
  46611. /**
  46612. * AKA Specular Color in other nomenclature.
  46613. */
  46614. protected _reflectivityColor: Color3;
  46615. /**
  46616. * The color applied when light is reflected from a material.
  46617. */
  46618. protected _reflectionColor: Color3;
  46619. /**
  46620. * The color applied when light is emitted from a material.
  46621. */
  46622. protected _emissiveColor: Color3;
  46623. /**
  46624. * AKA Glossiness in other nomenclature.
  46625. */
  46626. protected _microSurface: number;
  46627. /**
  46628. * Specifies that the material will use the light map as a show map.
  46629. */
  46630. protected _useLightmapAsShadowmap: boolean;
  46631. /**
  46632. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46633. * makes the reflect vector face the model (under horizon).
  46634. */
  46635. protected _useHorizonOcclusion: boolean;
  46636. /**
  46637. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46638. * too much the area relying on ambient texture to define their ambient occlusion.
  46639. */
  46640. protected _useRadianceOcclusion: boolean;
  46641. /**
  46642. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46643. */
  46644. protected _useAlphaFromAlbedoTexture: boolean;
  46645. /**
  46646. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46647. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46648. */
  46649. protected _useSpecularOverAlpha: boolean;
  46650. /**
  46651. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46652. */
  46653. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46654. /**
  46655. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46656. */
  46657. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46658. /**
  46659. * Specifies if the metallic texture contains the roughness information in its green channel.
  46660. */
  46661. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46662. /**
  46663. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46664. */
  46665. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46666. /**
  46667. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46668. */
  46669. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46670. /**
  46671. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46672. */
  46673. protected _useAmbientInGrayScale: boolean;
  46674. /**
  46675. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46676. * The material will try to infer what glossiness each pixel should be.
  46677. */
  46678. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46679. /**
  46680. * Defines the falloff type used in this material.
  46681. * It by default is Physical.
  46682. */
  46683. protected _lightFalloff: number;
  46684. /**
  46685. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46686. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46687. */
  46688. protected _useRadianceOverAlpha: boolean;
  46689. /**
  46690. * Allows using an object space normal map (instead of tangent space).
  46691. */
  46692. protected _useObjectSpaceNormalMap: boolean;
  46693. /**
  46694. * Allows using the bump map in parallax mode.
  46695. */
  46696. protected _useParallax: boolean;
  46697. /**
  46698. * Allows using the bump map in parallax occlusion mode.
  46699. */
  46700. protected _useParallaxOcclusion: boolean;
  46701. /**
  46702. * Controls the scale bias of the parallax mode.
  46703. */
  46704. protected _parallaxScaleBias: number;
  46705. /**
  46706. * If sets to true, disables all the lights affecting the material.
  46707. */
  46708. protected _disableLighting: boolean;
  46709. /**
  46710. * Number of Simultaneous lights allowed on the material.
  46711. */
  46712. protected _maxSimultaneousLights: number;
  46713. /**
  46714. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46715. */
  46716. protected _invertNormalMapX: boolean;
  46717. /**
  46718. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46719. */
  46720. protected _invertNormalMapY: boolean;
  46721. /**
  46722. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46723. */
  46724. protected _twoSidedLighting: boolean;
  46725. /**
  46726. * Defines the alpha limits in alpha test mode.
  46727. */
  46728. protected _alphaCutOff: number;
  46729. /**
  46730. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46731. */
  46732. protected _forceAlphaTest: boolean;
  46733. /**
  46734. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46735. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46736. */
  46737. protected _useAlphaFresnel: boolean;
  46738. /**
  46739. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46740. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46741. */
  46742. protected _useLinearAlphaFresnel: boolean;
  46743. /**
  46744. * The transparency mode of the material.
  46745. */
  46746. protected _transparencyMode: Nullable<number>;
  46747. /**
  46748. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46749. * from cos thetav and roughness:
  46750. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46751. */
  46752. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46753. /**
  46754. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46755. */
  46756. protected _forceIrradianceInFragment: boolean;
  46757. /**
  46758. * Force normal to face away from face.
  46759. */
  46760. protected _forceNormalForward: boolean;
  46761. /**
  46762. * Enables specular anti aliasing in the PBR shader.
  46763. * It will both interacts on the Geometry for analytical and IBL lighting.
  46764. * It also prefilter the roughness map based on the bump values.
  46765. */
  46766. protected _enableSpecularAntiAliasing: boolean;
  46767. /**
  46768. * Default configuration related to image processing available in the PBR Material.
  46769. */
  46770. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46771. /**
  46772. * Keep track of the image processing observer to allow dispose and replace.
  46773. */
  46774. private _imageProcessingObserver;
  46775. /**
  46776. * Attaches a new image processing configuration to the PBR Material.
  46777. * @param configuration
  46778. */
  46779. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46780. /**
  46781. * Stores the available render targets.
  46782. */
  46783. private _renderTargets;
  46784. /**
  46785. * Sets the global ambient color for the material used in lighting calculations.
  46786. */
  46787. private _globalAmbientColor;
  46788. /**
  46789. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46790. */
  46791. private _useLogarithmicDepth;
  46792. /**
  46793. * If set to true, no lighting calculations will be applied.
  46794. */
  46795. private _unlit;
  46796. private _debugMode;
  46797. /**
  46798. * @hidden
  46799. * This is reserved for the inspector.
  46800. * Defines the material debug mode.
  46801. * It helps seeing only some components of the material while troubleshooting.
  46802. */
  46803. debugMode: number;
  46804. /**
  46805. * @hidden
  46806. * This is reserved for the inspector.
  46807. * Specify from where on screen the debug mode should start.
  46808. * The value goes from -1 (full screen) to 1 (not visible)
  46809. * It helps with side by side comparison against the final render
  46810. * This defaults to -1
  46811. */
  46812. private debugLimit;
  46813. /**
  46814. * @hidden
  46815. * This is reserved for the inspector.
  46816. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46817. * You can use the factor to better multiply the final value.
  46818. */
  46819. private debugFactor;
  46820. /**
  46821. * Defines the clear coat layer parameters for the material.
  46822. */
  46823. readonly clearCoat: PBRClearCoatConfiguration;
  46824. /**
  46825. * Defines the anisotropic parameters for the material.
  46826. */
  46827. readonly anisotropy: PBRAnisotropicConfiguration;
  46828. /**
  46829. * Defines the BRDF parameters for the material.
  46830. */
  46831. readonly brdf: PBRBRDFConfiguration;
  46832. /**
  46833. * Defines the Sheen parameters for the material.
  46834. */
  46835. readonly sheen: PBRSheenConfiguration;
  46836. /**
  46837. * Defines the SubSurface parameters for the material.
  46838. */
  46839. readonly subSurface: PBRSubSurfaceConfiguration;
  46840. /**
  46841. * Custom callback helping to override the default shader used in the material.
  46842. */
  46843. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46844. /**
  46845. * Instantiates a new PBRMaterial instance.
  46846. *
  46847. * @param name The material name
  46848. * @param scene The scene the material will be use in.
  46849. */
  46850. constructor(name: string, scene: Scene);
  46851. /**
  46852. * Gets a boolean indicating that current material needs to register RTT
  46853. */
  46854. readonly hasRenderTargetTextures: boolean;
  46855. /**
  46856. * Gets the name of the material class.
  46857. */
  46858. getClassName(): string;
  46859. /**
  46860. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46861. */
  46862. /**
  46863. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46864. */
  46865. useLogarithmicDepth: boolean;
  46866. /**
  46867. * Gets the current transparency mode.
  46868. */
  46869. /**
  46870. * Sets the transparency mode of the material.
  46871. *
  46872. * | Value | Type | Description |
  46873. * | ----- | ----------------------------------- | ----------- |
  46874. * | 0 | OPAQUE | |
  46875. * | 1 | ALPHATEST | |
  46876. * | 2 | ALPHABLEND | |
  46877. * | 3 | ALPHATESTANDBLEND | |
  46878. *
  46879. */
  46880. transparencyMode: Nullable<number>;
  46881. /**
  46882. * Returns true if alpha blending should be disabled.
  46883. */
  46884. private readonly _disableAlphaBlending;
  46885. /**
  46886. * Specifies whether or not this material should be rendered in alpha blend mode.
  46887. */
  46888. needAlphaBlending(): boolean;
  46889. /**
  46890. * Specifies if the mesh will require alpha blending.
  46891. * @param mesh - BJS mesh.
  46892. */
  46893. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46894. /**
  46895. * Specifies whether or not this material should be rendered in alpha test mode.
  46896. */
  46897. needAlphaTesting(): boolean;
  46898. /**
  46899. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46900. */
  46901. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46902. /**
  46903. * Gets the texture used for the alpha test.
  46904. */
  46905. getAlphaTestTexture(): BaseTexture;
  46906. /**
  46907. * Specifies that the submesh is ready to be used.
  46908. * @param mesh - BJS mesh.
  46909. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46910. * @param useInstances - Specifies that instances should be used.
  46911. * @returns - boolean indicating that the submesh is ready or not.
  46912. */
  46913. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46914. /**
  46915. * Specifies if the material uses metallic roughness workflow.
  46916. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46917. */
  46918. isMetallicWorkflow(): boolean;
  46919. private _prepareEffect;
  46920. private _prepareDefines;
  46921. /**
  46922. * Force shader compilation
  46923. */
  46924. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46925. clipPlane: boolean;
  46926. }>): void;
  46927. /**
  46928. * Initializes the uniform buffer layout for the shader.
  46929. */
  46930. buildUniformLayout(): void;
  46931. /**
  46932. * Unbinds the material from the mesh
  46933. */
  46934. unbind(): void;
  46935. /**
  46936. * Binds the submesh data.
  46937. * @param world - The world matrix.
  46938. * @param mesh - The BJS mesh.
  46939. * @param subMesh - A submesh of the BJS mesh.
  46940. */
  46941. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46942. /**
  46943. * Returns the animatable textures.
  46944. * @returns - Array of animatable textures.
  46945. */
  46946. getAnimatables(): IAnimatable[];
  46947. /**
  46948. * Returns the texture used for reflections.
  46949. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46950. */
  46951. private _getReflectionTexture;
  46952. /**
  46953. * Returns an array of the actively used textures.
  46954. * @returns - Array of BaseTextures
  46955. */
  46956. getActiveTextures(): BaseTexture[];
  46957. /**
  46958. * Checks to see if a texture is used in the material.
  46959. * @param texture - Base texture to use.
  46960. * @returns - Boolean specifying if a texture is used in the material.
  46961. */
  46962. hasTexture(texture: BaseTexture): boolean;
  46963. /**
  46964. * Disposes the resources of the material.
  46965. * @param forceDisposeEffect - Forces the disposal of effects.
  46966. * @param forceDisposeTextures - Forces the disposal of all textures.
  46967. */
  46968. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46969. }
  46970. }
  46971. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  46972. import { Nullable } from "babylonjs/types";
  46973. import { Scene } from "babylonjs/scene";
  46974. import { Color3 } from "babylonjs/Maths/math";
  46975. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46976. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46977. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46978. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  46979. /**
  46980. * The Physically based material of BJS.
  46981. *
  46982. * This offers the main features of a standard PBR material.
  46983. * For more information, please refer to the documentation :
  46984. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46985. */
  46986. export class PBRMaterial extends PBRBaseMaterial {
  46987. /**
  46988. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46989. */
  46990. static readonly PBRMATERIAL_OPAQUE: number;
  46991. /**
  46992. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46993. */
  46994. static readonly PBRMATERIAL_ALPHATEST: number;
  46995. /**
  46996. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46997. */
  46998. static readonly PBRMATERIAL_ALPHABLEND: number;
  46999. /**
  47000. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47001. * They are also discarded below the alpha cutoff threshold to improve performances.
  47002. */
  47003. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47004. /**
  47005. * Defines the default value of how much AO map is occluding the analytical lights
  47006. * (point spot...).
  47007. */
  47008. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47009. /**
  47010. * Intensity of the direct lights e.g. the four lights available in your scene.
  47011. * This impacts both the direct diffuse and specular highlights.
  47012. */
  47013. directIntensity: number;
  47014. /**
  47015. * Intensity of the emissive part of the material.
  47016. * This helps controlling the emissive effect without modifying the emissive color.
  47017. */
  47018. emissiveIntensity: number;
  47019. /**
  47020. * Intensity of the environment e.g. how much the environment will light the object
  47021. * either through harmonics for rough material or through the refelction for shiny ones.
  47022. */
  47023. environmentIntensity: number;
  47024. /**
  47025. * This is a special control allowing the reduction of the specular highlights coming from the
  47026. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47027. */
  47028. specularIntensity: number;
  47029. /**
  47030. * Debug Control allowing disabling the bump map on this material.
  47031. */
  47032. disableBumpMap: boolean;
  47033. /**
  47034. * AKA Diffuse Texture in standard nomenclature.
  47035. */
  47036. albedoTexture: BaseTexture;
  47037. /**
  47038. * AKA Occlusion Texture in other nomenclature.
  47039. */
  47040. ambientTexture: BaseTexture;
  47041. /**
  47042. * AKA Occlusion Texture Intensity in other nomenclature.
  47043. */
  47044. ambientTextureStrength: number;
  47045. /**
  47046. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47047. * 1 means it completely occludes it
  47048. * 0 mean it has no impact
  47049. */
  47050. ambientTextureImpactOnAnalyticalLights: number;
  47051. /**
  47052. * Stores the alpha values in a texture.
  47053. */
  47054. opacityTexture: BaseTexture;
  47055. /**
  47056. * Stores the reflection values in a texture.
  47057. */
  47058. reflectionTexture: Nullable<BaseTexture>;
  47059. /**
  47060. * Stores the emissive values in a texture.
  47061. */
  47062. emissiveTexture: BaseTexture;
  47063. /**
  47064. * AKA Specular texture in other nomenclature.
  47065. */
  47066. reflectivityTexture: BaseTexture;
  47067. /**
  47068. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47069. */
  47070. metallicTexture: BaseTexture;
  47071. /**
  47072. * Specifies the metallic scalar of the metallic/roughness workflow.
  47073. * Can also be used to scale the metalness values of the metallic texture.
  47074. */
  47075. metallic: Nullable<number>;
  47076. /**
  47077. * Specifies the roughness scalar of the metallic/roughness workflow.
  47078. * Can also be used to scale the roughness values of the metallic texture.
  47079. */
  47080. roughness: Nullable<number>;
  47081. /**
  47082. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47083. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47084. */
  47085. microSurfaceTexture: BaseTexture;
  47086. /**
  47087. * Stores surface normal data used to displace a mesh in a texture.
  47088. */
  47089. bumpTexture: BaseTexture;
  47090. /**
  47091. * Stores the pre-calculated light information of a mesh in a texture.
  47092. */
  47093. lightmapTexture: BaseTexture;
  47094. /**
  47095. * Stores the refracted light information in a texture.
  47096. */
  47097. refractionTexture: Nullable<BaseTexture>;
  47098. /**
  47099. * The color of a material in ambient lighting.
  47100. */
  47101. ambientColor: Color3;
  47102. /**
  47103. * AKA Diffuse Color in other nomenclature.
  47104. */
  47105. albedoColor: Color3;
  47106. /**
  47107. * AKA Specular Color in other nomenclature.
  47108. */
  47109. reflectivityColor: Color3;
  47110. /**
  47111. * The color reflected from the material.
  47112. */
  47113. reflectionColor: Color3;
  47114. /**
  47115. * The color emitted from the material.
  47116. */
  47117. emissiveColor: Color3;
  47118. /**
  47119. * AKA Glossiness in other nomenclature.
  47120. */
  47121. microSurface: number;
  47122. /**
  47123. * source material index of refraction (IOR)' / 'destination material IOR.
  47124. */
  47125. indexOfRefraction: number;
  47126. /**
  47127. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47128. */
  47129. invertRefractionY: boolean;
  47130. /**
  47131. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47132. * Materials half opaque for instance using refraction could benefit from this control.
  47133. */
  47134. linkRefractionWithTransparency: boolean;
  47135. /**
  47136. * If true, the light map contains occlusion information instead of lighting info.
  47137. */
  47138. useLightmapAsShadowmap: boolean;
  47139. /**
  47140. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47141. */
  47142. useAlphaFromAlbedoTexture: boolean;
  47143. /**
  47144. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47145. */
  47146. forceAlphaTest: boolean;
  47147. /**
  47148. * Defines the alpha limits in alpha test mode.
  47149. */
  47150. alphaCutOff: number;
  47151. /**
  47152. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47153. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47154. */
  47155. useSpecularOverAlpha: boolean;
  47156. /**
  47157. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47158. */
  47159. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47160. /**
  47161. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47162. */
  47163. useRoughnessFromMetallicTextureAlpha: boolean;
  47164. /**
  47165. * Specifies if the metallic texture contains the roughness information in its green channel.
  47166. */
  47167. useRoughnessFromMetallicTextureGreen: boolean;
  47168. /**
  47169. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47170. */
  47171. useMetallnessFromMetallicTextureBlue: boolean;
  47172. /**
  47173. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47174. */
  47175. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47176. /**
  47177. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47178. */
  47179. useAmbientInGrayScale: boolean;
  47180. /**
  47181. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47182. * The material will try to infer what glossiness each pixel should be.
  47183. */
  47184. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47185. /**
  47186. * BJS is using an harcoded light falloff based on a manually sets up range.
  47187. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47188. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47189. */
  47190. /**
  47191. * BJS is using an harcoded light falloff based on a manually sets up range.
  47192. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47193. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47194. */
  47195. usePhysicalLightFalloff: boolean;
  47196. /**
  47197. * In order to support the falloff compatibility with gltf, a special mode has been added
  47198. * to reproduce the gltf light falloff.
  47199. */
  47200. /**
  47201. * In order to support the falloff compatibility with gltf, a special mode has been added
  47202. * to reproduce the gltf light falloff.
  47203. */
  47204. useGLTFLightFalloff: boolean;
  47205. /**
  47206. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47207. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47208. */
  47209. useRadianceOverAlpha: boolean;
  47210. /**
  47211. * Allows using an object space normal map (instead of tangent space).
  47212. */
  47213. useObjectSpaceNormalMap: boolean;
  47214. /**
  47215. * Allows using the bump map in parallax mode.
  47216. */
  47217. useParallax: boolean;
  47218. /**
  47219. * Allows using the bump map in parallax occlusion mode.
  47220. */
  47221. useParallaxOcclusion: boolean;
  47222. /**
  47223. * Controls the scale bias of the parallax mode.
  47224. */
  47225. parallaxScaleBias: number;
  47226. /**
  47227. * If sets to true, disables all the lights affecting the material.
  47228. */
  47229. disableLighting: boolean;
  47230. /**
  47231. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47232. */
  47233. forceIrradianceInFragment: boolean;
  47234. /**
  47235. * Number of Simultaneous lights allowed on the material.
  47236. */
  47237. maxSimultaneousLights: number;
  47238. /**
  47239. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47240. */
  47241. invertNormalMapX: boolean;
  47242. /**
  47243. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47244. */
  47245. invertNormalMapY: boolean;
  47246. /**
  47247. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47248. */
  47249. twoSidedLighting: boolean;
  47250. /**
  47251. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47252. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47253. */
  47254. useAlphaFresnel: boolean;
  47255. /**
  47256. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47257. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47258. */
  47259. useLinearAlphaFresnel: boolean;
  47260. /**
  47261. * Let user defines the brdf lookup texture used for IBL.
  47262. * A default 8bit version is embedded but you could point at :
  47263. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  47264. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47265. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47266. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47267. */
  47268. environmentBRDFTexture: Nullable<BaseTexture>;
  47269. /**
  47270. * Force normal to face away from face.
  47271. */
  47272. forceNormalForward: boolean;
  47273. /**
  47274. * Enables specular anti aliasing in the PBR shader.
  47275. * It will both interacts on the Geometry for analytical and IBL lighting.
  47276. * It also prefilter the roughness map based on the bump values.
  47277. */
  47278. enableSpecularAntiAliasing: boolean;
  47279. /**
  47280. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47281. * makes the reflect vector face the model (under horizon).
  47282. */
  47283. useHorizonOcclusion: boolean;
  47284. /**
  47285. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47286. * too much the area relying on ambient texture to define their ambient occlusion.
  47287. */
  47288. useRadianceOcclusion: boolean;
  47289. /**
  47290. * If set to true, no lighting calculations will be applied.
  47291. */
  47292. unlit: boolean;
  47293. /**
  47294. * Gets the image processing configuration used either in this material.
  47295. */
  47296. /**
  47297. * Sets the Default image processing configuration used either in the this material.
  47298. *
  47299. * If sets to null, the scene one is in use.
  47300. */
  47301. imageProcessingConfiguration: ImageProcessingConfiguration;
  47302. /**
  47303. * Gets wether the color curves effect is enabled.
  47304. */
  47305. /**
  47306. * Sets wether the color curves effect is enabled.
  47307. */
  47308. cameraColorCurvesEnabled: boolean;
  47309. /**
  47310. * Gets wether the color grading effect is enabled.
  47311. */
  47312. /**
  47313. * Gets wether the color grading effect is enabled.
  47314. */
  47315. cameraColorGradingEnabled: boolean;
  47316. /**
  47317. * Gets wether tonemapping is enabled or not.
  47318. */
  47319. /**
  47320. * Sets wether tonemapping is enabled or not
  47321. */
  47322. cameraToneMappingEnabled: boolean;
  47323. /**
  47324. * The camera exposure used on this material.
  47325. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47326. * This corresponds to a photographic exposure.
  47327. */
  47328. /**
  47329. * The camera exposure used on this material.
  47330. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47331. * This corresponds to a photographic exposure.
  47332. */
  47333. cameraExposure: number;
  47334. /**
  47335. * Gets The camera contrast used on this material.
  47336. */
  47337. /**
  47338. * Sets The camera contrast used on this material.
  47339. */
  47340. cameraContrast: number;
  47341. /**
  47342. * Gets the Color Grading 2D Lookup Texture.
  47343. */
  47344. /**
  47345. * Sets the Color Grading 2D Lookup Texture.
  47346. */
  47347. cameraColorGradingTexture: Nullable<BaseTexture>;
  47348. /**
  47349. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47350. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47351. * 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;
  47352. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47353. */
  47354. /**
  47355. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47356. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47357. * 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;
  47358. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47359. */
  47360. cameraColorCurves: Nullable<ColorCurves>;
  47361. /**
  47362. * Instantiates a new PBRMaterial instance.
  47363. *
  47364. * @param name The material name
  47365. * @param scene The scene the material will be use in.
  47366. */
  47367. constructor(name: string, scene: Scene);
  47368. /**
  47369. * Returns the name of this material class.
  47370. */
  47371. getClassName(): string;
  47372. /**
  47373. * Makes a duplicate of the current material.
  47374. * @param name - name to use for the new material.
  47375. */
  47376. clone(name: string): PBRMaterial;
  47377. /**
  47378. * Serializes this PBR Material.
  47379. * @returns - An object with the serialized material.
  47380. */
  47381. serialize(): any;
  47382. /**
  47383. * Parses a PBR Material from a serialized object.
  47384. * @param source - Serialized object.
  47385. * @param scene - BJS scene instance.
  47386. * @param rootUrl - url for the scene object
  47387. * @returns - PBRMaterial
  47388. */
  47389. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47390. }
  47391. }
  47392. declare module "babylonjs/Misc/dds" {
  47393. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47394. import { Engine } from "babylonjs/Engines/engine";
  47395. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47396. import { Nullable } from "babylonjs/types";
  47397. import { Scene } from "babylonjs/scene";
  47398. /**
  47399. * Direct draw surface info
  47400. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47401. */
  47402. export interface DDSInfo {
  47403. /**
  47404. * Width of the texture
  47405. */
  47406. width: number;
  47407. /**
  47408. * Width of the texture
  47409. */
  47410. height: number;
  47411. /**
  47412. * Number of Mipmaps for the texture
  47413. * @see https://en.wikipedia.org/wiki/Mipmap
  47414. */
  47415. mipmapCount: number;
  47416. /**
  47417. * If the textures format is a known fourCC format
  47418. * @see https://www.fourcc.org/
  47419. */
  47420. isFourCC: boolean;
  47421. /**
  47422. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47423. */
  47424. isRGB: boolean;
  47425. /**
  47426. * If the texture is a lumincance format
  47427. */
  47428. isLuminance: boolean;
  47429. /**
  47430. * If this is a cube texture
  47431. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47432. */
  47433. isCube: boolean;
  47434. /**
  47435. * If the texture is a compressed format eg. FOURCC_DXT1
  47436. */
  47437. isCompressed: boolean;
  47438. /**
  47439. * The dxgiFormat of the texture
  47440. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47441. */
  47442. dxgiFormat: number;
  47443. /**
  47444. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47445. */
  47446. textureType: number;
  47447. /**
  47448. * Sphericle polynomial created for the dds texture
  47449. */
  47450. sphericalPolynomial?: SphericalPolynomial;
  47451. }
  47452. /**
  47453. * Class used to provide DDS decompression tools
  47454. */
  47455. export class DDSTools {
  47456. /**
  47457. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47458. */
  47459. static StoreLODInAlphaChannel: boolean;
  47460. /**
  47461. * Gets DDS information from an array buffer
  47462. * @param arrayBuffer defines the array buffer to read data from
  47463. * @returns the DDS information
  47464. */
  47465. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47466. private static _FloatView;
  47467. private static _Int32View;
  47468. private static _ToHalfFloat;
  47469. private static _FromHalfFloat;
  47470. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47471. private static _GetHalfFloatRGBAArrayBuffer;
  47472. private static _GetFloatRGBAArrayBuffer;
  47473. private static _GetFloatAsUIntRGBAArrayBuffer;
  47474. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47475. private static _GetRGBAArrayBuffer;
  47476. private static _ExtractLongWordOrder;
  47477. private static _GetRGBArrayBuffer;
  47478. private static _GetLuminanceArrayBuffer;
  47479. /**
  47480. * Uploads DDS Levels to a Babylon Texture
  47481. * @hidden
  47482. */
  47483. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47484. }
  47485. module "babylonjs/Engines/engine" {
  47486. interface Engine {
  47487. /**
  47488. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47489. * @param rootUrl defines the url where the file to load is located
  47490. * @param scene defines the current scene
  47491. * @param lodScale defines scale to apply to the mip map selection
  47492. * @param lodOffset defines offset to apply to the mip map selection
  47493. * @param onLoad defines an optional callback raised when the texture is loaded
  47494. * @param onError defines an optional callback raised if there is an issue to load the texture
  47495. * @param format defines the format of the data
  47496. * @param forcedExtension defines the extension to use to pick the right loader
  47497. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47498. * @returns the cube texture as an InternalTexture
  47499. */
  47500. 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;
  47501. }
  47502. }
  47503. }
  47504. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47505. import { Nullable } from "babylonjs/types";
  47506. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47507. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47508. /**
  47509. * Implementation of the DDS Texture Loader.
  47510. * @hidden
  47511. */
  47512. export class _DDSTextureLoader implements IInternalTextureLoader {
  47513. /**
  47514. * Defines wether the loader supports cascade loading the different faces.
  47515. */
  47516. readonly supportCascades: boolean;
  47517. /**
  47518. * This returns if the loader support the current file information.
  47519. * @param extension defines the file extension of the file being loaded
  47520. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47521. * @param fallback defines the fallback internal texture if any
  47522. * @param isBase64 defines whether the texture is encoded as a base64
  47523. * @param isBuffer defines whether the texture data are stored as a buffer
  47524. * @returns true if the loader can load the specified file
  47525. */
  47526. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47527. /**
  47528. * Transform the url before loading if required.
  47529. * @param rootUrl the url of the texture
  47530. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47531. * @returns the transformed texture
  47532. */
  47533. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47534. /**
  47535. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47536. * @param rootUrl the url of the texture
  47537. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47538. * @returns the fallback texture
  47539. */
  47540. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47541. /**
  47542. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47543. * @param data contains the texture data
  47544. * @param texture defines the BabylonJS internal texture
  47545. * @param createPolynomials will be true if polynomials have been requested
  47546. * @param onLoad defines the callback to trigger once the texture is ready
  47547. * @param onError defines the callback to trigger in case of error
  47548. */
  47549. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47550. /**
  47551. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47552. * @param data contains the texture data
  47553. * @param texture defines the BabylonJS internal texture
  47554. * @param callback defines the method to call once ready to upload
  47555. */
  47556. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47557. }
  47558. }
  47559. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47560. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47561. /** @hidden */
  47562. export var rgbdEncodePixelShader: {
  47563. name: string;
  47564. shader: string;
  47565. };
  47566. }
  47567. declare module "babylonjs/Misc/environmentTextureTools" {
  47568. import { Nullable } from "babylonjs/types";
  47569. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47570. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47571. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47572. import "babylonjs/Shaders/rgbdEncode.fragment";
  47573. import "babylonjs/Shaders/rgbdDecode.fragment";
  47574. /**
  47575. * Raw texture data and descriptor sufficient for WebGL texture upload
  47576. */
  47577. export interface EnvironmentTextureInfo {
  47578. /**
  47579. * Version of the environment map
  47580. */
  47581. version: number;
  47582. /**
  47583. * Width of image
  47584. */
  47585. width: number;
  47586. /**
  47587. * Irradiance information stored in the file.
  47588. */
  47589. irradiance: any;
  47590. /**
  47591. * Specular information stored in the file.
  47592. */
  47593. specular: any;
  47594. }
  47595. /**
  47596. * Sets of helpers addressing the serialization and deserialization of environment texture
  47597. * stored in a BabylonJS env file.
  47598. * Those files are usually stored as .env files.
  47599. */
  47600. export class EnvironmentTextureTools {
  47601. /**
  47602. * Magic number identifying the env file.
  47603. */
  47604. private static _MagicBytes;
  47605. /**
  47606. * Gets the environment info from an env file.
  47607. * @param data The array buffer containing the .env bytes.
  47608. * @returns the environment file info (the json header) if successfully parsed.
  47609. */
  47610. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47611. /**
  47612. * Creates an environment texture from a loaded cube texture.
  47613. * @param texture defines the cube texture to convert in env file
  47614. * @return a promise containing the environment data if succesfull.
  47615. */
  47616. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47617. /**
  47618. * Creates a JSON representation of the spherical data.
  47619. * @param texture defines the texture containing the polynomials
  47620. * @return the JSON representation of the spherical info
  47621. */
  47622. private static _CreateEnvTextureIrradiance;
  47623. /**
  47624. * Uploads the texture info contained in the env file to the GPU.
  47625. * @param texture defines the internal texture to upload to
  47626. * @param arrayBuffer defines the buffer cotaining the data to load
  47627. * @param info defines the texture info retrieved through the GetEnvInfo method
  47628. * @returns a promise
  47629. */
  47630. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47631. /**
  47632. * Uploads the levels of image data to the GPU.
  47633. * @param texture defines the internal texture to upload to
  47634. * @param imageData defines the array buffer views of image data [mipmap][face]
  47635. * @returns a promise
  47636. */
  47637. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47638. /**
  47639. * Uploads spherical polynomials information to the texture.
  47640. * @param texture defines the texture we are trying to upload the information to
  47641. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47642. */
  47643. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47644. /** @hidden */
  47645. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47646. }
  47647. }
  47648. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  47649. import { Nullable } from "babylonjs/types";
  47650. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47651. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47652. /**
  47653. * Implementation of the ENV Texture Loader.
  47654. * @hidden
  47655. */
  47656. export class _ENVTextureLoader implements IInternalTextureLoader {
  47657. /**
  47658. * Defines wether the loader supports cascade loading the different faces.
  47659. */
  47660. readonly supportCascades: boolean;
  47661. /**
  47662. * This returns if the loader support the current file information.
  47663. * @param extension defines the file extension of the file being loaded
  47664. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47665. * @param fallback defines the fallback internal texture if any
  47666. * @param isBase64 defines whether the texture is encoded as a base64
  47667. * @param isBuffer defines whether the texture data are stored as a buffer
  47668. * @returns true if the loader can load the specified file
  47669. */
  47670. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47671. /**
  47672. * Transform the url before loading if required.
  47673. * @param rootUrl the url of the texture
  47674. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47675. * @returns the transformed texture
  47676. */
  47677. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47678. /**
  47679. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47680. * @param rootUrl the url of the texture
  47681. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47682. * @returns the fallback texture
  47683. */
  47684. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47685. /**
  47686. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47687. * @param data contains the texture data
  47688. * @param texture defines the BabylonJS internal texture
  47689. * @param createPolynomials will be true if polynomials have been requested
  47690. * @param onLoad defines the callback to trigger once the texture is ready
  47691. * @param onError defines the callback to trigger in case of error
  47692. */
  47693. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47694. /**
  47695. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47696. * @param data contains the texture data
  47697. * @param texture defines the BabylonJS internal texture
  47698. * @param callback defines the method to call once ready to upload
  47699. */
  47700. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47701. }
  47702. }
  47703. declare module "babylonjs/Misc/khronosTextureContainer" {
  47704. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47705. /**
  47706. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47707. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47708. */
  47709. export class KhronosTextureContainer {
  47710. /** contents of the KTX container file */
  47711. arrayBuffer: any;
  47712. private static HEADER_LEN;
  47713. private static COMPRESSED_2D;
  47714. private static COMPRESSED_3D;
  47715. private static TEX_2D;
  47716. private static TEX_3D;
  47717. /**
  47718. * Gets the openGL type
  47719. */
  47720. glType: number;
  47721. /**
  47722. * Gets the openGL type size
  47723. */
  47724. glTypeSize: number;
  47725. /**
  47726. * Gets the openGL format
  47727. */
  47728. glFormat: number;
  47729. /**
  47730. * Gets the openGL internal format
  47731. */
  47732. glInternalFormat: number;
  47733. /**
  47734. * Gets the base internal format
  47735. */
  47736. glBaseInternalFormat: number;
  47737. /**
  47738. * Gets image width in pixel
  47739. */
  47740. pixelWidth: number;
  47741. /**
  47742. * Gets image height in pixel
  47743. */
  47744. pixelHeight: number;
  47745. /**
  47746. * Gets image depth in pixels
  47747. */
  47748. pixelDepth: number;
  47749. /**
  47750. * Gets the number of array elements
  47751. */
  47752. numberOfArrayElements: number;
  47753. /**
  47754. * Gets the number of faces
  47755. */
  47756. numberOfFaces: number;
  47757. /**
  47758. * Gets the number of mipmap levels
  47759. */
  47760. numberOfMipmapLevels: number;
  47761. /**
  47762. * Gets the bytes of key value data
  47763. */
  47764. bytesOfKeyValueData: number;
  47765. /**
  47766. * Gets the load type
  47767. */
  47768. loadType: number;
  47769. /**
  47770. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47771. */
  47772. isInvalid: boolean;
  47773. /**
  47774. * Creates a new KhronosTextureContainer
  47775. * @param arrayBuffer contents of the KTX container file
  47776. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47777. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47778. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47779. */
  47780. constructor(
  47781. /** contents of the KTX container file */
  47782. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47783. /**
  47784. * Uploads KTX content to a Babylon Texture.
  47785. * It is assumed that the texture has already been created & is currently bound
  47786. * @hidden
  47787. */
  47788. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47789. private _upload2DCompressedLevels;
  47790. }
  47791. }
  47792. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  47793. import { Nullable } from "babylonjs/types";
  47794. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47795. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47796. /**
  47797. * Implementation of the KTX Texture Loader.
  47798. * @hidden
  47799. */
  47800. export class _KTXTextureLoader implements IInternalTextureLoader {
  47801. /**
  47802. * Defines wether the loader supports cascade loading the different faces.
  47803. */
  47804. readonly supportCascades: boolean;
  47805. /**
  47806. * This returns if the loader support the current file information.
  47807. * @param extension defines the file extension of the file being loaded
  47808. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47809. * @param fallback defines the fallback internal texture if any
  47810. * @param isBase64 defines whether the texture is encoded as a base64
  47811. * @param isBuffer defines whether the texture data are stored as a buffer
  47812. * @returns true if the loader can load the specified file
  47813. */
  47814. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47815. /**
  47816. * Transform the url before loading if required.
  47817. * @param rootUrl the url of the texture
  47818. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47819. * @returns the transformed texture
  47820. */
  47821. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47822. /**
  47823. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47824. * @param rootUrl the url of the texture
  47825. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47826. * @returns the fallback texture
  47827. */
  47828. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47829. /**
  47830. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47831. * @param data contains the texture data
  47832. * @param texture defines the BabylonJS internal texture
  47833. * @param createPolynomials will be true if polynomials have been requested
  47834. * @param onLoad defines the callback to trigger once the texture is ready
  47835. * @param onError defines the callback to trigger in case of error
  47836. */
  47837. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47838. /**
  47839. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47840. * @param data contains the texture data
  47841. * @param texture defines the BabylonJS internal texture
  47842. * @param callback defines the method to call once ready to upload
  47843. */
  47844. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47845. }
  47846. }
  47847. declare module "babylonjs/Helpers/sceneHelpers" {
  47848. import { Nullable } from "babylonjs/types";
  47849. import { Mesh } from "babylonjs/Meshes/mesh";
  47850. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47851. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  47852. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  47853. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  47854. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  47855. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  47856. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  47857. import "babylonjs/Meshes/Builders/boxBuilder";
  47858. /** @hidden */
  47859. export var _forceSceneHelpersToBundle: boolean;
  47860. module "babylonjs/scene" {
  47861. interface Scene {
  47862. /**
  47863. * Creates a default light for the scene.
  47864. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47865. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47866. */
  47867. createDefaultLight(replace?: boolean): void;
  47868. /**
  47869. * Creates a default camera for the scene.
  47870. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47871. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47872. * @param replace has default false, when true replaces the active camera in the scene
  47873. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47874. */
  47875. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47876. /**
  47877. * Creates a default camera and a default light.
  47878. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47879. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47880. * @param replace has the default false, when true replaces the active camera/light in the scene
  47881. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47882. */
  47883. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47884. /**
  47885. * Creates a new sky box
  47886. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47887. * @param environmentTexture defines the texture to use as environment texture
  47888. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47889. * @param scale defines the overall scale of the skybox
  47890. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47891. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47892. * @returns a new mesh holding the sky box
  47893. */
  47894. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47895. /**
  47896. * Creates a new environment
  47897. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47898. * @param options defines the options you can use to configure the environment
  47899. * @returns the new EnvironmentHelper
  47900. */
  47901. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47902. /**
  47903. * Creates a new VREXperienceHelper
  47904. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47905. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47906. * @returns a new VREXperienceHelper
  47907. */
  47908. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47909. /**
  47910. * Creates a new XREXperienceHelper
  47911. * @see http://doc.babylonjs.com/how_to/webxr
  47912. * @returns a promise for a new XREXperienceHelper
  47913. */
  47914. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  47915. }
  47916. }
  47917. }
  47918. declare module "babylonjs/Helpers/videoDome" {
  47919. import { Scene } from "babylonjs/scene";
  47920. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47921. import { Mesh } from "babylonjs/Meshes/mesh";
  47922. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  47923. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47924. import "babylonjs/Meshes/Builders/sphereBuilder";
  47925. /**
  47926. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47927. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47928. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47929. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47930. */
  47931. export class VideoDome extends TransformNode {
  47932. /**
  47933. * Define the video source as a Monoscopic panoramic 360 video.
  47934. */
  47935. static readonly MODE_MONOSCOPIC: number;
  47936. /**
  47937. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47938. */
  47939. static readonly MODE_TOPBOTTOM: number;
  47940. /**
  47941. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47942. */
  47943. static readonly MODE_SIDEBYSIDE: number;
  47944. private _useDirectMapping;
  47945. /**
  47946. * The video texture being displayed on the sphere
  47947. */
  47948. protected _videoTexture: VideoTexture;
  47949. /**
  47950. * Gets the video texture being displayed on the sphere
  47951. */
  47952. readonly videoTexture: VideoTexture;
  47953. /**
  47954. * The skybox material
  47955. */
  47956. protected _material: BackgroundMaterial;
  47957. /**
  47958. * The surface used for the skybox
  47959. */
  47960. protected _mesh: Mesh;
  47961. /**
  47962. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47963. * Also see the options.resolution property.
  47964. */
  47965. fovMultiplier: number;
  47966. private _videoMode;
  47967. /**
  47968. * Gets or set the current video mode for the video. It can be:
  47969. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47970. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47971. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47972. */
  47973. videoMode: number;
  47974. /**
  47975. * Oberserver used in Stereoscopic VR Mode.
  47976. */
  47977. private _onBeforeCameraRenderObserver;
  47978. /**
  47979. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  47980. * @param name Element's name, child elements will append suffixes for their own names.
  47981. * @param urlsOrVideo defines the url(s) or the video element to use
  47982. * @param options An object containing optional or exposed sub element properties
  47983. */
  47984. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47985. resolution?: number;
  47986. clickToPlay?: boolean;
  47987. autoPlay?: boolean;
  47988. loop?: boolean;
  47989. size?: number;
  47990. poster?: string;
  47991. faceForward?: boolean;
  47992. useDirectMapping?: boolean;
  47993. }, scene: Scene);
  47994. private _changeVideoMode;
  47995. /**
  47996. * Releases resources associated with this node.
  47997. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47998. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47999. */
  48000. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48001. }
  48002. }
  48003. declare module "babylonjs/Helpers/index" {
  48004. export * from "babylonjs/Helpers/environmentHelper";
  48005. export * from "babylonjs/Helpers/photoDome";
  48006. export * from "babylonjs/Helpers/sceneHelpers";
  48007. export * from "babylonjs/Helpers/videoDome";
  48008. }
  48009. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48010. import { PerfCounter } from "babylonjs/Misc/tools";
  48011. import { IDisposable } from "babylonjs/scene";
  48012. import { Engine } from "babylonjs/Engines/engine";
  48013. /**
  48014. * This class can be used to get instrumentation data from a Babylon engine
  48015. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48016. */
  48017. export class EngineInstrumentation implements IDisposable {
  48018. /**
  48019. * Define the instrumented engine.
  48020. */
  48021. engine: Engine;
  48022. private _captureGPUFrameTime;
  48023. private _gpuFrameTimeToken;
  48024. private _gpuFrameTime;
  48025. private _captureShaderCompilationTime;
  48026. private _shaderCompilationTime;
  48027. private _onBeginFrameObserver;
  48028. private _onEndFrameObserver;
  48029. private _onBeforeShaderCompilationObserver;
  48030. private _onAfterShaderCompilationObserver;
  48031. /**
  48032. * Gets the perf counter used for GPU frame time
  48033. */
  48034. readonly gpuFrameTimeCounter: PerfCounter;
  48035. /**
  48036. * Gets the GPU frame time capture status
  48037. */
  48038. /**
  48039. * Enable or disable the GPU frame time capture
  48040. */
  48041. captureGPUFrameTime: boolean;
  48042. /**
  48043. * Gets the perf counter used for shader compilation time
  48044. */
  48045. readonly shaderCompilationTimeCounter: PerfCounter;
  48046. /**
  48047. * Gets the shader compilation time capture status
  48048. */
  48049. /**
  48050. * Enable or disable the shader compilation time capture
  48051. */
  48052. captureShaderCompilationTime: boolean;
  48053. /**
  48054. * Instantiates a new engine instrumentation.
  48055. * This class can be used to get instrumentation data from a Babylon engine
  48056. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48057. * @param engine Defines the engine to instrument
  48058. */
  48059. constructor(
  48060. /**
  48061. * Define the instrumented engine.
  48062. */
  48063. engine: Engine);
  48064. /**
  48065. * Dispose and release associated resources.
  48066. */
  48067. dispose(): void;
  48068. }
  48069. }
  48070. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48071. import { PerfCounter } from "babylonjs/Misc/tools";
  48072. import { Scene, IDisposable } from "babylonjs/scene";
  48073. /**
  48074. * This class can be used to get instrumentation data from a Babylon engine
  48075. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48076. */
  48077. export class SceneInstrumentation implements IDisposable {
  48078. /**
  48079. * Defines the scene to instrument
  48080. */
  48081. scene: Scene;
  48082. private _captureActiveMeshesEvaluationTime;
  48083. private _activeMeshesEvaluationTime;
  48084. private _captureRenderTargetsRenderTime;
  48085. private _renderTargetsRenderTime;
  48086. private _captureFrameTime;
  48087. private _frameTime;
  48088. private _captureRenderTime;
  48089. private _renderTime;
  48090. private _captureInterFrameTime;
  48091. private _interFrameTime;
  48092. private _captureParticlesRenderTime;
  48093. private _particlesRenderTime;
  48094. private _captureSpritesRenderTime;
  48095. private _spritesRenderTime;
  48096. private _capturePhysicsTime;
  48097. private _physicsTime;
  48098. private _captureAnimationsTime;
  48099. private _animationsTime;
  48100. private _captureCameraRenderTime;
  48101. private _cameraRenderTime;
  48102. private _onBeforeActiveMeshesEvaluationObserver;
  48103. private _onAfterActiveMeshesEvaluationObserver;
  48104. private _onBeforeRenderTargetsRenderObserver;
  48105. private _onAfterRenderTargetsRenderObserver;
  48106. private _onAfterRenderObserver;
  48107. private _onBeforeDrawPhaseObserver;
  48108. private _onAfterDrawPhaseObserver;
  48109. private _onBeforeAnimationsObserver;
  48110. private _onBeforeParticlesRenderingObserver;
  48111. private _onAfterParticlesRenderingObserver;
  48112. private _onBeforeSpritesRenderingObserver;
  48113. private _onAfterSpritesRenderingObserver;
  48114. private _onBeforePhysicsObserver;
  48115. private _onAfterPhysicsObserver;
  48116. private _onAfterAnimationsObserver;
  48117. private _onBeforeCameraRenderObserver;
  48118. private _onAfterCameraRenderObserver;
  48119. /**
  48120. * Gets the perf counter used for active meshes evaluation time
  48121. */
  48122. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48123. /**
  48124. * Gets the active meshes evaluation time capture status
  48125. */
  48126. /**
  48127. * Enable or disable the active meshes evaluation time capture
  48128. */
  48129. captureActiveMeshesEvaluationTime: boolean;
  48130. /**
  48131. * Gets the perf counter used for render targets render time
  48132. */
  48133. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48134. /**
  48135. * Gets the render targets render time capture status
  48136. */
  48137. /**
  48138. * Enable or disable the render targets render time capture
  48139. */
  48140. captureRenderTargetsRenderTime: boolean;
  48141. /**
  48142. * Gets the perf counter used for particles render time
  48143. */
  48144. readonly particlesRenderTimeCounter: PerfCounter;
  48145. /**
  48146. * Gets the particles render time capture status
  48147. */
  48148. /**
  48149. * Enable or disable the particles render time capture
  48150. */
  48151. captureParticlesRenderTime: boolean;
  48152. /**
  48153. * Gets the perf counter used for sprites render time
  48154. */
  48155. readonly spritesRenderTimeCounter: PerfCounter;
  48156. /**
  48157. * Gets the sprites render time capture status
  48158. */
  48159. /**
  48160. * Enable or disable the sprites render time capture
  48161. */
  48162. captureSpritesRenderTime: boolean;
  48163. /**
  48164. * Gets the perf counter used for physics time
  48165. */
  48166. readonly physicsTimeCounter: PerfCounter;
  48167. /**
  48168. * Gets the physics time capture status
  48169. */
  48170. /**
  48171. * Enable or disable the physics time capture
  48172. */
  48173. capturePhysicsTime: boolean;
  48174. /**
  48175. * Gets the perf counter used for animations time
  48176. */
  48177. readonly animationsTimeCounter: PerfCounter;
  48178. /**
  48179. * Gets the animations time capture status
  48180. */
  48181. /**
  48182. * Enable or disable the animations time capture
  48183. */
  48184. captureAnimationsTime: boolean;
  48185. /**
  48186. * Gets the perf counter used for frame time capture
  48187. */
  48188. readonly frameTimeCounter: PerfCounter;
  48189. /**
  48190. * Gets the frame time capture status
  48191. */
  48192. /**
  48193. * Enable or disable the frame time capture
  48194. */
  48195. captureFrameTime: boolean;
  48196. /**
  48197. * Gets the perf counter used for inter-frames time capture
  48198. */
  48199. readonly interFrameTimeCounter: PerfCounter;
  48200. /**
  48201. * Gets the inter-frames time capture status
  48202. */
  48203. /**
  48204. * Enable or disable the inter-frames time capture
  48205. */
  48206. captureInterFrameTime: boolean;
  48207. /**
  48208. * Gets the perf counter used for render time capture
  48209. */
  48210. readonly renderTimeCounter: PerfCounter;
  48211. /**
  48212. * Gets the render time capture status
  48213. */
  48214. /**
  48215. * Enable or disable the render time capture
  48216. */
  48217. captureRenderTime: boolean;
  48218. /**
  48219. * Gets the perf counter used for camera render time capture
  48220. */
  48221. readonly cameraRenderTimeCounter: PerfCounter;
  48222. /**
  48223. * Gets the camera render time capture status
  48224. */
  48225. /**
  48226. * Enable or disable the camera render time capture
  48227. */
  48228. captureCameraRenderTime: boolean;
  48229. /**
  48230. * Gets the perf counter used for draw calls
  48231. */
  48232. readonly drawCallsCounter: PerfCounter;
  48233. /**
  48234. * Instantiates a new scene instrumentation.
  48235. * This class can be used to get instrumentation data from a Babylon engine
  48236. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48237. * @param scene Defines the scene to instrument
  48238. */
  48239. constructor(
  48240. /**
  48241. * Defines the scene to instrument
  48242. */
  48243. scene: Scene);
  48244. /**
  48245. * Dispose and release associated resources.
  48246. */
  48247. dispose(): void;
  48248. }
  48249. }
  48250. declare module "babylonjs/Instrumentation/index" {
  48251. export * from "babylonjs/Instrumentation/engineInstrumentation";
  48252. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  48253. export * from "babylonjs/Instrumentation/timeToken";
  48254. }
  48255. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  48256. /** @hidden */
  48257. export var glowMapGenerationPixelShader: {
  48258. name: string;
  48259. shader: string;
  48260. };
  48261. }
  48262. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  48263. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48264. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48265. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48266. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48267. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48268. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48269. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48270. /** @hidden */
  48271. export var glowMapGenerationVertexShader: {
  48272. name: string;
  48273. shader: string;
  48274. };
  48275. }
  48276. declare module "babylonjs/Layers/effectLayer" {
  48277. import { Observable } from "babylonjs/Misc/observable";
  48278. import { Nullable } from "babylonjs/types";
  48279. import { Camera } from "babylonjs/Cameras/camera";
  48280. import { Scene } from "babylonjs/scene";
  48281. import { Color4, ISize } from "babylonjs/Maths/math";
  48282. import { Engine } from "babylonjs/Engines/engine";
  48283. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48285. import { Mesh } from "babylonjs/Meshes/mesh";
  48286. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48287. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48288. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48289. import { Effect } from "babylonjs/Materials/effect";
  48290. import { Material } from "babylonjs/Materials/material";
  48291. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48292. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48293. /**
  48294. * Effect layer options. This helps customizing the behaviour
  48295. * of the effect layer.
  48296. */
  48297. export interface IEffectLayerOptions {
  48298. /**
  48299. * Multiplication factor apply to the canvas size to compute the render target size
  48300. * used to generated the objects (the smaller the faster).
  48301. */
  48302. mainTextureRatio: number;
  48303. /**
  48304. * Enforces a fixed size texture to ensure effect stability across devices.
  48305. */
  48306. mainTextureFixedSize?: number;
  48307. /**
  48308. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48309. */
  48310. alphaBlendingMode: number;
  48311. /**
  48312. * The camera attached to the layer.
  48313. */
  48314. camera: Nullable<Camera>;
  48315. /**
  48316. * The rendering group to draw the layer in.
  48317. */
  48318. renderingGroupId: number;
  48319. }
  48320. /**
  48321. * The effect layer Helps adding post process effect blended with the main pass.
  48322. *
  48323. * This can be for instance use to generate glow or higlight effects on the scene.
  48324. *
  48325. * The effect layer class can not be used directly and is intented to inherited from to be
  48326. * customized per effects.
  48327. */
  48328. export abstract class EffectLayer {
  48329. private _vertexBuffers;
  48330. private _indexBuffer;
  48331. private _cachedDefines;
  48332. private _effectLayerMapGenerationEffect;
  48333. private _effectLayerOptions;
  48334. private _mergeEffect;
  48335. protected _scene: Scene;
  48336. protected _engine: Engine;
  48337. protected _maxSize: number;
  48338. protected _mainTextureDesiredSize: ISize;
  48339. protected _mainTexture: RenderTargetTexture;
  48340. protected _shouldRender: boolean;
  48341. protected _postProcesses: PostProcess[];
  48342. protected _textures: BaseTexture[];
  48343. protected _emissiveTextureAndColor: {
  48344. texture: Nullable<BaseTexture>;
  48345. color: Color4;
  48346. };
  48347. /**
  48348. * The name of the layer
  48349. */
  48350. name: string;
  48351. /**
  48352. * The clear color of the texture used to generate the glow map.
  48353. */
  48354. neutralColor: Color4;
  48355. /**
  48356. * Specifies wether the highlight layer is enabled or not.
  48357. */
  48358. isEnabled: boolean;
  48359. /**
  48360. * Gets the camera attached to the layer.
  48361. */
  48362. readonly camera: Nullable<Camera>;
  48363. /**
  48364. * Gets the rendering group id the layer should render in.
  48365. */
  48366. readonly renderingGroupId: number;
  48367. /**
  48368. * An event triggered when the effect layer has been disposed.
  48369. */
  48370. onDisposeObservable: Observable<EffectLayer>;
  48371. /**
  48372. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48373. */
  48374. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48375. /**
  48376. * An event triggered when the generated texture is being merged in the scene.
  48377. */
  48378. onBeforeComposeObservable: Observable<EffectLayer>;
  48379. /**
  48380. * An event triggered when the generated texture has been merged in the scene.
  48381. */
  48382. onAfterComposeObservable: Observable<EffectLayer>;
  48383. /**
  48384. * An event triggered when the efffect layer changes its size.
  48385. */
  48386. onSizeChangedObservable: Observable<EffectLayer>;
  48387. /** @hidden */
  48388. static _SceneComponentInitialization: (scene: Scene) => void;
  48389. /**
  48390. * Instantiates a new effect Layer and references it in the scene.
  48391. * @param name The name of the layer
  48392. * @param scene The scene to use the layer in
  48393. */
  48394. constructor(
  48395. /** The Friendly of the effect in the scene */
  48396. name: string, scene: Scene);
  48397. /**
  48398. * Get the effect name of the layer.
  48399. * @return The effect name
  48400. */
  48401. abstract getEffectName(): string;
  48402. /**
  48403. * Checks for the readiness of the element composing the layer.
  48404. * @param subMesh the mesh to check for
  48405. * @param useInstances specify wether or not to use instances to render the mesh
  48406. * @return true if ready otherwise, false
  48407. */
  48408. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48409. /**
  48410. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48411. * @returns true if the effect requires stencil during the main canvas render pass.
  48412. */
  48413. abstract needStencil(): boolean;
  48414. /**
  48415. * Create the merge effect. This is the shader use to blit the information back
  48416. * to the main canvas at the end of the scene rendering.
  48417. * @returns The effect containing the shader used to merge the effect on the main canvas
  48418. */
  48419. protected abstract _createMergeEffect(): Effect;
  48420. /**
  48421. * Creates the render target textures and post processes used in the effect layer.
  48422. */
  48423. protected abstract _createTextureAndPostProcesses(): void;
  48424. /**
  48425. * Implementation specific of rendering the generating effect on the main canvas.
  48426. * @param effect The effect used to render through
  48427. */
  48428. protected abstract _internalRender(effect: Effect): void;
  48429. /**
  48430. * Sets the required values for both the emissive texture and and the main color.
  48431. */
  48432. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48433. /**
  48434. * Free any resources and references associated to a mesh.
  48435. * Internal use
  48436. * @param mesh The mesh to free.
  48437. */
  48438. abstract _disposeMesh(mesh: Mesh): void;
  48439. /**
  48440. * Serializes this layer (Glow or Highlight for example)
  48441. * @returns a serialized layer object
  48442. */
  48443. abstract serialize?(): any;
  48444. /**
  48445. * Initializes the effect layer with the required options.
  48446. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48447. */
  48448. protected _init(options: Partial<IEffectLayerOptions>): void;
  48449. /**
  48450. * Generates the index buffer of the full screen quad blending to the main canvas.
  48451. */
  48452. private _generateIndexBuffer;
  48453. /**
  48454. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48455. */
  48456. private _genrateVertexBuffer;
  48457. /**
  48458. * Sets the main texture desired size which is the closest power of two
  48459. * of the engine canvas size.
  48460. */
  48461. private _setMainTextureSize;
  48462. /**
  48463. * Creates the main texture for the effect layer.
  48464. */
  48465. protected _createMainTexture(): void;
  48466. /**
  48467. * Adds specific effects defines.
  48468. * @param defines The defines to add specifics to.
  48469. */
  48470. protected _addCustomEffectDefines(defines: string[]): void;
  48471. /**
  48472. * Checks for the readiness of the element composing the layer.
  48473. * @param subMesh the mesh to check for
  48474. * @param useInstances specify wether or not to use instances to render the mesh
  48475. * @param emissiveTexture the associated emissive texture used to generate the glow
  48476. * @return true if ready otherwise, false
  48477. */
  48478. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48479. /**
  48480. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48481. */
  48482. render(): void;
  48483. /**
  48484. * Determine if a given mesh will be used in the current effect.
  48485. * @param mesh mesh to test
  48486. * @returns true if the mesh will be used
  48487. */
  48488. hasMesh(mesh: AbstractMesh): boolean;
  48489. /**
  48490. * Returns true if the layer contains information to display, otherwise false.
  48491. * @returns true if the glow layer should be rendered
  48492. */
  48493. shouldRender(): boolean;
  48494. /**
  48495. * Returns true if the mesh should render, otherwise false.
  48496. * @param mesh The mesh to render
  48497. * @returns true if it should render otherwise false
  48498. */
  48499. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48500. /**
  48501. * Returns true if the mesh can be rendered, otherwise false.
  48502. * @param mesh The mesh to render
  48503. * @param material The material used on the mesh
  48504. * @returns true if it can be rendered otherwise false
  48505. */
  48506. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48507. /**
  48508. * Returns true if the mesh should render, otherwise false.
  48509. * @param mesh The mesh to render
  48510. * @returns true if it should render otherwise false
  48511. */
  48512. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48513. /**
  48514. * Renders the submesh passed in parameter to the generation map.
  48515. */
  48516. protected _renderSubMesh(subMesh: SubMesh): void;
  48517. /**
  48518. * Rebuild the required buffers.
  48519. * @hidden Internal use only.
  48520. */
  48521. _rebuild(): void;
  48522. /**
  48523. * Dispose only the render target textures and post process.
  48524. */
  48525. private _disposeTextureAndPostProcesses;
  48526. /**
  48527. * Dispose the highlight layer and free resources.
  48528. */
  48529. dispose(): void;
  48530. /**
  48531. * Gets the class name of the effect layer
  48532. * @returns the string with the class name of the effect layer
  48533. */
  48534. getClassName(): string;
  48535. /**
  48536. * Creates an effect layer from parsed effect layer data
  48537. * @param parsedEffectLayer defines effect layer data
  48538. * @param scene defines the current scene
  48539. * @param rootUrl defines the root URL containing the effect layer information
  48540. * @returns a parsed effect Layer
  48541. */
  48542. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48543. }
  48544. }
  48545. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  48546. import { Scene } from "babylonjs/scene";
  48547. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48548. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48549. import { AbstractScene } from "babylonjs/abstractScene";
  48550. module "babylonjs/abstractScene" {
  48551. interface AbstractScene {
  48552. /**
  48553. * The list of effect layers (highlights/glow) added to the scene
  48554. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48555. * @see http://doc.babylonjs.com/how_to/glow_layer
  48556. */
  48557. effectLayers: Array<EffectLayer>;
  48558. /**
  48559. * Removes the given effect layer from this scene.
  48560. * @param toRemove defines the effect layer to remove
  48561. * @returns the index of the removed effect layer
  48562. */
  48563. removeEffectLayer(toRemove: EffectLayer): number;
  48564. /**
  48565. * Adds the given effect layer to this scene
  48566. * @param newEffectLayer defines the effect layer to add
  48567. */
  48568. addEffectLayer(newEffectLayer: EffectLayer): void;
  48569. }
  48570. }
  48571. /**
  48572. * Defines the layer scene component responsible to manage any effect layers
  48573. * in a given scene.
  48574. */
  48575. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48576. /**
  48577. * The component name helpfull to identify the component in the list of scene components.
  48578. */
  48579. readonly name: string;
  48580. /**
  48581. * The scene the component belongs to.
  48582. */
  48583. scene: Scene;
  48584. private _engine;
  48585. private _renderEffects;
  48586. private _needStencil;
  48587. private _previousStencilState;
  48588. /**
  48589. * Creates a new instance of the component for the given scene
  48590. * @param scene Defines the scene to register the component in
  48591. */
  48592. constructor(scene: Scene);
  48593. /**
  48594. * Registers the component in a given scene
  48595. */
  48596. register(): void;
  48597. /**
  48598. * Rebuilds the elements related to this component in case of
  48599. * context lost for instance.
  48600. */
  48601. rebuild(): void;
  48602. /**
  48603. * Serializes the component data to the specified json object
  48604. * @param serializationObject The object to serialize to
  48605. */
  48606. serialize(serializationObject: any): void;
  48607. /**
  48608. * Adds all the element from the container to the scene
  48609. * @param container the container holding the elements
  48610. */
  48611. addFromContainer(container: AbstractScene): void;
  48612. /**
  48613. * Removes all the elements in the container from the scene
  48614. * @param container contains the elements to remove
  48615. * @param dispose if the removed element should be disposed (default: false)
  48616. */
  48617. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48618. /**
  48619. * Disposes the component and the associated ressources.
  48620. */
  48621. dispose(): void;
  48622. private _isReadyForMesh;
  48623. private _renderMainTexture;
  48624. private _setStencil;
  48625. private _setStencilBack;
  48626. private _draw;
  48627. private _drawCamera;
  48628. private _drawRenderingGroup;
  48629. }
  48630. }
  48631. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  48632. /** @hidden */
  48633. export var glowMapMergePixelShader: {
  48634. name: string;
  48635. shader: string;
  48636. };
  48637. }
  48638. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  48639. /** @hidden */
  48640. export var glowMapMergeVertexShader: {
  48641. name: string;
  48642. shader: string;
  48643. };
  48644. }
  48645. declare module "babylonjs/Layers/glowLayer" {
  48646. import { Nullable } from "babylonjs/types";
  48647. import { Camera } from "babylonjs/Cameras/camera";
  48648. import { Scene } from "babylonjs/scene";
  48649. import { Color4 } from "babylonjs/Maths/math";
  48650. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48652. import { Mesh } from "babylonjs/Meshes/mesh";
  48653. import { Texture } from "babylonjs/Materials/Textures/texture";
  48654. import { Effect } from "babylonjs/Materials/effect";
  48655. import { Material } from "babylonjs/Materials/material";
  48656. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48657. import "babylonjs/Shaders/glowMapMerge.fragment";
  48658. import "babylonjs/Shaders/glowMapMerge.vertex";
  48659. import "babylonjs/Layers/effectLayerSceneComponent";
  48660. module "babylonjs/abstractScene" {
  48661. interface AbstractScene {
  48662. /**
  48663. * Return a the first highlight layer of the scene with a given name.
  48664. * @param name The name of the highlight layer to look for.
  48665. * @return The highlight layer if found otherwise null.
  48666. */
  48667. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48668. }
  48669. }
  48670. /**
  48671. * Glow layer options. This helps customizing the behaviour
  48672. * of the glow layer.
  48673. */
  48674. export interface IGlowLayerOptions {
  48675. /**
  48676. * Multiplication factor apply to the canvas size to compute the render target size
  48677. * used to generated the glowing objects (the smaller the faster).
  48678. */
  48679. mainTextureRatio: number;
  48680. /**
  48681. * Enforces a fixed size texture to ensure resize independant blur.
  48682. */
  48683. mainTextureFixedSize?: number;
  48684. /**
  48685. * How big is the kernel of the blur texture.
  48686. */
  48687. blurKernelSize: number;
  48688. /**
  48689. * The camera attached to the layer.
  48690. */
  48691. camera: Nullable<Camera>;
  48692. /**
  48693. * Enable MSAA by chosing the number of samples.
  48694. */
  48695. mainTextureSamples?: number;
  48696. /**
  48697. * The rendering group to draw the layer in.
  48698. */
  48699. renderingGroupId: number;
  48700. }
  48701. /**
  48702. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48703. *
  48704. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48705. * glowy meshes to your scene.
  48706. *
  48707. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48708. */
  48709. export class GlowLayer extends EffectLayer {
  48710. /**
  48711. * Effect Name of the layer.
  48712. */
  48713. static readonly EffectName: string;
  48714. /**
  48715. * The default blur kernel size used for the glow.
  48716. */
  48717. static DefaultBlurKernelSize: number;
  48718. /**
  48719. * The default texture size ratio used for the glow.
  48720. */
  48721. static DefaultTextureRatio: number;
  48722. /**
  48723. * Sets the kernel size of the blur.
  48724. */
  48725. /**
  48726. * Gets the kernel size of the blur.
  48727. */
  48728. blurKernelSize: number;
  48729. /**
  48730. * Sets the glow intensity.
  48731. */
  48732. /**
  48733. * Gets the glow intensity.
  48734. */
  48735. intensity: number;
  48736. private _options;
  48737. private _intensity;
  48738. private _horizontalBlurPostprocess1;
  48739. private _verticalBlurPostprocess1;
  48740. private _horizontalBlurPostprocess2;
  48741. private _verticalBlurPostprocess2;
  48742. private _blurTexture1;
  48743. private _blurTexture2;
  48744. private _postProcesses1;
  48745. private _postProcesses2;
  48746. private _includedOnlyMeshes;
  48747. private _excludedMeshes;
  48748. /**
  48749. * Callback used to let the user override the color selection on a per mesh basis
  48750. */
  48751. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48752. /**
  48753. * Callback used to let the user override the texture selection on a per mesh basis
  48754. */
  48755. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48756. /**
  48757. * Instantiates a new glow Layer and references it to the scene.
  48758. * @param name The name of the layer
  48759. * @param scene The scene to use the layer in
  48760. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48761. */
  48762. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48763. /**
  48764. * Get the effect name of the layer.
  48765. * @return The effect name
  48766. */
  48767. getEffectName(): string;
  48768. /**
  48769. * Create the merge effect. This is the shader use to blit the information back
  48770. * to the main canvas at the end of the scene rendering.
  48771. */
  48772. protected _createMergeEffect(): Effect;
  48773. /**
  48774. * Creates the render target textures and post processes used in the glow layer.
  48775. */
  48776. protected _createTextureAndPostProcesses(): void;
  48777. /**
  48778. * Checks for the readiness of the element composing the layer.
  48779. * @param subMesh the mesh to check for
  48780. * @param useInstances specify wether or not to use instances to render the mesh
  48781. * @param emissiveTexture the associated emissive texture used to generate the glow
  48782. * @return true if ready otherwise, false
  48783. */
  48784. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48785. /**
  48786. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48787. */
  48788. needStencil(): boolean;
  48789. /**
  48790. * Returns true if the mesh can be rendered, otherwise false.
  48791. * @param mesh The mesh to render
  48792. * @param material The material used on the mesh
  48793. * @returns true if it can be rendered otherwise false
  48794. */
  48795. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48796. /**
  48797. * Implementation specific of rendering the generating effect on the main canvas.
  48798. * @param effect The effect used to render through
  48799. */
  48800. protected _internalRender(effect: Effect): void;
  48801. /**
  48802. * Sets the required values for both the emissive texture and and the main color.
  48803. */
  48804. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48805. /**
  48806. * Returns true if the mesh should render, otherwise false.
  48807. * @param mesh The mesh to render
  48808. * @returns true if it should render otherwise false
  48809. */
  48810. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48811. /**
  48812. * Adds specific effects defines.
  48813. * @param defines The defines to add specifics to.
  48814. */
  48815. protected _addCustomEffectDefines(defines: string[]): void;
  48816. /**
  48817. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48818. * @param mesh The mesh to exclude from the glow layer
  48819. */
  48820. addExcludedMesh(mesh: Mesh): void;
  48821. /**
  48822. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48823. * @param mesh The mesh to remove
  48824. */
  48825. removeExcludedMesh(mesh: Mesh): void;
  48826. /**
  48827. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48828. * @param mesh The mesh to include in the glow layer
  48829. */
  48830. addIncludedOnlyMesh(mesh: Mesh): void;
  48831. /**
  48832. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48833. * @param mesh The mesh to remove
  48834. */
  48835. removeIncludedOnlyMesh(mesh: Mesh): void;
  48836. /**
  48837. * Determine if a given mesh will be used in the glow layer
  48838. * @param mesh The mesh to test
  48839. * @returns true if the mesh will be highlighted by the current glow layer
  48840. */
  48841. hasMesh(mesh: AbstractMesh): boolean;
  48842. /**
  48843. * Free any resources and references associated to a mesh.
  48844. * Internal use
  48845. * @param mesh The mesh to free.
  48846. * @hidden
  48847. */
  48848. _disposeMesh(mesh: Mesh): void;
  48849. /**
  48850. * Gets the class name of the effect layer
  48851. * @returns the string with the class name of the effect layer
  48852. */
  48853. getClassName(): string;
  48854. /**
  48855. * Serializes this glow layer
  48856. * @returns a serialized glow layer object
  48857. */
  48858. serialize(): any;
  48859. /**
  48860. * Creates a Glow Layer from parsed glow layer data
  48861. * @param parsedGlowLayer defines glow layer data
  48862. * @param scene defines the current scene
  48863. * @param rootUrl defines the root URL containing the glow layer information
  48864. * @returns a parsed Glow Layer
  48865. */
  48866. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48867. }
  48868. }
  48869. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  48870. /** @hidden */
  48871. export var glowBlurPostProcessPixelShader: {
  48872. name: string;
  48873. shader: string;
  48874. };
  48875. }
  48876. declare module "babylonjs/Layers/highlightLayer" {
  48877. import { Observable } from "babylonjs/Misc/observable";
  48878. import { Nullable } from "babylonjs/types";
  48879. import { Camera } from "babylonjs/Cameras/camera";
  48880. import { Scene } from "babylonjs/scene";
  48881. import { Color3, Color4 } from "babylonjs/Maths/math";
  48882. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48884. import { Mesh } from "babylonjs/Meshes/mesh";
  48885. import { Effect } from "babylonjs/Materials/effect";
  48886. import { Material } from "babylonjs/Materials/material";
  48887. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48888. import "babylonjs/Shaders/glowMapMerge.fragment";
  48889. import "babylonjs/Shaders/glowMapMerge.vertex";
  48890. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  48891. module "babylonjs/abstractScene" {
  48892. interface AbstractScene {
  48893. /**
  48894. * Return a the first highlight layer of the scene with a given name.
  48895. * @param name The name of the highlight layer to look for.
  48896. * @return The highlight layer if found otherwise null.
  48897. */
  48898. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48899. }
  48900. }
  48901. /**
  48902. * Highlight layer options. This helps customizing the behaviour
  48903. * of the highlight layer.
  48904. */
  48905. export interface IHighlightLayerOptions {
  48906. /**
  48907. * Multiplication factor apply to the canvas size to compute the render target size
  48908. * used to generated the glowing objects (the smaller the faster).
  48909. */
  48910. mainTextureRatio: number;
  48911. /**
  48912. * Enforces a fixed size texture to ensure resize independant blur.
  48913. */
  48914. mainTextureFixedSize?: number;
  48915. /**
  48916. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48917. * of the picture to blur (the smaller the faster).
  48918. */
  48919. blurTextureSizeRatio: number;
  48920. /**
  48921. * How big in texel of the blur texture is the vertical blur.
  48922. */
  48923. blurVerticalSize: number;
  48924. /**
  48925. * How big in texel of the blur texture is the horizontal blur.
  48926. */
  48927. blurHorizontalSize: number;
  48928. /**
  48929. * Alpha blending mode used to apply the blur. Default is combine.
  48930. */
  48931. alphaBlendingMode: number;
  48932. /**
  48933. * The camera attached to the layer.
  48934. */
  48935. camera: Nullable<Camera>;
  48936. /**
  48937. * Should we display highlight as a solid stroke?
  48938. */
  48939. isStroke?: boolean;
  48940. /**
  48941. * The rendering group to draw the layer in.
  48942. */
  48943. renderingGroupId: number;
  48944. }
  48945. /**
  48946. * The highlight layer Helps adding a glow effect around a mesh.
  48947. *
  48948. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48949. * glowy meshes to your scene.
  48950. *
  48951. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48952. */
  48953. export class HighlightLayer extends EffectLayer {
  48954. name: string;
  48955. /**
  48956. * Effect Name of the highlight layer.
  48957. */
  48958. static readonly EffectName: string;
  48959. /**
  48960. * The neutral color used during the preparation of the glow effect.
  48961. * This is black by default as the blend operation is a blend operation.
  48962. */
  48963. static NeutralColor: Color4;
  48964. /**
  48965. * Stencil value used for glowing meshes.
  48966. */
  48967. static GlowingMeshStencilReference: number;
  48968. /**
  48969. * Stencil value used for the other meshes in the scene.
  48970. */
  48971. static NormalMeshStencilReference: number;
  48972. /**
  48973. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48974. */
  48975. innerGlow: boolean;
  48976. /**
  48977. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48978. */
  48979. outerGlow: boolean;
  48980. /**
  48981. * Specifies the horizontal size of the blur.
  48982. */
  48983. /**
  48984. * Gets the horizontal size of the blur.
  48985. */
  48986. blurHorizontalSize: number;
  48987. /**
  48988. * Specifies the vertical size of the blur.
  48989. */
  48990. /**
  48991. * Gets the vertical size of the blur.
  48992. */
  48993. blurVerticalSize: number;
  48994. /**
  48995. * An event triggered when the highlight layer is being blurred.
  48996. */
  48997. onBeforeBlurObservable: Observable<HighlightLayer>;
  48998. /**
  48999. * An event triggered when the highlight layer has been blurred.
  49000. */
  49001. onAfterBlurObservable: Observable<HighlightLayer>;
  49002. private _instanceGlowingMeshStencilReference;
  49003. private _options;
  49004. private _downSamplePostprocess;
  49005. private _horizontalBlurPostprocess;
  49006. private _verticalBlurPostprocess;
  49007. private _blurTexture;
  49008. private _meshes;
  49009. private _excludedMeshes;
  49010. /**
  49011. * Instantiates a new highlight Layer and references it to the scene..
  49012. * @param name The name of the layer
  49013. * @param scene The scene to use the layer in
  49014. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49015. */
  49016. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49017. /**
  49018. * Get the effect name of the layer.
  49019. * @return The effect name
  49020. */
  49021. getEffectName(): string;
  49022. /**
  49023. * Create the merge effect. This is the shader use to blit the information back
  49024. * to the main canvas at the end of the scene rendering.
  49025. */
  49026. protected _createMergeEffect(): Effect;
  49027. /**
  49028. * Creates the render target textures and post processes used in the highlight layer.
  49029. */
  49030. protected _createTextureAndPostProcesses(): void;
  49031. /**
  49032. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49033. */
  49034. needStencil(): boolean;
  49035. /**
  49036. * Checks for the readiness of the element composing the layer.
  49037. * @param subMesh the mesh to check for
  49038. * @param useInstances specify wether or not to use instances to render the mesh
  49039. * @param emissiveTexture the associated emissive texture used to generate the glow
  49040. * @return true if ready otherwise, false
  49041. */
  49042. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49043. /**
  49044. * Implementation specific of rendering the generating effect on the main canvas.
  49045. * @param effect The effect used to render through
  49046. */
  49047. protected _internalRender(effect: Effect): void;
  49048. /**
  49049. * Returns true if the layer contains information to display, otherwise false.
  49050. */
  49051. shouldRender(): boolean;
  49052. /**
  49053. * Returns true if the mesh should render, otherwise false.
  49054. * @param mesh The mesh to render
  49055. * @returns true if it should render otherwise false
  49056. */
  49057. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49058. /**
  49059. * Sets the required values for both the emissive texture and and the main color.
  49060. */
  49061. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49062. /**
  49063. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49064. * @param mesh The mesh to exclude from the highlight layer
  49065. */
  49066. addExcludedMesh(mesh: Mesh): void;
  49067. /**
  49068. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49069. * @param mesh The mesh to highlight
  49070. */
  49071. removeExcludedMesh(mesh: Mesh): void;
  49072. /**
  49073. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49074. * @param mesh mesh to test
  49075. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49076. */
  49077. hasMesh(mesh: AbstractMesh): boolean;
  49078. /**
  49079. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49080. * @param mesh The mesh to highlight
  49081. * @param color The color of the highlight
  49082. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49083. */
  49084. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49085. /**
  49086. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49087. * @param mesh The mesh to highlight
  49088. */
  49089. removeMesh(mesh: Mesh): void;
  49090. /**
  49091. * Force the stencil to the normal expected value for none glowing parts
  49092. */
  49093. private _defaultStencilReference;
  49094. /**
  49095. * Free any resources and references associated to a mesh.
  49096. * Internal use
  49097. * @param mesh The mesh to free.
  49098. * @hidden
  49099. */
  49100. _disposeMesh(mesh: Mesh): void;
  49101. /**
  49102. * Dispose the highlight layer and free resources.
  49103. */
  49104. dispose(): void;
  49105. /**
  49106. * Gets the class name of the effect layer
  49107. * @returns the string with the class name of the effect layer
  49108. */
  49109. getClassName(): string;
  49110. /**
  49111. * Serializes this Highlight layer
  49112. * @returns a serialized Highlight layer object
  49113. */
  49114. serialize(): any;
  49115. /**
  49116. * Creates a Highlight layer from parsed Highlight layer data
  49117. * @param parsedHightlightLayer defines the Highlight layer data
  49118. * @param scene defines the current scene
  49119. * @param rootUrl defines the root URL containing the Highlight layer information
  49120. * @returns a parsed Highlight layer
  49121. */
  49122. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49123. }
  49124. }
  49125. declare module "babylonjs/Layers/index" {
  49126. export * from "babylonjs/Layers/effectLayer";
  49127. export * from "babylonjs/Layers/effectLayerSceneComponent";
  49128. export * from "babylonjs/Layers/glowLayer";
  49129. export * from "babylonjs/Layers/highlightLayer";
  49130. export * from "babylonjs/Layers/layer";
  49131. export * from "babylonjs/Layers/layerSceneComponent";
  49132. }
  49133. declare module "babylonjs/Shaders/lensFlare.fragment" {
  49134. /** @hidden */
  49135. export var lensFlarePixelShader: {
  49136. name: string;
  49137. shader: string;
  49138. };
  49139. }
  49140. declare module "babylonjs/Shaders/lensFlare.vertex" {
  49141. /** @hidden */
  49142. export var lensFlareVertexShader: {
  49143. name: string;
  49144. shader: string;
  49145. };
  49146. }
  49147. declare module "babylonjs/LensFlares/lensFlareSystem" {
  49148. import { Scene } from "babylonjs/scene";
  49149. import { Vector3, Viewport } from "babylonjs/Maths/math";
  49150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49151. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  49152. import "babylonjs/Shaders/lensFlare.fragment";
  49153. import "babylonjs/Shaders/lensFlare.vertex";
  49154. /**
  49155. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49156. * It is usually composed of several `lensFlare`.
  49157. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49158. */
  49159. export class LensFlareSystem {
  49160. /**
  49161. * Define the name of the lens flare system
  49162. */
  49163. name: string;
  49164. /**
  49165. * List of lens flares used in this system.
  49166. */
  49167. lensFlares: LensFlare[];
  49168. /**
  49169. * Define a limit from the border the lens flare can be visible.
  49170. */
  49171. borderLimit: number;
  49172. /**
  49173. * Define a viewport border we do not want to see the lens flare in.
  49174. */
  49175. viewportBorder: number;
  49176. /**
  49177. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49178. */
  49179. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49180. /**
  49181. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49182. */
  49183. layerMask: number;
  49184. /**
  49185. * Define the id of the lens flare system in the scene.
  49186. * (equal to name by default)
  49187. */
  49188. id: string;
  49189. private _scene;
  49190. private _emitter;
  49191. private _vertexBuffers;
  49192. private _indexBuffer;
  49193. private _effect;
  49194. private _positionX;
  49195. private _positionY;
  49196. private _isEnabled;
  49197. /** @hidden */
  49198. static _SceneComponentInitialization: (scene: Scene) => void;
  49199. /**
  49200. * Instantiates a lens flare system.
  49201. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49202. * It is usually composed of several `lensFlare`.
  49203. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49204. * @param name Define the name of the lens flare system in the scene
  49205. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49206. * @param scene Define the scene the lens flare system belongs to
  49207. */
  49208. constructor(
  49209. /**
  49210. * Define the name of the lens flare system
  49211. */
  49212. name: string, emitter: any, scene: Scene);
  49213. /**
  49214. * Define if the lens flare system is enabled.
  49215. */
  49216. isEnabled: boolean;
  49217. /**
  49218. * Get the scene the effects belongs to.
  49219. * @returns the scene holding the lens flare system
  49220. */
  49221. getScene(): Scene;
  49222. /**
  49223. * Get the emitter of the lens flare system.
  49224. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49225. * @returns the emitter of the lens flare system
  49226. */
  49227. getEmitter(): any;
  49228. /**
  49229. * Set the emitter of the lens flare system.
  49230. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49231. * @param newEmitter Define the new emitter of the system
  49232. */
  49233. setEmitter(newEmitter: any): void;
  49234. /**
  49235. * Get the lens flare system emitter position.
  49236. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49237. * @returns the position
  49238. */
  49239. getEmitterPosition(): Vector3;
  49240. /**
  49241. * @hidden
  49242. */
  49243. computeEffectivePosition(globalViewport: Viewport): boolean;
  49244. /** @hidden */
  49245. _isVisible(): boolean;
  49246. /**
  49247. * @hidden
  49248. */
  49249. render(): boolean;
  49250. /**
  49251. * Dispose and release the lens flare with its associated resources.
  49252. */
  49253. dispose(): void;
  49254. /**
  49255. * Parse a lens flare system from a JSON repressentation
  49256. * @param parsedLensFlareSystem Define the JSON to parse
  49257. * @param scene Define the scene the parsed system should be instantiated in
  49258. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49259. * @returns the parsed system
  49260. */
  49261. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49262. /**
  49263. * Serialize the current Lens Flare System into a JSON representation.
  49264. * @returns the serialized JSON
  49265. */
  49266. serialize(): any;
  49267. }
  49268. }
  49269. declare module "babylonjs/LensFlares/lensFlare" {
  49270. import { Nullable } from "babylonjs/types";
  49271. import { Color3 } from "babylonjs/Maths/math";
  49272. import { Texture } from "babylonjs/Materials/Textures/texture";
  49273. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49274. /**
  49275. * This represents one of the lens effect in a `lensFlareSystem`.
  49276. * It controls one of the indiviual texture used in the effect.
  49277. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49278. */
  49279. export class LensFlare {
  49280. /**
  49281. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49282. */
  49283. size: number;
  49284. /**
  49285. * 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.
  49286. */
  49287. position: number;
  49288. /**
  49289. * Define the lens color.
  49290. */
  49291. color: Color3;
  49292. /**
  49293. * Define the lens texture.
  49294. */
  49295. texture: Nullable<Texture>;
  49296. /**
  49297. * Define the alpha mode to render this particular lens.
  49298. */
  49299. alphaMode: number;
  49300. private _system;
  49301. /**
  49302. * Creates a new Lens Flare.
  49303. * This represents one of the lens effect in a `lensFlareSystem`.
  49304. * It controls one of the indiviual texture used in the effect.
  49305. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49306. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49307. * @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.
  49308. * @param color Define the lens color
  49309. * @param imgUrl Define the lens texture url
  49310. * @param system Define the `lensFlareSystem` this flare is part of
  49311. * @returns The newly created Lens Flare
  49312. */
  49313. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49314. /**
  49315. * Instantiates a new Lens Flare.
  49316. * This represents one of the lens effect in a `lensFlareSystem`.
  49317. * It controls one of the indiviual texture used in the effect.
  49318. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49319. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49320. * @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.
  49321. * @param color Define the lens color
  49322. * @param imgUrl Define the lens texture url
  49323. * @param system Define the `lensFlareSystem` this flare is part of
  49324. */
  49325. constructor(
  49326. /**
  49327. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49328. */
  49329. size: number,
  49330. /**
  49331. * 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.
  49332. */
  49333. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49334. /**
  49335. * Dispose and release the lens flare with its associated resources.
  49336. */
  49337. dispose(): void;
  49338. }
  49339. }
  49340. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  49341. import { Nullable } from "babylonjs/types";
  49342. import { Scene } from "babylonjs/scene";
  49343. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49344. import { AbstractScene } from "babylonjs/abstractScene";
  49345. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49346. module "babylonjs/abstractScene" {
  49347. interface AbstractScene {
  49348. /**
  49349. * The list of lens flare system added to the scene
  49350. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49351. */
  49352. lensFlareSystems: Array<LensFlareSystem>;
  49353. /**
  49354. * Removes the given lens flare system from this scene.
  49355. * @param toRemove The lens flare system to remove
  49356. * @returns The index of the removed lens flare system
  49357. */
  49358. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49359. /**
  49360. * Adds the given lens flare system to this scene
  49361. * @param newLensFlareSystem The lens flare system to add
  49362. */
  49363. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49364. /**
  49365. * Gets a lens flare system using its name
  49366. * @param name defines the name to look for
  49367. * @returns the lens flare system or null if not found
  49368. */
  49369. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49370. /**
  49371. * Gets a lens flare system using its id
  49372. * @param id defines the id to look for
  49373. * @returns the lens flare system or null if not found
  49374. */
  49375. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49376. }
  49377. }
  49378. /**
  49379. * Defines the lens flare scene component responsible to manage any lens flares
  49380. * in a given scene.
  49381. */
  49382. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49383. /**
  49384. * The component name helpfull to identify the component in the list of scene components.
  49385. */
  49386. readonly name: string;
  49387. /**
  49388. * The scene the component belongs to.
  49389. */
  49390. scene: Scene;
  49391. /**
  49392. * Creates a new instance of the component for the given scene
  49393. * @param scene Defines the scene to register the component in
  49394. */
  49395. constructor(scene: Scene);
  49396. /**
  49397. * Registers the component in a given scene
  49398. */
  49399. register(): void;
  49400. /**
  49401. * Rebuilds the elements related to this component in case of
  49402. * context lost for instance.
  49403. */
  49404. rebuild(): void;
  49405. /**
  49406. * Adds all the element from the container to the scene
  49407. * @param container the container holding the elements
  49408. */
  49409. addFromContainer(container: AbstractScene): void;
  49410. /**
  49411. * Removes all the elements in the container from the scene
  49412. * @param container contains the elements to remove
  49413. * @param dispose if the removed element should be disposed (default: false)
  49414. */
  49415. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49416. /**
  49417. * Serializes the component data to the specified json object
  49418. * @param serializationObject The object to serialize to
  49419. */
  49420. serialize(serializationObject: any): void;
  49421. /**
  49422. * Disposes the component and the associated ressources.
  49423. */
  49424. dispose(): void;
  49425. private _draw;
  49426. }
  49427. }
  49428. declare module "babylonjs/LensFlares/index" {
  49429. export * from "babylonjs/LensFlares/lensFlare";
  49430. export * from "babylonjs/LensFlares/lensFlareSystem";
  49431. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  49432. }
  49433. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  49434. import { Scene } from "babylonjs/scene";
  49435. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49436. import { AbstractScene } from "babylonjs/abstractScene";
  49437. /**
  49438. * Defines the shadow generator component responsible to manage any shadow generators
  49439. * in a given scene.
  49440. */
  49441. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49442. /**
  49443. * The component name helpfull to identify the component in the list of scene components.
  49444. */
  49445. readonly name: string;
  49446. /**
  49447. * The scene the component belongs to.
  49448. */
  49449. scene: Scene;
  49450. /**
  49451. * Creates a new instance of the component for the given scene
  49452. * @param scene Defines the scene to register the component in
  49453. */
  49454. constructor(scene: Scene);
  49455. /**
  49456. * Registers the component in a given scene
  49457. */
  49458. register(): void;
  49459. /**
  49460. * Rebuilds the elements related to this component in case of
  49461. * context lost for instance.
  49462. */
  49463. rebuild(): void;
  49464. /**
  49465. * Serializes the component data to the specified json object
  49466. * @param serializationObject The object to serialize to
  49467. */
  49468. serialize(serializationObject: any): void;
  49469. /**
  49470. * Adds all the element from the container to the scene
  49471. * @param container the container holding the elements
  49472. */
  49473. addFromContainer(container: AbstractScene): void;
  49474. /**
  49475. * Removes all the elements in the container from the scene
  49476. * @param container contains the elements to remove
  49477. * @param dispose if the removed element should be disposed (default: false)
  49478. */
  49479. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49480. /**
  49481. * Rebuilds the elements related to this component in case of
  49482. * context lost for instance.
  49483. */
  49484. dispose(): void;
  49485. private _gatherRenderTargets;
  49486. }
  49487. }
  49488. declare module "babylonjs/Lights/Shadows/index" {
  49489. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  49490. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  49491. }
  49492. declare module "babylonjs/Lights/pointLight" {
  49493. import { Scene } from "babylonjs/scene";
  49494. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49496. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49497. import { Effect } from "babylonjs/Materials/effect";
  49498. /**
  49499. * A point light is a light defined by an unique point in world space.
  49500. * The light is emitted in every direction from this point.
  49501. * A good example of a point light is a standard light bulb.
  49502. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49503. */
  49504. export class PointLight extends ShadowLight {
  49505. private _shadowAngle;
  49506. /**
  49507. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49508. * This specifies what angle the shadow will use to be created.
  49509. *
  49510. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49511. */
  49512. /**
  49513. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49514. * This specifies what angle the shadow will use to be created.
  49515. *
  49516. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49517. */
  49518. shadowAngle: number;
  49519. /**
  49520. * Gets the direction if it has been set.
  49521. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49522. */
  49523. /**
  49524. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49525. */
  49526. direction: Vector3;
  49527. /**
  49528. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49529. * A PointLight emits the light in every direction.
  49530. * It can cast shadows.
  49531. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49532. * ```javascript
  49533. * var pointLight = new PointLight("pl", camera.position, scene);
  49534. * ```
  49535. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49536. * @param name The light friendly name
  49537. * @param position The position of the point light in the scene
  49538. * @param scene The scene the lights belongs to
  49539. */
  49540. constructor(name: string, position: Vector3, scene: Scene);
  49541. /**
  49542. * Returns the string "PointLight"
  49543. * @returns the class name
  49544. */
  49545. getClassName(): string;
  49546. /**
  49547. * Returns the integer 0.
  49548. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49549. */
  49550. getTypeID(): number;
  49551. /**
  49552. * Specifies wether or not the shadowmap should be a cube texture.
  49553. * @returns true if the shadowmap needs to be a cube texture.
  49554. */
  49555. needCube(): boolean;
  49556. /**
  49557. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49558. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49559. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49560. */
  49561. getShadowDirection(faceIndex?: number): Vector3;
  49562. /**
  49563. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49564. * - fov = PI / 2
  49565. * - aspect ratio : 1.0
  49566. * - z-near and far equal to the active camera minZ and maxZ.
  49567. * Returns the PointLight.
  49568. */
  49569. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49570. protected _buildUniformLayout(): void;
  49571. /**
  49572. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49573. * @param effect The effect to update
  49574. * @param lightIndex The index of the light in the effect to update
  49575. * @returns The point light
  49576. */
  49577. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49578. /**
  49579. * Prepares the list of defines specific to the light type.
  49580. * @param defines the list of defines
  49581. * @param lightIndex defines the index of the light for the effect
  49582. */
  49583. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49584. }
  49585. }
  49586. declare module "babylonjs/Lights/index" {
  49587. export * from "babylonjs/Lights/light";
  49588. export * from "babylonjs/Lights/shadowLight";
  49589. export * from "babylonjs/Lights/Shadows/index";
  49590. export * from "babylonjs/Lights/directionalLight";
  49591. export * from "babylonjs/Lights/hemisphericLight";
  49592. export * from "babylonjs/Lights/pointLight";
  49593. export * from "babylonjs/Lights/spotLight";
  49594. }
  49595. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  49596. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49597. /**
  49598. * Header information of HDR texture files.
  49599. */
  49600. export interface HDRInfo {
  49601. /**
  49602. * The height of the texture in pixels.
  49603. */
  49604. height: number;
  49605. /**
  49606. * The width of the texture in pixels.
  49607. */
  49608. width: number;
  49609. /**
  49610. * The index of the beginning of the data in the binary file.
  49611. */
  49612. dataPosition: number;
  49613. }
  49614. /**
  49615. * This groups tools to convert HDR texture to native colors array.
  49616. */
  49617. export class HDRTools {
  49618. private static Ldexp;
  49619. private static Rgbe2float;
  49620. private static readStringLine;
  49621. /**
  49622. * Reads header information from an RGBE texture stored in a native array.
  49623. * More information on this format are available here:
  49624. * https://en.wikipedia.org/wiki/RGBE_image_format
  49625. *
  49626. * @param uint8array The binary file stored in native array.
  49627. * @return The header information.
  49628. */
  49629. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49630. /**
  49631. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49632. * This RGBE texture needs to store the information as a panorama.
  49633. *
  49634. * More information on this format are available here:
  49635. * https://en.wikipedia.org/wiki/RGBE_image_format
  49636. *
  49637. * @param buffer The binary file stored in an array buffer.
  49638. * @param size The expected size of the extracted cubemap.
  49639. * @return The Cube Map information.
  49640. */
  49641. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49642. /**
  49643. * Returns the pixels data extracted from an RGBE texture.
  49644. * This pixels will be stored left to right up to down in the R G B order in one array.
  49645. *
  49646. * More information on this format are available here:
  49647. * https://en.wikipedia.org/wiki/RGBE_image_format
  49648. *
  49649. * @param uint8array The binary file stored in an array buffer.
  49650. * @param hdrInfo The header information of the file.
  49651. * @return The pixels data in RGB right to left up to down order.
  49652. */
  49653. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49654. private static RGBE_ReadPixels_RLE;
  49655. }
  49656. }
  49657. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  49658. import { Nullable } from "babylonjs/types";
  49659. import { Scene } from "babylonjs/scene";
  49660. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49661. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49662. /**
  49663. * This represents a texture coming from an HDR input.
  49664. *
  49665. * The only supported format is currently panorama picture stored in RGBE format.
  49666. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49667. */
  49668. export class HDRCubeTexture extends BaseTexture {
  49669. private static _facesMapping;
  49670. private _generateHarmonics;
  49671. private _noMipmap;
  49672. private _textureMatrix;
  49673. private _size;
  49674. private _onLoad;
  49675. private _onError;
  49676. /**
  49677. * The texture URL.
  49678. */
  49679. url: string;
  49680. /**
  49681. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49682. */
  49683. coordinatesMode: number;
  49684. protected _isBlocking: boolean;
  49685. /**
  49686. * Sets wether or not the texture is blocking during loading.
  49687. */
  49688. /**
  49689. * Gets wether or not the texture is blocking during loading.
  49690. */
  49691. isBlocking: boolean;
  49692. protected _rotationY: number;
  49693. /**
  49694. * Sets texture matrix rotation angle around Y axis in radians.
  49695. */
  49696. /**
  49697. * Gets texture matrix rotation angle around Y axis radians.
  49698. */
  49699. rotationY: number;
  49700. /**
  49701. * Gets or sets the center of the bounding box associated with the cube texture
  49702. * It must define where the camera used to render the texture was set
  49703. */
  49704. boundingBoxPosition: Vector3;
  49705. private _boundingBoxSize;
  49706. /**
  49707. * Gets or sets the size of the bounding box associated with the cube texture
  49708. * When defined, the cubemap will switch to local mode
  49709. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49710. * @example https://www.babylonjs-playground.com/#RNASML
  49711. */
  49712. boundingBoxSize: Vector3;
  49713. /**
  49714. * Instantiates an HDRTexture from the following parameters.
  49715. *
  49716. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49717. * @param scene The scene the texture will be used in
  49718. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49719. * @param noMipmap Forces to not generate the mipmap if true
  49720. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49721. * @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)
  49722. * @param reserved Reserved flag for internal use.
  49723. */
  49724. 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>);
  49725. /**
  49726. * Get the current class name of the texture useful for serialization or dynamic coding.
  49727. * @returns "HDRCubeTexture"
  49728. */
  49729. getClassName(): string;
  49730. /**
  49731. * Occurs when the file is raw .hdr file.
  49732. */
  49733. private loadTexture;
  49734. clone(): HDRCubeTexture;
  49735. delayLoad(): void;
  49736. /**
  49737. * Get the texture reflection matrix used to rotate/transform the reflection.
  49738. * @returns the reflection matrix
  49739. */
  49740. getReflectionTextureMatrix(): Matrix;
  49741. /**
  49742. * Set the texture reflection matrix used to rotate/transform the reflection.
  49743. * @param value Define the reflection matrix to set
  49744. */
  49745. setReflectionTextureMatrix(value: Matrix): void;
  49746. /**
  49747. * Parses a JSON representation of an HDR Texture in order to create the texture
  49748. * @param parsedTexture Define the JSON representation
  49749. * @param scene Define the scene the texture should be created in
  49750. * @param rootUrl Define the root url in case we need to load relative dependencies
  49751. * @returns the newly created texture after parsing
  49752. */
  49753. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49754. serialize(): any;
  49755. }
  49756. }
  49757. declare module "babylonjs/Physics/physicsEngine" {
  49758. import { Nullable } from "babylonjs/types";
  49759. import { Vector3 } from "babylonjs/Maths/math";
  49760. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  49761. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  49762. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  49763. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49764. /**
  49765. * Class used to control physics engine
  49766. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49767. */
  49768. export class PhysicsEngine implements IPhysicsEngine {
  49769. private _physicsPlugin;
  49770. /**
  49771. * Global value used to control the smallest number supported by the simulation
  49772. */
  49773. static Epsilon: number;
  49774. private _impostors;
  49775. private _joints;
  49776. /**
  49777. * Gets the gravity vector used by the simulation
  49778. */
  49779. gravity: Vector3;
  49780. /**
  49781. * Factory used to create the default physics plugin.
  49782. * @returns The default physics plugin
  49783. */
  49784. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49785. /**
  49786. * Creates a new Physics Engine
  49787. * @param gravity defines the gravity vector used by the simulation
  49788. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49789. */
  49790. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49791. /**
  49792. * Sets the gravity vector used by the simulation
  49793. * @param gravity defines the gravity vector to use
  49794. */
  49795. setGravity(gravity: Vector3): void;
  49796. /**
  49797. * Set the time step of the physics engine.
  49798. * Default is 1/60.
  49799. * To slow it down, enter 1/600 for example.
  49800. * To speed it up, 1/30
  49801. * @param newTimeStep defines the new timestep to apply to this world.
  49802. */
  49803. setTimeStep(newTimeStep?: number): void;
  49804. /**
  49805. * Get the time step of the physics engine.
  49806. * @returns the current time step
  49807. */
  49808. getTimeStep(): number;
  49809. /**
  49810. * Release all resources
  49811. */
  49812. dispose(): void;
  49813. /**
  49814. * Gets the name of the current physics plugin
  49815. * @returns the name of the plugin
  49816. */
  49817. getPhysicsPluginName(): string;
  49818. /**
  49819. * Adding a new impostor for the impostor tracking.
  49820. * This will be done by the impostor itself.
  49821. * @param impostor the impostor to add
  49822. */
  49823. addImpostor(impostor: PhysicsImpostor): void;
  49824. /**
  49825. * Remove an impostor from the engine.
  49826. * This impostor and its mesh will not longer be updated by the physics engine.
  49827. * @param impostor the impostor to remove
  49828. */
  49829. removeImpostor(impostor: PhysicsImpostor): void;
  49830. /**
  49831. * Add a joint to the physics engine
  49832. * @param mainImpostor defines the main impostor to which the joint is added.
  49833. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49834. * @param joint defines the joint that will connect both impostors.
  49835. */
  49836. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49837. /**
  49838. * Removes a joint from the simulation
  49839. * @param mainImpostor defines the impostor used with the joint
  49840. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49841. * @param joint defines the joint to remove
  49842. */
  49843. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49844. /**
  49845. * Called by the scene. No need to call it.
  49846. * @param delta defines the timespam between frames
  49847. */
  49848. _step(delta: number): void;
  49849. /**
  49850. * Gets the current plugin used to run the simulation
  49851. * @returns current plugin
  49852. */
  49853. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49854. /**
  49855. * Gets the list of physic impostors
  49856. * @returns an array of PhysicsImpostor
  49857. */
  49858. getImpostors(): Array<PhysicsImpostor>;
  49859. /**
  49860. * Gets the impostor for a physics enabled object
  49861. * @param object defines the object impersonated by the impostor
  49862. * @returns the PhysicsImpostor or null if not found
  49863. */
  49864. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49865. /**
  49866. * Gets the impostor for a physics body object
  49867. * @param body defines physics body used by the impostor
  49868. * @returns the PhysicsImpostor or null if not found
  49869. */
  49870. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49871. /**
  49872. * Does a raycast in the physics world
  49873. * @param from when should the ray start?
  49874. * @param to when should the ray end?
  49875. * @returns PhysicsRaycastResult
  49876. */
  49877. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49878. }
  49879. }
  49880. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  49881. import { Nullable } from "babylonjs/types";
  49882. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49884. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49885. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49886. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49887. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49888. /** @hidden */
  49889. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49890. private _useDeltaForWorldStep;
  49891. world: any;
  49892. name: string;
  49893. private _physicsMaterials;
  49894. private _fixedTimeStep;
  49895. private _cannonRaycastResult;
  49896. private _raycastResult;
  49897. private _removeAfterStep;
  49898. BJSCANNON: any;
  49899. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49900. setGravity(gravity: Vector3): void;
  49901. setTimeStep(timeStep: number): void;
  49902. getTimeStep(): number;
  49903. executeStep(delta: number): void;
  49904. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49905. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49906. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49907. private _processChildMeshes;
  49908. removePhysicsBody(impostor: PhysicsImpostor): void;
  49909. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49910. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49911. private _addMaterial;
  49912. private _checkWithEpsilon;
  49913. private _createShape;
  49914. private _createHeightmap;
  49915. private _minus90X;
  49916. private _plus90X;
  49917. private _tmpPosition;
  49918. private _tmpDeltaPosition;
  49919. private _tmpUnityRotation;
  49920. private _updatePhysicsBodyTransformation;
  49921. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49922. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49923. isSupported(): boolean;
  49924. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49925. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49926. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49927. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49928. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49929. getBodyMass(impostor: PhysicsImpostor): number;
  49930. getBodyFriction(impostor: PhysicsImpostor): number;
  49931. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49932. getBodyRestitution(impostor: PhysicsImpostor): number;
  49933. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49934. sleepBody(impostor: PhysicsImpostor): void;
  49935. wakeUpBody(impostor: PhysicsImpostor): void;
  49936. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49937. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49938. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49939. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49940. getRadius(impostor: PhysicsImpostor): number;
  49941. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49942. dispose(): void;
  49943. private _extendNamespace;
  49944. /**
  49945. * Does a raycast in the physics world
  49946. * @param from when should the ray start?
  49947. * @param to when should the ray end?
  49948. * @returns PhysicsRaycastResult
  49949. */
  49950. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49951. }
  49952. }
  49953. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  49954. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49955. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49956. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49958. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49959. import { Nullable } from "babylonjs/types";
  49960. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49961. /** @hidden */
  49962. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49963. world: any;
  49964. name: string;
  49965. BJSOIMO: any;
  49966. private _raycastResult;
  49967. constructor(iterations?: number, oimoInjection?: any);
  49968. setGravity(gravity: Vector3): void;
  49969. setTimeStep(timeStep: number): void;
  49970. getTimeStep(): number;
  49971. private _tmpImpostorsArray;
  49972. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49973. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49974. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49975. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49976. private _tmpPositionVector;
  49977. removePhysicsBody(impostor: PhysicsImpostor): void;
  49978. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49979. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49980. isSupported(): boolean;
  49981. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49982. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49983. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49984. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49985. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49986. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49987. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49988. getBodyMass(impostor: PhysicsImpostor): number;
  49989. getBodyFriction(impostor: PhysicsImpostor): number;
  49990. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49991. getBodyRestitution(impostor: PhysicsImpostor): number;
  49992. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49993. sleepBody(impostor: PhysicsImpostor): void;
  49994. wakeUpBody(impostor: PhysicsImpostor): void;
  49995. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49996. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49997. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49998. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49999. getRadius(impostor: PhysicsImpostor): number;
  50000. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50001. dispose(): void;
  50002. /**
  50003. * Does a raycast in the physics world
  50004. * @param from when should the ray start?
  50005. * @param to when should the ray end?
  50006. * @returns PhysicsRaycastResult
  50007. */
  50008. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50009. }
  50010. }
  50011. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50012. import { Nullable } from "babylonjs/types";
  50013. import { Scene } from "babylonjs/scene";
  50014. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50015. import { Mesh } from "babylonjs/Meshes/mesh";
  50016. /**
  50017. * Class containing static functions to help procedurally build meshes
  50018. */
  50019. export class RibbonBuilder {
  50020. /**
  50021. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50022. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50023. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50024. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50025. * * 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
  50026. * * 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
  50027. * * 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
  50028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50029. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50030. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50031. * * 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
  50032. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50033. * * 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
  50034. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50036. * @param name defines the name of the mesh
  50037. * @param options defines the options used to create the mesh
  50038. * @param scene defines the hosting scene
  50039. * @returns the ribbon mesh
  50040. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50041. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50042. */
  50043. static CreateRibbon(name: string, options: {
  50044. pathArray: Vector3[][];
  50045. closeArray?: boolean;
  50046. closePath?: boolean;
  50047. offset?: number;
  50048. updatable?: boolean;
  50049. sideOrientation?: number;
  50050. frontUVs?: Vector4;
  50051. backUVs?: Vector4;
  50052. instance?: Mesh;
  50053. invertUV?: boolean;
  50054. uvs?: Vector2[];
  50055. colors?: Color4[];
  50056. }, scene?: Nullable<Scene>): Mesh;
  50057. }
  50058. }
  50059. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50060. import { Nullable } from "babylonjs/types";
  50061. import { Scene } from "babylonjs/scene";
  50062. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50063. import { Mesh } from "babylonjs/Meshes/mesh";
  50064. /**
  50065. * Class containing static functions to help procedurally build meshes
  50066. */
  50067. export class ShapeBuilder {
  50068. /**
  50069. * 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.
  50070. * * 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.
  50071. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50072. * * 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.
  50073. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50074. * * 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
  50075. * * 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
  50076. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50077. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50078. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50079. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50081. * @param name defines the name of the mesh
  50082. * @param options defines the options used to create the mesh
  50083. * @param scene defines the hosting scene
  50084. * @returns the extruded shape mesh
  50085. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50086. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50087. */
  50088. static ExtrudeShape(name: string, options: {
  50089. shape: Vector3[];
  50090. path: Vector3[];
  50091. scale?: number;
  50092. rotation?: number;
  50093. cap?: number;
  50094. updatable?: boolean;
  50095. sideOrientation?: number;
  50096. frontUVs?: Vector4;
  50097. backUVs?: Vector4;
  50098. instance?: Mesh;
  50099. invertUV?: boolean;
  50100. }, scene?: Nullable<Scene>): Mesh;
  50101. /**
  50102. * Creates an custom extruded shape mesh.
  50103. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50104. * * 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.
  50105. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50106. * * 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
  50107. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50108. * * 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
  50109. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50110. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50111. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50112. * * 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
  50113. * * 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
  50114. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50115. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50116. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50117. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50119. * @param name defines the name of the mesh
  50120. * @param options defines the options used to create the mesh
  50121. * @param scene defines the hosting scene
  50122. * @returns the custom extruded shape mesh
  50123. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50124. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50125. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50126. */
  50127. static ExtrudeShapeCustom(name: string, options: {
  50128. shape: Vector3[];
  50129. path: Vector3[];
  50130. scaleFunction?: any;
  50131. rotationFunction?: any;
  50132. ribbonCloseArray?: boolean;
  50133. ribbonClosePath?: boolean;
  50134. cap?: number;
  50135. updatable?: boolean;
  50136. sideOrientation?: number;
  50137. frontUVs?: Vector4;
  50138. backUVs?: Vector4;
  50139. instance?: Mesh;
  50140. invertUV?: boolean;
  50141. }, scene?: Nullable<Scene>): Mesh;
  50142. private static _ExtrudeShapeGeneric;
  50143. }
  50144. }
  50145. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50146. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50147. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50148. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50149. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50150. import { Nullable } from "babylonjs/types";
  50151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50152. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50153. /**
  50154. * AmmoJS Physics plugin
  50155. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50156. * @see https://github.com/kripken/ammo.js/
  50157. */
  50158. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50159. private _useDeltaForWorldStep;
  50160. /**
  50161. * Reference to the Ammo library
  50162. */
  50163. bjsAMMO: any;
  50164. /**
  50165. * Created ammoJS world which physics bodies are added to
  50166. */
  50167. world: any;
  50168. /**
  50169. * Name of the plugin
  50170. */
  50171. name: string;
  50172. private _timeStep;
  50173. private _fixedTimeStep;
  50174. private _maxSteps;
  50175. private _tmpQuaternion;
  50176. private _tmpAmmoTransform;
  50177. private _tmpAmmoQuaternion;
  50178. private _tmpAmmoConcreteContactResultCallback;
  50179. private _collisionConfiguration;
  50180. private _dispatcher;
  50181. private _overlappingPairCache;
  50182. private _solver;
  50183. private _softBodySolver;
  50184. private _tmpAmmoVectorA;
  50185. private _tmpAmmoVectorB;
  50186. private _tmpAmmoVectorC;
  50187. private _tmpAmmoVectorD;
  50188. private _tmpContactCallbackResult;
  50189. private _tmpAmmoVectorRCA;
  50190. private _tmpAmmoVectorRCB;
  50191. private _raycastResult;
  50192. private static readonly DISABLE_COLLISION_FLAG;
  50193. private static readonly KINEMATIC_FLAG;
  50194. private static readonly DISABLE_DEACTIVATION_FLAG;
  50195. /**
  50196. * Initializes the ammoJS plugin
  50197. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50198. * @param ammoInjection can be used to inject your own ammo reference
  50199. */
  50200. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50201. /**
  50202. * Sets the gravity of the physics world (m/(s^2))
  50203. * @param gravity Gravity to set
  50204. */
  50205. setGravity(gravity: Vector3): void;
  50206. /**
  50207. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50208. * @param timeStep timestep to use in seconds
  50209. */
  50210. setTimeStep(timeStep: number): void;
  50211. /**
  50212. * 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)
  50213. * @param fixedTimeStep fixedTimeStep to use in seconds
  50214. */
  50215. setFixedTimeStep(fixedTimeStep: number): void;
  50216. /**
  50217. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50218. * @param maxSteps the maximum number of steps by the physics engine per frame
  50219. */
  50220. setMaxSteps(maxSteps: number): void;
  50221. /**
  50222. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50223. * @returns the current timestep in seconds
  50224. */
  50225. getTimeStep(): number;
  50226. private _isImpostorInContact;
  50227. private _isImpostorPairInContact;
  50228. private _stepSimulation;
  50229. /**
  50230. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50231. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50232. * After the step the babylon meshes are set to the position of the physics imposters
  50233. * @param delta amount of time to step forward
  50234. * @param impostors array of imposters to update before/after the step
  50235. */
  50236. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50237. /**
  50238. * Update babylon mesh to match physics world object
  50239. * @param impostor imposter to match
  50240. */
  50241. private _afterSoftStep;
  50242. /**
  50243. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50244. * @param impostor imposter to match
  50245. */
  50246. private _ropeStep;
  50247. /**
  50248. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50249. * @param impostor imposter to match
  50250. */
  50251. private _softbodyOrClothStep;
  50252. private _tmpVector;
  50253. private _tmpMatrix;
  50254. /**
  50255. * Applies an impulse on the imposter
  50256. * @param impostor imposter to apply impulse to
  50257. * @param force amount of force to be applied to the imposter
  50258. * @param contactPoint the location to apply the impulse on the imposter
  50259. */
  50260. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50261. /**
  50262. * Applies a force on the imposter
  50263. * @param impostor imposter to apply force
  50264. * @param force amount of force to be applied to the imposter
  50265. * @param contactPoint the location to apply the force on the imposter
  50266. */
  50267. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50268. /**
  50269. * Creates a physics body using the plugin
  50270. * @param impostor the imposter to create the physics body on
  50271. */
  50272. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50273. /**
  50274. * Removes the physics body from the imposter and disposes of the body's memory
  50275. * @param impostor imposter to remove the physics body from
  50276. */
  50277. removePhysicsBody(impostor: PhysicsImpostor): void;
  50278. /**
  50279. * Generates a joint
  50280. * @param impostorJoint the imposter joint to create the joint with
  50281. */
  50282. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50283. /**
  50284. * Removes a joint
  50285. * @param impostorJoint the imposter joint to remove the joint from
  50286. */
  50287. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50288. private _addMeshVerts;
  50289. /**
  50290. * Initialise the soft body vertices to match its object's (mesh) vertices
  50291. * Softbody vertices (nodes) are in world space and to match this
  50292. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50293. * @param impostor to create the softbody for
  50294. */
  50295. private _softVertexData;
  50296. /**
  50297. * Create an impostor's soft body
  50298. * @param impostor to create the softbody for
  50299. */
  50300. private _createSoftbody;
  50301. /**
  50302. * Create cloth for an impostor
  50303. * @param impostor to create the softbody for
  50304. */
  50305. private _createCloth;
  50306. /**
  50307. * Create rope for an impostor
  50308. * @param impostor to create the softbody for
  50309. */
  50310. private _createRope;
  50311. private _addHullVerts;
  50312. private _createShape;
  50313. /**
  50314. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50315. * @param impostor imposter containing the physics body and babylon object
  50316. */
  50317. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50318. /**
  50319. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50320. * @param impostor imposter containing the physics body and babylon object
  50321. * @param newPosition new position
  50322. * @param newRotation new rotation
  50323. */
  50324. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50325. /**
  50326. * If this plugin is supported
  50327. * @returns true if its supported
  50328. */
  50329. isSupported(): boolean;
  50330. /**
  50331. * Sets the linear velocity of the physics body
  50332. * @param impostor imposter to set the velocity on
  50333. * @param velocity velocity to set
  50334. */
  50335. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50336. /**
  50337. * Sets the angular velocity of the physics body
  50338. * @param impostor imposter to set the velocity on
  50339. * @param velocity velocity to set
  50340. */
  50341. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50342. /**
  50343. * gets the linear velocity
  50344. * @param impostor imposter to get linear velocity from
  50345. * @returns linear velocity
  50346. */
  50347. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50348. /**
  50349. * gets the angular velocity
  50350. * @param impostor imposter to get angular velocity from
  50351. * @returns angular velocity
  50352. */
  50353. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50354. /**
  50355. * Sets the mass of physics body
  50356. * @param impostor imposter to set the mass on
  50357. * @param mass mass to set
  50358. */
  50359. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50360. /**
  50361. * Gets the mass of the physics body
  50362. * @param impostor imposter to get the mass from
  50363. * @returns mass
  50364. */
  50365. getBodyMass(impostor: PhysicsImpostor): number;
  50366. /**
  50367. * Gets friction of the impostor
  50368. * @param impostor impostor to get friction from
  50369. * @returns friction value
  50370. */
  50371. getBodyFriction(impostor: PhysicsImpostor): number;
  50372. /**
  50373. * Sets friction of the impostor
  50374. * @param impostor impostor to set friction on
  50375. * @param friction friction value
  50376. */
  50377. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50378. /**
  50379. * Gets restitution of the impostor
  50380. * @param impostor impostor to get restitution from
  50381. * @returns restitution value
  50382. */
  50383. getBodyRestitution(impostor: PhysicsImpostor): number;
  50384. /**
  50385. * Sets resitution of the impostor
  50386. * @param impostor impostor to set resitution on
  50387. * @param restitution resitution value
  50388. */
  50389. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50390. /**
  50391. * Gets pressure inside the impostor
  50392. * @param impostor impostor to get pressure from
  50393. * @returns pressure value
  50394. */
  50395. getBodyPressure(impostor: PhysicsImpostor): number;
  50396. /**
  50397. * Sets pressure inside a soft body impostor
  50398. * Cloth and rope must remain 0 pressure
  50399. * @param impostor impostor to set pressure on
  50400. * @param pressure pressure value
  50401. */
  50402. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50403. /**
  50404. * Gets stiffness of the impostor
  50405. * @param impostor impostor to get stiffness from
  50406. * @returns pressure value
  50407. */
  50408. getBodyStiffness(impostor: PhysicsImpostor): number;
  50409. /**
  50410. * Sets stiffness of the impostor
  50411. * @param impostor impostor to set stiffness on
  50412. * @param stiffness stiffness value from 0 to 1
  50413. */
  50414. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50415. /**
  50416. * Gets velocityIterations of the impostor
  50417. * @param impostor impostor to get velocity iterations from
  50418. * @returns velocityIterations value
  50419. */
  50420. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50421. /**
  50422. * Sets velocityIterations of the impostor
  50423. * @param impostor impostor to set velocity iterations on
  50424. * @param velocityIterations velocityIterations value
  50425. */
  50426. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50427. /**
  50428. * Gets positionIterations of the impostor
  50429. * @param impostor impostor to get position iterations from
  50430. * @returns positionIterations value
  50431. */
  50432. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50433. /**
  50434. * Sets positionIterations of the impostor
  50435. * @param impostor impostor to set position on
  50436. * @param positionIterations positionIterations value
  50437. */
  50438. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50439. /**
  50440. * Append an anchor to a cloth object
  50441. * @param impostor is the cloth impostor to add anchor to
  50442. * @param otherImpostor is the rigid impostor to anchor to
  50443. * @param width ratio across width from 0 to 1
  50444. * @param height ratio up height from 0 to 1
  50445. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50446. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50447. */
  50448. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50449. /**
  50450. * Append an hook to a rope object
  50451. * @param impostor is the rope impostor to add hook to
  50452. * @param otherImpostor is the rigid impostor to hook to
  50453. * @param length ratio along the rope from 0 to 1
  50454. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50455. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50456. */
  50457. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50458. /**
  50459. * Sleeps the physics body and stops it from being active
  50460. * @param impostor impostor to sleep
  50461. */
  50462. sleepBody(impostor: PhysicsImpostor): void;
  50463. /**
  50464. * Activates the physics body
  50465. * @param impostor impostor to activate
  50466. */
  50467. wakeUpBody(impostor: PhysicsImpostor): void;
  50468. /**
  50469. * Updates the distance parameters of the joint
  50470. * @param joint joint to update
  50471. * @param maxDistance maximum distance of the joint
  50472. * @param minDistance minimum distance of the joint
  50473. */
  50474. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50475. /**
  50476. * Sets a motor on the joint
  50477. * @param joint joint to set motor on
  50478. * @param speed speed of the motor
  50479. * @param maxForce maximum force of the motor
  50480. * @param motorIndex index of the motor
  50481. */
  50482. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50483. /**
  50484. * Sets the motors limit
  50485. * @param joint joint to set limit on
  50486. * @param upperLimit upper limit
  50487. * @param lowerLimit lower limit
  50488. */
  50489. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50490. /**
  50491. * Syncs the position and rotation of a mesh with the impostor
  50492. * @param mesh mesh to sync
  50493. * @param impostor impostor to update the mesh with
  50494. */
  50495. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50496. /**
  50497. * Gets the radius of the impostor
  50498. * @param impostor impostor to get radius from
  50499. * @returns the radius
  50500. */
  50501. getRadius(impostor: PhysicsImpostor): number;
  50502. /**
  50503. * Gets the box size of the impostor
  50504. * @param impostor impostor to get box size from
  50505. * @param result the resulting box size
  50506. */
  50507. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50508. /**
  50509. * Disposes of the impostor
  50510. */
  50511. dispose(): void;
  50512. /**
  50513. * Does a raycast in the physics world
  50514. * @param from when should the ray start?
  50515. * @param to when should the ray end?
  50516. * @returns PhysicsRaycastResult
  50517. */
  50518. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50519. }
  50520. }
  50521. declare module "babylonjs/Probes/reflectionProbe" {
  50522. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50523. import { Vector3 } from "babylonjs/Maths/math";
  50524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50525. import { Nullable } from "babylonjs/types";
  50526. import { Scene } from "babylonjs/scene";
  50527. module "babylonjs/abstractScene" {
  50528. interface AbstractScene {
  50529. /**
  50530. * The list of reflection probes added to the scene
  50531. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50532. */
  50533. reflectionProbes: Array<ReflectionProbe>;
  50534. /**
  50535. * Removes the given reflection probe from this scene.
  50536. * @param toRemove The reflection probe to remove
  50537. * @returns The index of the removed reflection probe
  50538. */
  50539. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50540. /**
  50541. * Adds the given reflection probe to this scene.
  50542. * @param newReflectionProbe The reflection probe to add
  50543. */
  50544. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50545. }
  50546. }
  50547. /**
  50548. * Class used to generate realtime reflection / refraction cube textures
  50549. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50550. */
  50551. export class ReflectionProbe {
  50552. /** defines the name of the probe */
  50553. name: string;
  50554. private _scene;
  50555. private _renderTargetTexture;
  50556. private _projectionMatrix;
  50557. private _viewMatrix;
  50558. private _target;
  50559. private _add;
  50560. private _attachedMesh;
  50561. private _invertYAxis;
  50562. /** Gets or sets probe position (center of the cube map) */
  50563. position: Vector3;
  50564. /**
  50565. * Creates a new reflection probe
  50566. * @param name defines the name of the probe
  50567. * @param size defines the texture resolution (for each face)
  50568. * @param scene defines the hosting scene
  50569. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50570. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50571. */
  50572. constructor(
  50573. /** defines the name of the probe */
  50574. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50575. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50576. samples: number;
  50577. /** Gets or sets the refresh rate to use (on every frame by default) */
  50578. refreshRate: number;
  50579. /**
  50580. * Gets the hosting scene
  50581. * @returns a Scene
  50582. */
  50583. getScene(): Scene;
  50584. /** Gets the internal CubeTexture used to render to */
  50585. readonly cubeTexture: RenderTargetTexture;
  50586. /** Gets the list of meshes to render */
  50587. readonly renderList: Nullable<AbstractMesh[]>;
  50588. /**
  50589. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50590. * @param mesh defines the mesh to attach to
  50591. */
  50592. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50593. /**
  50594. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50595. * @param renderingGroupId The rendering group id corresponding to its index
  50596. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50597. */
  50598. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50599. /**
  50600. * Clean all associated resources
  50601. */
  50602. dispose(): void;
  50603. /**
  50604. * Converts the reflection probe information to a readable string for debug purpose.
  50605. * @param fullDetails Supports for multiple levels of logging within scene loading
  50606. * @returns the human readable reflection probe info
  50607. */
  50608. toString(fullDetails?: boolean): string;
  50609. /**
  50610. * Get the class name of the relfection probe.
  50611. * @returns "ReflectionProbe"
  50612. */
  50613. getClassName(): string;
  50614. /**
  50615. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50616. * @returns The JSON representation of the texture
  50617. */
  50618. serialize(): any;
  50619. /**
  50620. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50621. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50622. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50623. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50624. * @returns The parsed reflection probe if successful
  50625. */
  50626. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50627. }
  50628. }
  50629. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  50630. /** @hidden */
  50631. export var _BabylonLoaderRegistered: boolean;
  50632. }
  50633. declare module "babylonjs/Loading/Plugins/index" {
  50634. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  50635. }
  50636. declare module "babylonjs/Loading/index" {
  50637. export * from "babylonjs/Loading/loadingScreen";
  50638. export * from "babylonjs/Loading/Plugins/index";
  50639. export * from "babylonjs/Loading/sceneLoader";
  50640. export * from "babylonjs/Loading/sceneLoaderFlags";
  50641. }
  50642. declare module "babylonjs/Materials/Background/index" {
  50643. export * from "babylonjs/Materials/Background/backgroundMaterial";
  50644. }
  50645. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  50646. import { Scene } from "babylonjs/scene";
  50647. import { Color3 } from "babylonjs/Maths/math";
  50648. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50649. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50650. /**
  50651. * The Physically based simple base material of BJS.
  50652. *
  50653. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50654. * It is used as the base class for both the specGloss and metalRough conventions.
  50655. */
  50656. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50657. /**
  50658. * Number of Simultaneous lights allowed on the material.
  50659. */
  50660. maxSimultaneousLights: number;
  50661. /**
  50662. * If sets to true, disables all the lights affecting the material.
  50663. */
  50664. disableLighting: boolean;
  50665. /**
  50666. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50667. */
  50668. environmentTexture: BaseTexture;
  50669. /**
  50670. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50671. */
  50672. invertNormalMapX: boolean;
  50673. /**
  50674. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50675. */
  50676. invertNormalMapY: boolean;
  50677. /**
  50678. * Normal map used in the model.
  50679. */
  50680. normalTexture: BaseTexture;
  50681. /**
  50682. * Emissivie color used to self-illuminate the model.
  50683. */
  50684. emissiveColor: Color3;
  50685. /**
  50686. * Emissivie texture used to self-illuminate the model.
  50687. */
  50688. emissiveTexture: BaseTexture;
  50689. /**
  50690. * Occlusion Channel Strenght.
  50691. */
  50692. occlusionStrength: number;
  50693. /**
  50694. * Occlusion Texture of the material (adding extra occlusion effects).
  50695. */
  50696. occlusionTexture: BaseTexture;
  50697. /**
  50698. * Defines the alpha limits in alpha test mode.
  50699. */
  50700. alphaCutOff: number;
  50701. /**
  50702. * Gets the current double sided mode.
  50703. */
  50704. /**
  50705. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50706. */
  50707. doubleSided: boolean;
  50708. /**
  50709. * Stores the pre-calculated light information of a mesh in a texture.
  50710. */
  50711. lightmapTexture: BaseTexture;
  50712. /**
  50713. * If true, the light map contains occlusion information instead of lighting info.
  50714. */
  50715. useLightmapAsShadowmap: boolean;
  50716. /**
  50717. * Instantiates a new PBRMaterial instance.
  50718. *
  50719. * @param name The material name
  50720. * @param scene The scene the material will be use in.
  50721. */
  50722. constructor(name: string, scene: Scene);
  50723. getClassName(): string;
  50724. }
  50725. }
  50726. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  50727. import { Scene } from "babylonjs/scene";
  50728. import { Color3 } from "babylonjs/Maths/math";
  50729. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50730. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50731. /**
  50732. * The PBR material of BJS following the metal roughness convention.
  50733. *
  50734. * This fits to the PBR convention in the GLTF definition:
  50735. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50736. */
  50737. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50738. /**
  50739. * The base color has two different interpretations depending on the value of metalness.
  50740. * When the material is a metal, the base color is the specific measured reflectance value
  50741. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50742. * of the material.
  50743. */
  50744. baseColor: Color3;
  50745. /**
  50746. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50747. * well as opacity information in the alpha channel.
  50748. */
  50749. baseTexture: BaseTexture;
  50750. /**
  50751. * Specifies the metallic scalar value of the material.
  50752. * Can also be used to scale the metalness values of the metallic texture.
  50753. */
  50754. metallic: number;
  50755. /**
  50756. * Specifies the roughness scalar value of the material.
  50757. * Can also be used to scale the roughness values of the metallic texture.
  50758. */
  50759. roughness: number;
  50760. /**
  50761. * Texture containing both the metallic value in the B channel and the
  50762. * roughness value in the G channel to keep better precision.
  50763. */
  50764. metallicRoughnessTexture: BaseTexture;
  50765. /**
  50766. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50767. *
  50768. * @param name The material name
  50769. * @param scene The scene the material will be use in.
  50770. */
  50771. constructor(name: string, scene: Scene);
  50772. /**
  50773. * Return the currrent class name of the material.
  50774. */
  50775. getClassName(): string;
  50776. /**
  50777. * Makes a duplicate of the current material.
  50778. * @param name - name to use for the new material.
  50779. */
  50780. clone(name: string): PBRMetallicRoughnessMaterial;
  50781. /**
  50782. * Serialize the material to a parsable JSON object.
  50783. */
  50784. serialize(): any;
  50785. /**
  50786. * Parses a JSON object correponding to the serialize function.
  50787. */
  50788. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50789. }
  50790. }
  50791. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  50792. import { Scene } from "babylonjs/scene";
  50793. import { Color3 } from "babylonjs/Maths/math";
  50794. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50795. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50796. /**
  50797. * The PBR material of BJS following the specular glossiness convention.
  50798. *
  50799. * This fits to the PBR convention in the GLTF definition:
  50800. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50801. */
  50802. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50803. /**
  50804. * Specifies the diffuse color of the material.
  50805. */
  50806. diffuseColor: Color3;
  50807. /**
  50808. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50809. * channel.
  50810. */
  50811. diffuseTexture: BaseTexture;
  50812. /**
  50813. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50814. */
  50815. specularColor: Color3;
  50816. /**
  50817. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50818. */
  50819. glossiness: number;
  50820. /**
  50821. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50822. */
  50823. specularGlossinessTexture: BaseTexture;
  50824. /**
  50825. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50826. *
  50827. * @param name The material name
  50828. * @param scene The scene the material will be use in.
  50829. */
  50830. constructor(name: string, scene: Scene);
  50831. /**
  50832. * Return the currrent class name of the material.
  50833. */
  50834. getClassName(): string;
  50835. /**
  50836. * Makes a duplicate of the current material.
  50837. * @param name - name to use for the new material.
  50838. */
  50839. clone(name: string): PBRSpecularGlossinessMaterial;
  50840. /**
  50841. * Serialize the material to a parsable JSON object.
  50842. */
  50843. serialize(): any;
  50844. /**
  50845. * Parses a JSON object correponding to the serialize function.
  50846. */
  50847. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50848. }
  50849. }
  50850. declare module "babylonjs/Materials/PBR/index" {
  50851. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50852. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50853. export * from "babylonjs/Materials/PBR/pbrMaterial";
  50854. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  50855. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  50856. }
  50857. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  50858. import { Nullable } from "babylonjs/types";
  50859. import { Scene } from "babylonjs/scene";
  50860. import { Matrix } from "babylonjs/Maths/math";
  50861. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50862. /**
  50863. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50864. * It can help converting any input color in a desired output one. This can then be used to create effects
  50865. * from sepia, black and white to sixties or futuristic rendering...
  50866. *
  50867. * The only supported format is currently 3dl.
  50868. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50869. */
  50870. export class ColorGradingTexture extends BaseTexture {
  50871. /**
  50872. * The current texture matrix. (will always be identity in color grading texture)
  50873. */
  50874. private _textureMatrix;
  50875. /**
  50876. * The texture URL.
  50877. */
  50878. url: string;
  50879. /**
  50880. * Empty line regex stored for GC.
  50881. */
  50882. private static _noneEmptyLineRegex;
  50883. private _engine;
  50884. /**
  50885. * Instantiates a ColorGradingTexture from the following parameters.
  50886. *
  50887. * @param url The location of the color gradind data (currently only supporting 3dl)
  50888. * @param scene The scene the texture will be used in
  50889. */
  50890. constructor(url: string, scene: Scene);
  50891. /**
  50892. * Returns the texture matrix used in most of the material.
  50893. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50894. */
  50895. getTextureMatrix(): Matrix;
  50896. /**
  50897. * Occurs when the file being loaded is a .3dl LUT file.
  50898. */
  50899. private load3dlTexture;
  50900. /**
  50901. * Starts the loading process of the texture.
  50902. */
  50903. private loadTexture;
  50904. /**
  50905. * Clones the color gradind texture.
  50906. */
  50907. clone(): ColorGradingTexture;
  50908. /**
  50909. * Called during delayed load for textures.
  50910. */
  50911. delayLoad(): void;
  50912. /**
  50913. * Parses a color grading texture serialized by Babylon.
  50914. * @param parsedTexture The texture information being parsedTexture
  50915. * @param scene The scene to load the texture in
  50916. * @param rootUrl The root url of the data assets to load
  50917. * @return A color gradind texture
  50918. */
  50919. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50920. /**
  50921. * Serializes the LUT texture to json format.
  50922. */
  50923. serialize(): any;
  50924. }
  50925. }
  50926. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  50927. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50928. import { Scene } from "babylonjs/scene";
  50929. import { Nullable } from "babylonjs/types";
  50930. /**
  50931. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50932. */
  50933. export class EquiRectangularCubeTexture extends BaseTexture {
  50934. /** The six faces of the cube. */
  50935. private static _FacesMapping;
  50936. private _noMipmap;
  50937. private _onLoad;
  50938. private _onError;
  50939. /** The size of the cubemap. */
  50940. private _size;
  50941. /** The buffer of the image. */
  50942. private _buffer;
  50943. /** The width of the input image. */
  50944. private _width;
  50945. /** The height of the input image. */
  50946. private _height;
  50947. /** The URL to the image. */
  50948. url: string;
  50949. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50950. coordinatesMode: number;
  50951. /**
  50952. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50953. * @param url The location of the image
  50954. * @param scene The scene the texture will be used in
  50955. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50956. * @param noMipmap Forces to not generate the mipmap if true
  50957. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50958. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50959. * @param onLoad — defines a callback called when texture is loaded
  50960. * @param onError — defines a callback called if there is an error
  50961. */
  50962. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50963. /**
  50964. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50965. */
  50966. private loadImage;
  50967. /**
  50968. * Convert the image buffer into a cubemap and create a CubeTexture.
  50969. */
  50970. private loadTexture;
  50971. /**
  50972. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  50973. * @param buffer The ArrayBuffer that should be converted.
  50974. * @returns The buffer as Float32Array.
  50975. */
  50976. private getFloat32ArrayFromArrayBuffer;
  50977. /**
  50978. * Get the current class name of the texture useful for serialization or dynamic coding.
  50979. * @returns "EquiRectangularCubeTexture"
  50980. */
  50981. getClassName(): string;
  50982. /**
  50983. * Create a clone of the current EquiRectangularCubeTexture and return it.
  50984. * @returns A clone of the current EquiRectangularCubeTexture.
  50985. */
  50986. clone(): EquiRectangularCubeTexture;
  50987. }
  50988. }
  50989. declare module "babylonjs/Misc/tga" {
  50990. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50991. /**
  50992. * Based on jsTGALoader - Javascript loader for TGA file
  50993. * By Vincent Thibault
  50994. * @see http://blog.robrowser.com/javascript-tga-loader.html
  50995. */
  50996. export class TGATools {
  50997. private static _TYPE_INDEXED;
  50998. private static _TYPE_RGB;
  50999. private static _TYPE_GREY;
  51000. private static _TYPE_RLE_INDEXED;
  51001. private static _TYPE_RLE_RGB;
  51002. private static _TYPE_RLE_GREY;
  51003. private static _ORIGIN_MASK;
  51004. private static _ORIGIN_SHIFT;
  51005. private static _ORIGIN_BL;
  51006. private static _ORIGIN_BR;
  51007. private static _ORIGIN_UL;
  51008. private static _ORIGIN_UR;
  51009. /**
  51010. * Gets the header of a TGA file
  51011. * @param data defines the TGA data
  51012. * @returns the header
  51013. */
  51014. static GetTGAHeader(data: Uint8Array): any;
  51015. /**
  51016. * Uploads TGA content to a Babylon Texture
  51017. * @hidden
  51018. */
  51019. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51020. /** @hidden */
  51021. 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;
  51022. /** @hidden */
  51023. 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;
  51024. /** @hidden */
  51025. 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;
  51026. /** @hidden */
  51027. 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;
  51028. /** @hidden */
  51029. 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;
  51030. /** @hidden */
  51031. 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;
  51032. }
  51033. }
  51034. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  51035. import { Nullable } from "babylonjs/types";
  51036. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51037. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51038. /**
  51039. * Implementation of the TGA Texture Loader.
  51040. * @hidden
  51041. */
  51042. export class _TGATextureLoader implements IInternalTextureLoader {
  51043. /**
  51044. * Defines wether the loader supports cascade loading the different faces.
  51045. */
  51046. readonly supportCascades: boolean;
  51047. /**
  51048. * This returns if the loader support the current file information.
  51049. * @param extension defines the file extension of the file being loaded
  51050. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51051. * @param fallback defines the fallback internal texture if any
  51052. * @param isBase64 defines whether the texture is encoded as a base64
  51053. * @param isBuffer defines whether the texture data are stored as a buffer
  51054. * @returns true if the loader can load the specified file
  51055. */
  51056. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51057. /**
  51058. * Transform the url before loading if required.
  51059. * @param rootUrl the url of the texture
  51060. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51061. * @returns the transformed texture
  51062. */
  51063. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51064. /**
  51065. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51066. * @param rootUrl the url of the texture
  51067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51068. * @returns the fallback texture
  51069. */
  51070. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51071. /**
  51072. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51073. * @param data contains the texture data
  51074. * @param texture defines the BabylonJS internal texture
  51075. * @param createPolynomials will be true if polynomials have been requested
  51076. * @param onLoad defines the callback to trigger once the texture is ready
  51077. * @param onError defines the callback to trigger in case of error
  51078. */
  51079. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51080. /**
  51081. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51082. * @param data contains the texture data
  51083. * @param texture defines the BabylonJS internal texture
  51084. * @param callback defines the method to call once ready to upload
  51085. */
  51086. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51087. }
  51088. }
  51089. declare module "babylonjs/Materials/Textures/Loaders/index" {
  51090. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51091. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51092. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51093. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  51094. }
  51095. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  51096. import { Scene } from "babylonjs/scene";
  51097. import { Texture } from "babylonjs/Materials/Textures/texture";
  51098. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51099. /**
  51100. * 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.
  51101. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51102. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51103. */
  51104. export class CustomProceduralTexture extends ProceduralTexture {
  51105. private _animate;
  51106. private _time;
  51107. private _config;
  51108. private _texturePath;
  51109. /**
  51110. * Instantiates a new Custom Procedural Texture.
  51111. * 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.
  51112. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51113. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51114. * @param name Define the name of the texture
  51115. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51116. * @param size Define the size of the texture to create
  51117. * @param scene Define the scene the texture belongs to
  51118. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51119. * @param generateMipMaps Define if the texture should creates mip maps or not
  51120. */
  51121. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51122. private _loadJson;
  51123. /**
  51124. * Is the texture ready to be used ? (rendered at least once)
  51125. * @returns true if ready, otherwise, false.
  51126. */
  51127. isReady(): boolean;
  51128. /**
  51129. * Render the texture to its associated render target.
  51130. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51131. */
  51132. render(useCameraPostProcess?: boolean): void;
  51133. /**
  51134. * Update the list of dependant textures samplers in the shader.
  51135. */
  51136. updateTextures(): void;
  51137. /**
  51138. * Update the uniform values of the procedural texture in the shader.
  51139. */
  51140. updateShaderUniforms(): void;
  51141. /**
  51142. * Define if the texture animates or not.
  51143. */
  51144. animate: boolean;
  51145. }
  51146. }
  51147. declare module "babylonjs/Shaders/noise.fragment" {
  51148. /** @hidden */
  51149. export var noisePixelShader: {
  51150. name: string;
  51151. shader: string;
  51152. };
  51153. }
  51154. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  51155. import { Nullable } from "babylonjs/types";
  51156. import { Scene } from "babylonjs/scene";
  51157. import { Texture } from "babylonjs/Materials/Textures/texture";
  51158. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51159. import "babylonjs/Shaders/noise.fragment";
  51160. /**
  51161. * Class used to generate noise procedural textures
  51162. */
  51163. export class NoiseProceduralTexture extends ProceduralTexture {
  51164. private _time;
  51165. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51166. brightness: number;
  51167. /** Defines the number of octaves to process */
  51168. octaves: number;
  51169. /** Defines the level of persistence (0.8 by default) */
  51170. persistence: number;
  51171. /** Gets or sets animation speed factor (default is 1) */
  51172. animationSpeedFactor: number;
  51173. /**
  51174. * Creates a new NoiseProceduralTexture
  51175. * @param name defines the name fo the texture
  51176. * @param size defines the size of the texture (default is 256)
  51177. * @param scene defines the hosting scene
  51178. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51179. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51180. */
  51181. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51182. private _updateShaderUniforms;
  51183. protected _getDefines(): string;
  51184. /** Generate the current state of the procedural texture */
  51185. render(useCameraPostProcess?: boolean): void;
  51186. /**
  51187. * Serializes this noise procedural texture
  51188. * @returns a serialized noise procedural texture object
  51189. */
  51190. serialize(): any;
  51191. /**
  51192. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51193. * @param parsedTexture defines parsed texture data
  51194. * @param scene defines the current scene
  51195. * @param rootUrl defines the root URL containing noise procedural texture information
  51196. * @returns a parsed NoiseProceduralTexture
  51197. */
  51198. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51199. }
  51200. }
  51201. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  51202. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  51203. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  51204. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51205. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  51206. }
  51207. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  51208. import { Nullable } from "babylonjs/types";
  51209. import { Scene } from "babylonjs/scene";
  51210. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51211. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51212. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  51213. /**
  51214. * Raw cube texture where the raw buffers are passed in
  51215. */
  51216. export class RawCubeTexture extends CubeTexture {
  51217. /**
  51218. * Creates a cube texture where the raw buffers are passed in.
  51219. * @param scene defines the scene the texture is attached to
  51220. * @param data defines the array of data to use to create each face
  51221. * @param size defines the size of the textures
  51222. * @param format defines the format of the data
  51223. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51224. * @param generateMipMaps defines if the engine should generate the mip levels
  51225. * @param invertY defines if data must be stored with Y axis inverted
  51226. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51227. * @param compression defines the compression used (null by default)
  51228. */
  51229. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51230. /**
  51231. * Updates the raw cube texture.
  51232. * @param data defines the data to store
  51233. * @param format defines the data format
  51234. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51235. * @param invertY defines if data must be stored with Y axis inverted
  51236. * @param compression defines the compression used (null by default)
  51237. * @param level defines which level of the texture to update
  51238. */
  51239. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51240. /**
  51241. * Updates a raw cube texture with RGBD encoded data.
  51242. * @param data defines the array of data [mipmap][face] to use to create each face
  51243. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51244. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51245. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51246. * @returns a promsie that resolves when the operation is complete
  51247. */
  51248. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51249. /**
  51250. * Clones the raw cube texture.
  51251. * @return a new cube texture
  51252. */
  51253. clone(): CubeTexture;
  51254. /** @hidden */
  51255. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51256. }
  51257. }
  51258. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  51259. import { Scene } from "babylonjs/scene";
  51260. import { Texture } from "babylonjs/Materials/Textures/texture";
  51261. /**
  51262. * Class used to store 3D textures containing user data
  51263. */
  51264. export class RawTexture3D extends Texture {
  51265. /** Gets or sets the texture format to use */
  51266. format: number;
  51267. private _engine;
  51268. /**
  51269. * Create a new RawTexture3D
  51270. * @param data defines the data of the texture
  51271. * @param width defines the width of the texture
  51272. * @param height defines the height of the texture
  51273. * @param depth defines the depth of the texture
  51274. * @param format defines the texture format to use
  51275. * @param scene defines the hosting scene
  51276. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51277. * @param invertY defines if texture must be stored with Y axis inverted
  51278. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51279. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51280. */
  51281. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51282. /** Gets or sets the texture format to use */
  51283. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51284. /**
  51285. * Update the texture with new data
  51286. * @param data defines the data to store in the texture
  51287. */
  51288. update(data: ArrayBufferView): void;
  51289. }
  51290. }
  51291. declare module "babylonjs/Materials/Textures/refractionTexture" {
  51292. import { Scene } from "babylonjs/scene";
  51293. import { Plane } from "babylonjs/Maths/math";
  51294. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51295. /**
  51296. * Creates a refraction texture used by refraction channel of the standard material.
  51297. * It is like a mirror but to see through a material.
  51298. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51299. */
  51300. export class RefractionTexture extends RenderTargetTexture {
  51301. /**
  51302. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51303. * 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.
  51304. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51305. */
  51306. refractionPlane: Plane;
  51307. /**
  51308. * Define how deep under the surface we should see.
  51309. */
  51310. depth: number;
  51311. /**
  51312. * Creates a refraction texture used by refraction channel of the standard material.
  51313. * It is like a mirror but to see through a material.
  51314. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51315. * @param name Define the texture name
  51316. * @param size Define the size of the underlying texture
  51317. * @param scene Define the scene the refraction belongs to
  51318. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51319. */
  51320. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51321. /**
  51322. * Clone the refraction texture.
  51323. * @returns the cloned texture
  51324. */
  51325. clone(): RefractionTexture;
  51326. /**
  51327. * Serialize the texture to a JSON representation you could use in Parse later on
  51328. * @returns the serialized JSON representation
  51329. */
  51330. serialize(): any;
  51331. }
  51332. }
  51333. declare module "babylonjs/Materials/Textures/index" {
  51334. export * from "babylonjs/Materials/Textures/baseTexture";
  51335. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  51336. export * from "babylonjs/Materials/Textures/cubeTexture";
  51337. export * from "babylonjs/Materials/Textures/dynamicTexture";
  51338. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  51339. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  51340. export * from "babylonjs/Materials/Textures/internalTexture";
  51341. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  51342. export * from "babylonjs/Materials/Textures/Loaders/index";
  51343. export * from "babylonjs/Materials/Textures/mirrorTexture";
  51344. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  51345. export * from "babylonjs/Materials/Textures/Procedurals/index";
  51346. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  51347. export * from "babylonjs/Materials/Textures/rawTexture";
  51348. export * from "babylonjs/Materials/Textures/rawTexture3D";
  51349. export * from "babylonjs/Materials/Textures/refractionTexture";
  51350. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  51351. export * from "babylonjs/Materials/Textures/texture";
  51352. export * from "babylonjs/Materials/Textures/videoTexture";
  51353. }
  51354. declare module "babylonjs/Materials/index" {
  51355. export * from "babylonjs/Materials/Background/index";
  51356. export * from "babylonjs/Materials/colorCurves";
  51357. export * from "babylonjs/Materials/effect";
  51358. export * from "babylonjs/Materials/fresnelParameters";
  51359. export * from "babylonjs/Materials/imageProcessingConfiguration";
  51360. export * from "babylonjs/Materials/material";
  51361. export * from "babylonjs/Materials/materialDefines";
  51362. export * from "babylonjs/Materials/materialHelper";
  51363. export * from "babylonjs/Materials/multiMaterial";
  51364. export * from "babylonjs/Materials/PBR/index";
  51365. export * from "babylonjs/Materials/pushMaterial";
  51366. export * from "babylonjs/Materials/shaderMaterial";
  51367. export * from "babylonjs/Materials/standardMaterial";
  51368. export * from "babylonjs/Materials/Textures/index";
  51369. export * from "babylonjs/Materials/uniformBuffer";
  51370. export * from "babylonjs/Materials/materialFlags";
  51371. }
  51372. declare module "babylonjs/Maths/index" {
  51373. export * from "babylonjs/Maths/math.scalar";
  51374. export * from "babylonjs/Maths/math";
  51375. export * from "babylonjs/Maths/sphericalPolynomial";
  51376. }
  51377. declare module "babylonjs/Misc/workerPool" {
  51378. import { IDisposable } from "babylonjs/scene";
  51379. /**
  51380. * Helper class to push actions to a pool of workers.
  51381. */
  51382. export class WorkerPool implements IDisposable {
  51383. private _workerInfos;
  51384. private _pendingActions;
  51385. /**
  51386. * Constructor
  51387. * @param workers Array of workers to use for actions
  51388. */
  51389. constructor(workers: Array<Worker>);
  51390. /**
  51391. * Terminates all workers and clears any pending actions.
  51392. */
  51393. dispose(): void;
  51394. /**
  51395. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51396. * pended until a worker has completed its action.
  51397. * @param action The action to perform. Call onComplete when the action is complete.
  51398. */
  51399. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51400. private _execute;
  51401. }
  51402. }
  51403. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  51404. import { IDisposable } from "babylonjs/scene";
  51405. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51406. /**
  51407. * Configuration for Draco compression
  51408. */
  51409. export interface IDracoCompressionConfiguration {
  51410. /**
  51411. * Configuration for the decoder.
  51412. */
  51413. decoder?: {
  51414. /**
  51415. * The url to the WebAssembly module.
  51416. */
  51417. wasmUrl?: string;
  51418. /**
  51419. * The url to the WebAssembly binary.
  51420. */
  51421. wasmBinaryUrl?: string;
  51422. /**
  51423. * The url to the fallback JavaScript module.
  51424. */
  51425. fallbackUrl?: string;
  51426. };
  51427. }
  51428. /**
  51429. * Draco compression (https://google.github.io/draco/)
  51430. *
  51431. * This class wraps the Draco module.
  51432. *
  51433. * **Encoder**
  51434. *
  51435. * The encoder is not currently implemented.
  51436. *
  51437. * **Decoder**
  51438. *
  51439. * 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.
  51440. *
  51441. * To update the configuration, use the following code:
  51442. * ```javascript
  51443. * DracoCompression.Configuration = {
  51444. * decoder: {
  51445. * wasmUrl: "<url to the WebAssembly library>",
  51446. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51447. * fallbackUrl: "<url to the fallback JavaScript library>",
  51448. * }
  51449. * };
  51450. * ```
  51451. *
  51452. * 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.
  51453. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51454. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  51455. *
  51456. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  51457. * ```javascript
  51458. * var dracoCompression = new DracoCompression();
  51459. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  51460. * [VertexBuffer.PositionKind]: 0
  51461. * });
  51462. * ```
  51463. *
  51464. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  51465. */
  51466. export class DracoCompression implements IDisposable {
  51467. private _workerPoolPromise;
  51468. /**
  51469. * The configuration. Defaults to the following urls:
  51470. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  51471. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  51472. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  51473. */
  51474. static Configuration: IDracoCompressionConfiguration;
  51475. /**
  51476. * Returns true if the decoder is available.
  51477. */
  51478. static readonly DecoderAvailable: boolean;
  51479. /**
  51480. * Default number of workers to create when creating the draco compression object.
  51481. */
  51482. static DefaultNumWorkers: number;
  51483. private static GetDefaultNumWorkers;
  51484. /**
  51485. * Constructor
  51486. * @param numWorkers The number of workers for async operations
  51487. */
  51488. constructor(numWorkers?: number);
  51489. /**
  51490. * Stop all async operations and release resources.
  51491. */
  51492. dispose(): void;
  51493. /**
  51494. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  51495. * @returns a promise that resolves when ready
  51496. */
  51497. whenReadyAsync(): Promise<void>;
  51498. /**
  51499. * Decode Draco compressed mesh data to vertex data.
  51500. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  51501. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  51502. * @returns A promise that resolves with the decoded vertex data
  51503. */
  51504. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  51505. [kind: string]: number;
  51506. }): Promise<VertexData>;
  51507. /**
  51508. * The worker function that gets converted to a blob url to pass into a worker.
  51509. */
  51510. private static _Worker;
  51511. private _loadDecoderWasmBinaryAsync;
  51512. }
  51513. }
  51514. declare module "babylonjs/Meshes/Compression/index" {
  51515. export * from "babylonjs/Meshes/Compression/dracoCompression";
  51516. }
  51517. declare module "babylonjs/Meshes/csg" {
  51518. import { Nullable } from "babylonjs/types";
  51519. import { Scene } from "babylonjs/scene";
  51520. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  51521. import { Mesh } from "babylonjs/Meshes/mesh";
  51522. import { Material } from "babylonjs/Materials/material";
  51523. /**
  51524. * Class for building Constructive Solid Geometry
  51525. */
  51526. export class CSG {
  51527. private polygons;
  51528. /**
  51529. * The world matrix
  51530. */
  51531. matrix: Matrix;
  51532. /**
  51533. * Stores the position
  51534. */
  51535. position: Vector3;
  51536. /**
  51537. * Stores the rotation
  51538. */
  51539. rotation: Vector3;
  51540. /**
  51541. * Stores the rotation quaternion
  51542. */
  51543. rotationQuaternion: Nullable<Quaternion>;
  51544. /**
  51545. * Stores the scaling vector
  51546. */
  51547. scaling: Vector3;
  51548. /**
  51549. * Convert the Mesh to CSG
  51550. * @param mesh The Mesh to convert to CSG
  51551. * @returns A new CSG from the Mesh
  51552. */
  51553. static FromMesh(mesh: Mesh): CSG;
  51554. /**
  51555. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  51556. * @param polygons Polygons used to construct a CSG solid
  51557. */
  51558. private static FromPolygons;
  51559. /**
  51560. * Clones, or makes a deep copy, of the CSG
  51561. * @returns A new CSG
  51562. */
  51563. clone(): CSG;
  51564. /**
  51565. * Unions this CSG with another CSG
  51566. * @param csg The CSG to union against this CSG
  51567. * @returns The unioned CSG
  51568. */
  51569. union(csg: CSG): CSG;
  51570. /**
  51571. * Unions this CSG with another CSG in place
  51572. * @param csg The CSG to union against this CSG
  51573. */
  51574. unionInPlace(csg: CSG): void;
  51575. /**
  51576. * Subtracts this CSG with another CSG
  51577. * @param csg The CSG to subtract against this CSG
  51578. * @returns A new CSG
  51579. */
  51580. subtract(csg: CSG): CSG;
  51581. /**
  51582. * Subtracts this CSG with another CSG in place
  51583. * @param csg The CSG to subtact against this CSG
  51584. */
  51585. subtractInPlace(csg: CSG): void;
  51586. /**
  51587. * Intersect this CSG with another CSG
  51588. * @param csg The CSG to intersect against this CSG
  51589. * @returns A new CSG
  51590. */
  51591. intersect(csg: CSG): CSG;
  51592. /**
  51593. * Intersects this CSG with another CSG in place
  51594. * @param csg The CSG to intersect against this CSG
  51595. */
  51596. intersectInPlace(csg: CSG): void;
  51597. /**
  51598. * Return a new CSG solid with solid and empty space switched. This solid is
  51599. * not modified.
  51600. * @returns A new CSG solid with solid and empty space switched
  51601. */
  51602. inverse(): CSG;
  51603. /**
  51604. * Inverses the CSG in place
  51605. */
  51606. inverseInPlace(): void;
  51607. /**
  51608. * This is used to keep meshes transformations so they can be restored
  51609. * when we build back a Babylon Mesh
  51610. * NB : All CSG operations are performed in world coordinates
  51611. * @param csg The CSG to copy the transform attributes from
  51612. * @returns This CSG
  51613. */
  51614. copyTransformAttributes(csg: CSG): CSG;
  51615. /**
  51616. * Build Raw mesh from CSG
  51617. * Coordinates here are in world space
  51618. * @param name The name of the mesh geometry
  51619. * @param scene The Scene
  51620. * @param keepSubMeshes Specifies if the submeshes should be kept
  51621. * @returns A new Mesh
  51622. */
  51623. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  51624. /**
  51625. * Build Mesh from CSG taking material and transforms into account
  51626. * @param name The name of the Mesh
  51627. * @param material The material of the Mesh
  51628. * @param scene The Scene
  51629. * @param keepSubMeshes Specifies if submeshes should be kept
  51630. * @returns The new Mesh
  51631. */
  51632. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  51633. }
  51634. }
  51635. declare module "babylonjs/Meshes/trailMesh" {
  51636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51637. import { Mesh } from "babylonjs/Meshes/mesh";
  51638. import { Scene } from "babylonjs/scene";
  51639. /**
  51640. * Class used to create a trail following a mesh
  51641. */
  51642. export class TrailMesh extends Mesh {
  51643. private _generator;
  51644. private _autoStart;
  51645. private _running;
  51646. private _diameter;
  51647. private _length;
  51648. private _sectionPolygonPointsCount;
  51649. private _sectionVectors;
  51650. private _sectionNormalVectors;
  51651. private _beforeRenderObserver;
  51652. /**
  51653. * @constructor
  51654. * @param name The value used by scene.getMeshByName() to do a lookup.
  51655. * @param generator The mesh to generate a trail.
  51656. * @param scene The scene to add this mesh to.
  51657. * @param diameter Diameter of trailing mesh. Default is 1.
  51658. * @param length Length of trailing mesh. Default is 60.
  51659. * @param autoStart Automatically start trailing mesh. Default true.
  51660. */
  51661. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  51662. /**
  51663. * "TrailMesh"
  51664. * @returns "TrailMesh"
  51665. */
  51666. getClassName(): string;
  51667. private _createMesh;
  51668. /**
  51669. * Start trailing mesh.
  51670. */
  51671. start(): void;
  51672. /**
  51673. * Stop trailing mesh.
  51674. */
  51675. stop(): void;
  51676. /**
  51677. * Update trailing mesh geometry.
  51678. */
  51679. update(): void;
  51680. /**
  51681. * Returns a new TrailMesh object.
  51682. * @param name is a string, the name given to the new mesh
  51683. * @param newGenerator use new generator object for cloned trail mesh
  51684. * @returns a new mesh
  51685. */
  51686. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  51687. /**
  51688. * Serializes this trail mesh
  51689. * @param serializationObject object to write serialization to
  51690. */
  51691. serialize(serializationObject: any): void;
  51692. /**
  51693. * Parses a serialized trail mesh
  51694. * @param parsedMesh the serialized mesh
  51695. * @param scene the scene to create the trail mesh in
  51696. * @returns the created trail mesh
  51697. */
  51698. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  51699. }
  51700. }
  51701. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  51702. import { Vector4 } from "babylonjs/Maths/math";
  51703. import { Mesh } from "babylonjs/Meshes/mesh";
  51704. /**
  51705. * Class containing static functions to help procedurally build meshes
  51706. */
  51707. export class TorusKnotBuilder {
  51708. /**
  51709. * Creates a torus knot mesh
  51710. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51711. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51712. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51713. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51714. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51715. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51717. * @param name defines the name of the mesh
  51718. * @param options defines the options used to create the mesh
  51719. * @param scene defines the hosting scene
  51720. * @returns the torus knot mesh
  51721. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51722. */
  51723. static CreateTorusKnot(name: string, options: {
  51724. radius?: number;
  51725. tube?: number;
  51726. radialSegments?: number;
  51727. tubularSegments?: number;
  51728. p?: number;
  51729. q?: number;
  51730. updatable?: boolean;
  51731. sideOrientation?: number;
  51732. frontUVs?: Vector4;
  51733. backUVs?: Vector4;
  51734. }, scene: any): Mesh;
  51735. }
  51736. }
  51737. declare module "babylonjs/Meshes/polygonMesh" {
  51738. import { Scene } from "babylonjs/scene";
  51739. import { Vector2, Path2 } from "babylonjs/Maths/math";
  51740. import { Mesh } from "babylonjs/Meshes/mesh";
  51741. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51742. /**
  51743. * Polygon
  51744. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  51745. */
  51746. export class Polygon {
  51747. /**
  51748. * Creates a rectangle
  51749. * @param xmin bottom X coord
  51750. * @param ymin bottom Y coord
  51751. * @param xmax top X coord
  51752. * @param ymax top Y coord
  51753. * @returns points that make the resulting rectation
  51754. */
  51755. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  51756. /**
  51757. * Creates a circle
  51758. * @param radius radius of circle
  51759. * @param cx scale in x
  51760. * @param cy scale in y
  51761. * @param numberOfSides number of sides that make up the circle
  51762. * @returns points that make the resulting circle
  51763. */
  51764. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  51765. /**
  51766. * Creates a polygon from input string
  51767. * @param input Input polygon data
  51768. * @returns the parsed points
  51769. */
  51770. static Parse(input: string): Vector2[];
  51771. /**
  51772. * Starts building a polygon from x and y coordinates
  51773. * @param x x coordinate
  51774. * @param y y coordinate
  51775. * @returns the started path2
  51776. */
  51777. static StartingAt(x: number, y: number): Path2;
  51778. }
  51779. /**
  51780. * Builds a polygon
  51781. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  51782. */
  51783. export class PolygonMeshBuilder {
  51784. private _points;
  51785. private _outlinepoints;
  51786. private _holes;
  51787. private _name;
  51788. private _scene;
  51789. private _epoints;
  51790. private _eholes;
  51791. private _addToepoint;
  51792. /**
  51793. * Babylon reference to the earcut plugin.
  51794. */
  51795. bjsEarcut: any;
  51796. /**
  51797. * Creates a PolygonMeshBuilder
  51798. * @param name name of the builder
  51799. * @param contours Path of the polygon
  51800. * @param scene scene to add to when creating the mesh
  51801. * @param earcutInjection can be used to inject your own earcut reference
  51802. */
  51803. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  51804. /**
  51805. * Adds a whole within the polygon
  51806. * @param hole Array of points defining the hole
  51807. * @returns this
  51808. */
  51809. addHole(hole: Vector2[]): PolygonMeshBuilder;
  51810. /**
  51811. * Creates the polygon
  51812. * @param updatable If the mesh should be updatable
  51813. * @param depth The depth of the mesh created
  51814. * @returns the created mesh
  51815. */
  51816. build(updatable?: boolean, depth?: number): Mesh;
  51817. /**
  51818. * Creates the polygon
  51819. * @param depth The depth of the mesh created
  51820. * @returns the created VertexData
  51821. */
  51822. buildVertexData(depth?: number): VertexData;
  51823. /**
  51824. * Adds a side to the polygon
  51825. * @param positions points that make the polygon
  51826. * @param normals normals of the polygon
  51827. * @param uvs uvs of the polygon
  51828. * @param indices indices of the polygon
  51829. * @param bounds bounds of the polygon
  51830. * @param points points of the polygon
  51831. * @param depth depth of the polygon
  51832. * @param flip flip of the polygon
  51833. */
  51834. private addSide;
  51835. }
  51836. }
  51837. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  51838. import { Scene } from "babylonjs/scene";
  51839. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  51840. import { Mesh } from "babylonjs/Meshes/mesh";
  51841. import { Nullable } from "babylonjs/types";
  51842. /**
  51843. * Class containing static functions to help procedurally build meshes
  51844. */
  51845. export class PolygonBuilder {
  51846. /**
  51847. * Creates a polygon mesh
  51848. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51849. * * 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
  51850. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51852. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  51853. * * Remember you can only change the shape positions, not their number when updating a polygon
  51854. * @param name defines the name of the mesh
  51855. * @param options defines the options used to create the mesh
  51856. * @param scene defines the hosting scene
  51857. * @param earcutInjection can be used to inject your own earcut reference
  51858. * @returns the polygon mesh
  51859. */
  51860. static CreatePolygon(name: string, options: {
  51861. shape: Vector3[];
  51862. holes?: Vector3[][];
  51863. depth?: number;
  51864. faceUV?: Vector4[];
  51865. faceColors?: Color4[];
  51866. updatable?: boolean;
  51867. sideOrientation?: number;
  51868. frontUVs?: Vector4;
  51869. backUVs?: Vector4;
  51870. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51871. /**
  51872. * Creates an extruded polygon mesh, with depth in the Y direction.
  51873. * * 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)
  51874. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51875. * @param name defines the name of the mesh
  51876. * @param options defines the options used to create the mesh
  51877. * @param scene defines the hosting scene
  51878. * @param earcutInjection can be used to inject your own earcut reference
  51879. * @returns the polygon mesh
  51880. */
  51881. static ExtrudePolygon(name: string, options: {
  51882. shape: Vector3[];
  51883. holes?: Vector3[][];
  51884. depth?: number;
  51885. faceUV?: Vector4[];
  51886. faceColors?: Color4[];
  51887. updatable?: boolean;
  51888. sideOrientation?: number;
  51889. frontUVs?: Vector4;
  51890. backUVs?: Vector4;
  51891. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51892. }
  51893. }
  51894. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  51895. import { Scene } from "babylonjs/scene";
  51896. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51897. import { Mesh } from "babylonjs/Meshes/mesh";
  51898. import { Nullable } from "babylonjs/types";
  51899. /**
  51900. * Class containing static functions to help procedurally build meshes
  51901. */
  51902. export class LatheBuilder {
  51903. /**
  51904. * Creates lathe mesh.
  51905. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  51906. * * 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
  51907. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  51908. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  51909. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  51910. * * 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
  51911. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  51912. * * 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
  51913. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51914. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51915. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51917. * @param name defines the name of the mesh
  51918. * @param options defines the options used to create the mesh
  51919. * @param scene defines the hosting scene
  51920. * @returns the lathe mesh
  51921. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  51922. */
  51923. static CreateLathe(name: string, options: {
  51924. shape: Vector3[];
  51925. radius?: number;
  51926. tessellation?: number;
  51927. clip?: number;
  51928. arc?: number;
  51929. closed?: boolean;
  51930. updatable?: boolean;
  51931. sideOrientation?: number;
  51932. frontUVs?: Vector4;
  51933. backUVs?: Vector4;
  51934. cap?: number;
  51935. invertUV?: boolean;
  51936. }, scene?: Nullable<Scene>): Mesh;
  51937. }
  51938. }
  51939. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  51940. import { Nullable } from "babylonjs/types";
  51941. import { Scene } from "babylonjs/scene";
  51942. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51943. import { Mesh } from "babylonjs/Meshes/mesh";
  51944. /**
  51945. * Class containing static functions to help procedurally build meshes
  51946. */
  51947. export class TubeBuilder {
  51948. /**
  51949. * Creates a tube mesh.
  51950. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51951. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51952. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51953. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51954. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51955. * * 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)
  51956. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51957. * * 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
  51958. * * 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
  51959. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51960. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51961. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51963. * @param name defines the name of the mesh
  51964. * @param options defines the options used to create the mesh
  51965. * @param scene defines the hosting scene
  51966. * @returns the tube mesh
  51967. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51968. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  51969. */
  51970. static CreateTube(name: string, options: {
  51971. path: Vector3[];
  51972. radius?: number;
  51973. tessellation?: number;
  51974. radiusFunction?: {
  51975. (i: number, distance: number): number;
  51976. };
  51977. cap?: number;
  51978. arc?: number;
  51979. updatable?: boolean;
  51980. sideOrientation?: number;
  51981. frontUVs?: Vector4;
  51982. backUVs?: Vector4;
  51983. instance?: Mesh;
  51984. invertUV?: boolean;
  51985. }, scene?: Nullable<Scene>): Mesh;
  51986. }
  51987. }
  51988. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  51989. import { Scene } from "babylonjs/scene";
  51990. import { Vector4 } from "babylonjs/Maths/math";
  51991. import { Mesh } from "babylonjs/Meshes/mesh";
  51992. import { Nullable } from "babylonjs/types";
  51993. /**
  51994. * Class containing static functions to help procedurally build meshes
  51995. */
  51996. export class IcoSphereBuilder {
  51997. /**
  51998. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  51999. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52000. * * 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`)
  52001. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52002. * * 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
  52003. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52004. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52006. * @param name defines the name of the mesh
  52007. * @param options defines the options used to create the mesh
  52008. * @param scene defines the hosting scene
  52009. * @returns the icosahedron mesh
  52010. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52011. */
  52012. static CreateIcoSphere(name: string, options: {
  52013. radius?: number;
  52014. radiusX?: number;
  52015. radiusY?: number;
  52016. radiusZ?: number;
  52017. flat?: boolean;
  52018. subdivisions?: number;
  52019. sideOrientation?: number;
  52020. frontUVs?: Vector4;
  52021. backUVs?: Vector4;
  52022. updatable?: boolean;
  52023. }, scene?: Nullable<Scene>): Mesh;
  52024. }
  52025. }
  52026. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  52027. import { Vector3 } from "babylonjs/Maths/math";
  52028. import { Mesh } from "babylonjs/Meshes/mesh";
  52029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52030. /**
  52031. * Class containing static functions to help procedurally build meshes
  52032. */
  52033. export class DecalBuilder {
  52034. /**
  52035. * Creates a decal mesh.
  52036. * 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
  52037. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52038. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52039. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52040. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52041. * @param name defines the name of the mesh
  52042. * @param sourceMesh defines the mesh where the decal must be applied
  52043. * @param options defines the options used to create the mesh
  52044. * @param scene defines the hosting scene
  52045. * @returns the decal mesh
  52046. * @see https://doc.babylonjs.com/how_to/decals
  52047. */
  52048. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52049. position?: Vector3;
  52050. normal?: Vector3;
  52051. size?: Vector3;
  52052. angle?: number;
  52053. }): Mesh;
  52054. }
  52055. }
  52056. declare module "babylonjs/Meshes/meshBuilder" {
  52057. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  52058. import { Nullable } from "babylonjs/types";
  52059. import { Scene } from "babylonjs/scene";
  52060. import { Mesh } from "babylonjs/Meshes/mesh";
  52061. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52062. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52064. /**
  52065. * Class containing static functions to help procedurally build meshes
  52066. */
  52067. export class MeshBuilder {
  52068. /**
  52069. * Creates a box mesh
  52070. * * The parameter `size` sets the size (float) of each box side (default 1)
  52071. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52072. * * 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)
  52073. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52075. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52077. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52078. * @param name defines the name of the mesh
  52079. * @param options defines the options used to create the mesh
  52080. * @param scene defines the hosting scene
  52081. * @returns the box mesh
  52082. */
  52083. static CreateBox(name: string, options: {
  52084. size?: number;
  52085. width?: number;
  52086. height?: number;
  52087. depth?: number;
  52088. faceUV?: Vector4[];
  52089. faceColors?: Color4[];
  52090. sideOrientation?: number;
  52091. frontUVs?: Vector4;
  52092. backUVs?: Vector4;
  52093. updatable?: boolean;
  52094. }, scene?: Nullable<Scene>): Mesh;
  52095. /**
  52096. * Creates a sphere mesh
  52097. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52098. * * 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`)
  52099. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52100. * * 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
  52101. * * 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)
  52102. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52103. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52105. * @param name defines the name of the mesh
  52106. * @param options defines the options used to create the mesh
  52107. * @param scene defines the hosting scene
  52108. * @returns the sphere mesh
  52109. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52110. */
  52111. static CreateSphere(name: string, options: {
  52112. segments?: number;
  52113. diameter?: number;
  52114. diameterX?: number;
  52115. diameterY?: number;
  52116. diameterZ?: number;
  52117. arc?: number;
  52118. slice?: number;
  52119. sideOrientation?: number;
  52120. frontUVs?: Vector4;
  52121. backUVs?: Vector4;
  52122. updatable?: boolean;
  52123. }, scene?: Nullable<Scene>): Mesh;
  52124. /**
  52125. * Creates a plane polygonal mesh. By default, this is a disc
  52126. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52127. * * 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
  52128. * * 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
  52129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52130. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52132. * @param name defines the name of the mesh
  52133. * @param options defines the options used to create the mesh
  52134. * @param scene defines the hosting scene
  52135. * @returns the plane polygonal mesh
  52136. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52137. */
  52138. static CreateDisc(name: string, options: {
  52139. radius?: number;
  52140. tessellation?: number;
  52141. arc?: number;
  52142. updatable?: boolean;
  52143. sideOrientation?: number;
  52144. frontUVs?: Vector4;
  52145. backUVs?: Vector4;
  52146. }, scene?: Nullable<Scene>): Mesh;
  52147. /**
  52148. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52149. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52150. * * 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`)
  52151. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52152. * * 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
  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 mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52156. * @param name defines the name of the mesh
  52157. * @param options defines the options used to create the mesh
  52158. * @param scene defines the hosting scene
  52159. * @returns the icosahedron mesh
  52160. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52161. */
  52162. static CreateIcoSphere(name: string, options: {
  52163. radius?: number;
  52164. radiusX?: number;
  52165. radiusY?: number;
  52166. radiusZ?: number;
  52167. flat?: boolean;
  52168. subdivisions?: number;
  52169. sideOrientation?: number;
  52170. frontUVs?: Vector4;
  52171. backUVs?: Vector4;
  52172. updatable?: boolean;
  52173. }, scene?: Nullable<Scene>): Mesh;
  52174. /**
  52175. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52176. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52177. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52178. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52179. * * 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
  52180. * * 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
  52181. * * 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
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52185. * * 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
  52186. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52187. * * 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
  52188. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52190. * @param name defines the name of the mesh
  52191. * @param options defines the options used to create the mesh
  52192. * @param scene defines the hosting scene
  52193. * @returns the ribbon mesh
  52194. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52195. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52196. */
  52197. static CreateRibbon(name: string, options: {
  52198. pathArray: Vector3[][];
  52199. closeArray?: boolean;
  52200. closePath?: boolean;
  52201. offset?: number;
  52202. updatable?: boolean;
  52203. sideOrientation?: number;
  52204. frontUVs?: Vector4;
  52205. backUVs?: Vector4;
  52206. instance?: Mesh;
  52207. invertUV?: boolean;
  52208. uvs?: Vector2[];
  52209. colors?: Color4[];
  52210. }, scene?: Nullable<Scene>): Mesh;
  52211. /**
  52212. * Creates a cylinder or a cone mesh
  52213. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52214. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52215. * * 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.
  52216. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52217. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52218. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52219. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52220. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52221. * * 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).
  52222. * * 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
  52223. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52224. * * 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
  52225. * * 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.
  52226. * * If `enclose` is false, a ring surface is one element.
  52227. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52228. * * 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
  52229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52230. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52232. * @param name defines the name of the mesh
  52233. * @param options defines the options used to create the mesh
  52234. * @param scene defines the hosting scene
  52235. * @returns the cylinder mesh
  52236. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52237. */
  52238. static CreateCylinder(name: string, options: {
  52239. height?: number;
  52240. diameterTop?: number;
  52241. diameterBottom?: number;
  52242. diameter?: number;
  52243. tessellation?: number;
  52244. subdivisions?: number;
  52245. arc?: number;
  52246. faceColors?: Color4[];
  52247. faceUV?: Vector4[];
  52248. updatable?: boolean;
  52249. hasRings?: boolean;
  52250. enclose?: boolean;
  52251. sideOrientation?: number;
  52252. frontUVs?: Vector4;
  52253. backUVs?: Vector4;
  52254. }, scene?: Nullable<Scene>): Mesh;
  52255. /**
  52256. * Creates a torus mesh
  52257. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52258. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52259. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52260. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52261. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52263. * @param name defines the name of the mesh
  52264. * @param options defines the options used to create the mesh
  52265. * @param scene defines the hosting scene
  52266. * @returns the torus mesh
  52267. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52268. */
  52269. static CreateTorus(name: string, options: {
  52270. diameter?: number;
  52271. thickness?: number;
  52272. tessellation?: number;
  52273. updatable?: boolean;
  52274. sideOrientation?: number;
  52275. frontUVs?: Vector4;
  52276. backUVs?: Vector4;
  52277. }, scene?: Nullable<Scene>): Mesh;
  52278. /**
  52279. * Creates a torus knot mesh
  52280. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52281. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52282. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52283. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52284. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52285. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52287. * @param name defines the name of the mesh
  52288. * @param options defines the options used to create the mesh
  52289. * @param scene defines the hosting scene
  52290. * @returns the torus knot mesh
  52291. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52292. */
  52293. static CreateTorusKnot(name: string, options: {
  52294. radius?: number;
  52295. tube?: number;
  52296. radialSegments?: number;
  52297. tubularSegments?: number;
  52298. p?: number;
  52299. q?: number;
  52300. updatable?: boolean;
  52301. sideOrientation?: number;
  52302. frontUVs?: Vector4;
  52303. backUVs?: Vector4;
  52304. }, scene?: Nullable<Scene>): Mesh;
  52305. /**
  52306. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52307. * * 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
  52308. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52309. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52310. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52311. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52312. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52313. * * 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
  52314. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52316. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52317. * @param name defines the name of the new line system
  52318. * @param options defines the options used to create the line system
  52319. * @param scene defines the hosting scene
  52320. * @returns a new line system mesh
  52321. */
  52322. static CreateLineSystem(name: string, options: {
  52323. lines: Vector3[][];
  52324. updatable?: boolean;
  52325. instance?: Nullable<LinesMesh>;
  52326. colors?: Nullable<Color4[][]>;
  52327. useVertexAlpha?: boolean;
  52328. }, scene: Nullable<Scene>): LinesMesh;
  52329. /**
  52330. * Creates a line mesh
  52331. * 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
  52332. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52333. * * The parameter `points` is an array successive Vector3
  52334. * * 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
  52335. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52336. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52337. * * When updating an instance, remember that only point positions can change, not the number of points
  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. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52340. * @param name defines the name of the new line system
  52341. * @param options defines the options used to create the line system
  52342. * @param scene defines the hosting scene
  52343. * @returns a new line mesh
  52344. */
  52345. static CreateLines(name: string, options: {
  52346. points: Vector3[];
  52347. updatable?: boolean;
  52348. instance?: Nullable<LinesMesh>;
  52349. colors?: Color4[];
  52350. useVertexAlpha?: boolean;
  52351. }, scene?: Nullable<Scene>): LinesMesh;
  52352. /**
  52353. * Creates a dashed line mesh
  52354. * * 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
  52355. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52356. * * The parameter `points` is an array successive Vector3
  52357. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52358. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52359. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52360. * * 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
  52361. * * When updating an instance, remember that only point positions can change, not the number of points
  52362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52363. * @param name defines the name of the mesh
  52364. * @param options defines the options used to create the mesh
  52365. * @param scene defines the hosting scene
  52366. * @returns the dashed line mesh
  52367. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52368. */
  52369. static CreateDashedLines(name: string, options: {
  52370. points: Vector3[];
  52371. dashSize?: number;
  52372. gapSize?: number;
  52373. dashNb?: number;
  52374. updatable?: boolean;
  52375. instance?: LinesMesh;
  52376. }, scene?: Nullable<Scene>): LinesMesh;
  52377. /**
  52378. * 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.
  52379. * * 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.
  52380. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52381. * * 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.
  52382. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52383. * * 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
  52384. * * 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
  52385. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52387. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52388. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52390. * @param name defines the name of the mesh
  52391. * @param options defines the options used to create the mesh
  52392. * @param scene defines the hosting scene
  52393. * @returns the extruded shape mesh
  52394. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52395. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52396. */
  52397. static ExtrudeShape(name: string, options: {
  52398. shape: Vector3[];
  52399. path: Vector3[];
  52400. scale?: number;
  52401. rotation?: number;
  52402. cap?: number;
  52403. updatable?: boolean;
  52404. sideOrientation?: number;
  52405. frontUVs?: Vector4;
  52406. backUVs?: Vector4;
  52407. instance?: Mesh;
  52408. invertUV?: boolean;
  52409. }, scene?: Nullable<Scene>): Mesh;
  52410. /**
  52411. * Creates an custom extruded shape mesh.
  52412. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52413. * * 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.
  52414. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52415. * * 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
  52416. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52417. * * 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
  52418. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52419. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52420. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52421. * * 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
  52422. * * 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
  52423. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52425. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52426. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52428. * @param name defines the name of the mesh
  52429. * @param options defines the options used to create the mesh
  52430. * @param scene defines the hosting scene
  52431. * @returns the custom extruded shape mesh
  52432. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52433. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52434. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52435. */
  52436. static ExtrudeShapeCustom(name: string, options: {
  52437. shape: Vector3[];
  52438. path: Vector3[];
  52439. scaleFunction?: any;
  52440. rotationFunction?: any;
  52441. ribbonCloseArray?: boolean;
  52442. ribbonClosePath?: boolean;
  52443. cap?: number;
  52444. updatable?: boolean;
  52445. sideOrientation?: number;
  52446. frontUVs?: Vector4;
  52447. backUVs?: Vector4;
  52448. instance?: Mesh;
  52449. invertUV?: boolean;
  52450. }, scene?: Nullable<Scene>): Mesh;
  52451. /**
  52452. * Creates lathe mesh.
  52453. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52454. * * 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
  52455. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52456. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52457. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52458. * * 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
  52459. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52460. * * 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
  52461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52462. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52463. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52465. * @param name defines the name of the mesh
  52466. * @param options defines the options used to create the mesh
  52467. * @param scene defines the hosting scene
  52468. * @returns the lathe mesh
  52469. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52470. */
  52471. static CreateLathe(name: string, options: {
  52472. shape: Vector3[];
  52473. radius?: number;
  52474. tessellation?: number;
  52475. clip?: number;
  52476. arc?: number;
  52477. closed?: boolean;
  52478. updatable?: boolean;
  52479. sideOrientation?: number;
  52480. frontUVs?: Vector4;
  52481. backUVs?: Vector4;
  52482. cap?: number;
  52483. invertUV?: boolean;
  52484. }, scene?: Nullable<Scene>): Mesh;
  52485. /**
  52486. * Creates a plane mesh
  52487. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  52488. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  52489. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  52490. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52491. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52493. * @param name defines the name of the mesh
  52494. * @param options defines the options used to create the mesh
  52495. * @param scene defines the hosting scene
  52496. * @returns the plane mesh
  52497. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52498. */
  52499. static CreatePlane(name: string, options: {
  52500. size?: number;
  52501. width?: number;
  52502. height?: number;
  52503. sideOrientation?: number;
  52504. frontUVs?: Vector4;
  52505. backUVs?: Vector4;
  52506. updatable?: boolean;
  52507. sourcePlane?: Plane;
  52508. }, scene?: Nullable<Scene>): Mesh;
  52509. /**
  52510. * Creates a ground mesh
  52511. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52512. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52514. * @param name defines the name of the mesh
  52515. * @param options defines the options used to create the mesh
  52516. * @param scene defines the hosting scene
  52517. * @returns the ground mesh
  52518. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52519. */
  52520. static CreateGround(name: string, options: {
  52521. width?: number;
  52522. height?: number;
  52523. subdivisions?: number;
  52524. subdivisionsX?: number;
  52525. subdivisionsY?: number;
  52526. updatable?: boolean;
  52527. }, scene?: Nullable<Scene>): Mesh;
  52528. /**
  52529. * Creates a tiled ground mesh
  52530. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52531. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52532. * * 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
  52533. * * 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
  52534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52535. * @param name defines the name of the mesh
  52536. * @param options defines the options used to create the mesh
  52537. * @param scene defines the hosting scene
  52538. * @returns the tiled ground mesh
  52539. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52540. */
  52541. static CreateTiledGround(name: string, options: {
  52542. xmin: number;
  52543. zmin: number;
  52544. xmax: number;
  52545. zmax: number;
  52546. subdivisions?: {
  52547. w: number;
  52548. h: number;
  52549. };
  52550. precision?: {
  52551. w: number;
  52552. h: number;
  52553. };
  52554. updatable?: boolean;
  52555. }, scene?: Nullable<Scene>): Mesh;
  52556. /**
  52557. * Creates a ground mesh from a height map
  52558. * * The parameter `url` sets the URL of the height map image resource.
  52559. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52560. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52561. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52562. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52563. * * 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.
  52564. * * 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).
  52565. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52567. * @param name defines the name of the mesh
  52568. * @param url defines the url to the height map
  52569. * @param options defines the options used to create the mesh
  52570. * @param scene defines the hosting scene
  52571. * @returns the ground mesh
  52572. * @see https://doc.babylonjs.com/babylon101/height_map
  52573. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52574. */
  52575. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52576. width?: number;
  52577. height?: number;
  52578. subdivisions?: number;
  52579. minHeight?: number;
  52580. maxHeight?: number;
  52581. colorFilter?: Color3;
  52582. alphaFilter?: number;
  52583. updatable?: boolean;
  52584. onReady?: (mesh: GroundMesh) => void;
  52585. }, scene?: Nullable<Scene>): GroundMesh;
  52586. /**
  52587. * Creates a polygon mesh
  52588. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52589. * * 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
  52590. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52592. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52593. * * Remember you can only change the shape positions, not their number when updating a polygon
  52594. * @param name defines the name of the mesh
  52595. * @param options defines the options used to create the mesh
  52596. * @param scene defines the hosting scene
  52597. * @param earcutInjection can be used to inject your own earcut reference
  52598. * @returns the polygon mesh
  52599. */
  52600. static CreatePolygon(name: string, options: {
  52601. shape: Vector3[];
  52602. holes?: Vector3[][];
  52603. depth?: number;
  52604. faceUV?: Vector4[];
  52605. faceColors?: Color4[];
  52606. updatable?: boolean;
  52607. sideOrientation?: number;
  52608. frontUVs?: Vector4;
  52609. backUVs?: Vector4;
  52610. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52611. /**
  52612. * Creates an extruded polygon mesh, with depth in the Y direction.
  52613. * * 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)
  52614. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52615. * @param name defines the name of the mesh
  52616. * @param options defines the options used to create the mesh
  52617. * @param scene defines the hosting scene
  52618. * @param earcutInjection can be used to inject your own earcut reference
  52619. * @returns the polygon mesh
  52620. */
  52621. static ExtrudePolygon(name: string, options: {
  52622. shape: Vector3[];
  52623. holes?: Vector3[][];
  52624. depth?: number;
  52625. faceUV?: Vector4[];
  52626. faceColors?: Color4[];
  52627. updatable?: boolean;
  52628. sideOrientation?: number;
  52629. frontUVs?: Vector4;
  52630. backUVs?: Vector4;
  52631. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52632. /**
  52633. * Creates a tube mesh.
  52634. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52635. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52636. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52637. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52638. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52639. * * 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)
  52640. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52641. * * 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
  52642. * * 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
  52643. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52644. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52645. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52647. * @param name defines the name of the mesh
  52648. * @param options defines the options used to create the mesh
  52649. * @param scene defines the hosting scene
  52650. * @returns the tube mesh
  52651. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52652. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52653. */
  52654. static CreateTube(name: string, options: {
  52655. path: Vector3[];
  52656. radius?: number;
  52657. tessellation?: number;
  52658. radiusFunction?: {
  52659. (i: number, distance: number): number;
  52660. };
  52661. cap?: number;
  52662. arc?: number;
  52663. updatable?: boolean;
  52664. sideOrientation?: number;
  52665. frontUVs?: Vector4;
  52666. backUVs?: Vector4;
  52667. instance?: Mesh;
  52668. invertUV?: boolean;
  52669. }, scene?: Nullable<Scene>): Mesh;
  52670. /**
  52671. * Creates a polyhedron mesh
  52672. * * 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
  52673. * * The parameter `size` (positive float, default 1) sets the polygon size
  52674. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52675. * * 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`
  52676. * * 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
  52677. * * 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)`)
  52678. * * 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
  52679. * * 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
  52680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52681. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52683. * @param name defines the name of the mesh
  52684. * @param options defines the options used to create the mesh
  52685. * @param scene defines the hosting scene
  52686. * @returns the polyhedron mesh
  52687. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52688. */
  52689. static CreatePolyhedron(name: string, options: {
  52690. type?: number;
  52691. size?: number;
  52692. sizeX?: number;
  52693. sizeY?: number;
  52694. sizeZ?: number;
  52695. custom?: any;
  52696. faceUV?: Vector4[];
  52697. faceColors?: Color4[];
  52698. flat?: boolean;
  52699. updatable?: boolean;
  52700. sideOrientation?: number;
  52701. frontUVs?: Vector4;
  52702. backUVs?: Vector4;
  52703. }, scene?: Nullable<Scene>): Mesh;
  52704. /**
  52705. * Creates a decal mesh.
  52706. * 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
  52707. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52708. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52709. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52710. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52711. * @param name defines the name of the mesh
  52712. * @param sourceMesh defines the mesh where the decal must be applied
  52713. * @param options defines the options used to create the mesh
  52714. * @param scene defines the hosting scene
  52715. * @returns the decal mesh
  52716. * @see https://doc.babylonjs.com/how_to/decals
  52717. */
  52718. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52719. position?: Vector3;
  52720. normal?: Vector3;
  52721. size?: Vector3;
  52722. angle?: number;
  52723. }): Mesh;
  52724. }
  52725. }
  52726. declare module "babylonjs/Meshes/meshSimplification" {
  52727. import { Mesh } from "babylonjs/Meshes/mesh";
  52728. /**
  52729. * A simplifier interface for future simplification implementations
  52730. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52731. */
  52732. export interface ISimplifier {
  52733. /**
  52734. * Simplification of a given mesh according to the given settings.
  52735. * Since this requires computation, it is assumed that the function runs async.
  52736. * @param settings The settings of the simplification, including quality and distance
  52737. * @param successCallback A callback that will be called after the mesh was simplified.
  52738. * @param errorCallback in case of an error, this callback will be called. optional.
  52739. */
  52740. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  52741. }
  52742. /**
  52743. * Expected simplification settings.
  52744. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  52745. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52746. */
  52747. export interface ISimplificationSettings {
  52748. /**
  52749. * Gets or sets the expected quality
  52750. */
  52751. quality: number;
  52752. /**
  52753. * Gets or sets the distance when this optimized version should be used
  52754. */
  52755. distance: number;
  52756. /**
  52757. * Gets an already optimized mesh
  52758. */
  52759. optimizeMesh?: boolean;
  52760. }
  52761. /**
  52762. * Class used to specify simplification options
  52763. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52764. */
  52765. export class SimplificationSettings implements ISimplificationSettings {
  52766. /** expected quality */
  52767. quality: number;
  52768. /** distance when this optimized version should be used */
  52769. distance: number;
  52770. /** already optimized mesh */
  52771. optimizeMesh?: boolean | undefined;
  52772. /**
  52773. * Creates a SimplificationSettings
  52774. * @param quality expected quality
  52775. * @param distance distance when this optimized version should be used
  52776. * @param optimizeMesh already optimized mesh
  52777. */
  52778. constructor(
  52779. /** expected quality */
  52780. quality: number,
  52781. /** distance when this optimized version should be used */
  52782. distance: number,
  52783. /** already optimized mesh */
  52784. optimizeMesh?: boolean | undefined);
  52785. }
  52786. /**
  52787. * Interface used to define a simplification task
  52788. */
  52789. export interface ISimplificationTask {
  52790. /**
  52791. * Array of settings
  52792. */
  52793. settings: Array<ISimplificationSettings>;
  52794. /**
  52795. * Simplification type
  52796. */
  52797. simplificationType: SimplificationType;
  52798. /**
  52799. * Mesh to simplify
  52800. */
  52801. mesh: Mesh;
  52802. /**
  52803. * Callback called on success
  52804. */
  52805. successCallback?: () => void;
  52806. /**
  52807. * Defines if parallel processing can be used
  52808. */
  52809. parallelProcessing: boolean;
  52810. }
  52811. /**
  52812. * Queue used to order the simplification tasks
  52813. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52814. */
  52815. export class SimplificationQueue {
  52816. private _simplificationArray;
  52817. /**
  52818. * Gets a boolean indicating that the process is still running
  52819. */
  52820. running: boolean;
  52821. /**
  52822. * Creates a new queue
  52823. */
  52824. constructor();
  52825. /**
  52826. * Adds a new simplification task
  52827. * @param task defines a task to add
  52828. */
  52829. addTask(task: ISimplificationTask): void;
  52830. /**
  52831. * Execute next task
  52832. */
  52833. executeNext(): void;
  52834. /**
  52835. * Execute a simplification task
  52836. * @param task defines the task to run
  52837. */
  52838. runSimplification(task: ISimplificationTask): void;
  52839. private getSimplifier;
  52840. }
  52841. /**
  52842. * The implemented types of simplification
  52843. * At the moment only Quadratic Error Decimation is implemented
  52844. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52845. */
  52846. export enum SimplificationType {
  52847. /** Quadratic error decimation */
  52848. QUADRATIC = 0
  52849. }
  52850. }
  52851. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  52852. import { Scene } from "babylonjs/scene";
  52853. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  52854. import { ISceneComponent } from "babylonjs/sceneComponent";
  52855. module "babylonjs/scene" {
  52856. interface Scene {
  52857. /** @hidden (Backing field) */
  52858. _simplificationQueue: SimplificationQueue;
  52859. /**
  52860. * Gets or sets the simplification queue attached to the scene
  52861. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52862. */
  52863. simplificationQueue: SimplificationQueue;
  52864. }
  52865. }
  52866. module "babylonjs/Meshes/mesh" {
  52867. interface Mesh {
  52868. /**
  52869. * Simplify the mesh according to the given array of settings.
  52870. * Function will return immediately and will simplify async
  52871. * @param settings a collection of simplification settings
  52872. * @param parallelProcessing should all levels calculate parallel or one after the other
  52873. * @param simplificationType the type of simplification to run
  52874. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  52875. * @returns the current mesh
  52876. */
  52877. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  52878. }
  52879. }
  52880. /**
  52881. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  52882. * created in a scene
  52883. */
  52884. export class SimplicationQueueSceneComponent implements ISceneComponent {
  52885. /**
  52886. * The component name helpfull to identify the component in the list of scene components.
  52887. */
  52888. readonly name: string;
  52889. /**
  52890. * The scene the component belongs to.
  52891. */
  52892. scene: Scene;
  52893. /**
  52894. * Creates a new instance of the component for the given scene
  52895. * @param scene Defines the scene to register the component in
  52896. */
  52897. constructor(scene: Scene);
  52898. /**
  52899. * Registers the component in a given scene
  52900. */
  52901. register(): void;
  52902. /**
  52903. * Rebuilds the elements related to this component in case of
  52904. * context lost for instance.
  52905. */
  52906. rebuild(): void;
  52907. /**
  52908. * Disposes the component and the associated ressources
  52909. */
  52910. dispose(): void;
  52911. private _beforeCameraUpdate;
  52912. }
  52913. }
  52914. declare module "babylonjs/Meshes/Builders/index" {
  52915. export * from "babylonjs/Meshes/Builders/boxBuilder";
  52916. export * from "babylonjs/Meshes/Builders/discBuilder";
  52917. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  52918. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  52919. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  52920. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  52921. export * from "babylonjs/Meshes/Builders/torusBuilder";
  52922. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  52923. export * from "babylonjs/Meshes/Builders/linesBuilder";
  52924. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  52925. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  52926. export * from "babylonjs/Meshes/Builders/latheBuilder";
  52927. export * from "babylonjs/Meshes/Builders/planeBuilder";
  52928. export * from "babylonjs/Meshes/Builders/groundBuilder";
  52929. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  52930. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  52931. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  52932. export * from "babylonjs/Meshes/Builders/decalBuilder";
  52933. }
  52934. declare module "babylonjs/Meshes/index" {
  52935. export * from "babylonjs/Meshes/abstractMesh";
  52936. export * from "babylonjs/Meshes/buffer";
  52937. export * from "babylonjs/Meshes/Compression/index";
  52938. export * from "babylonjs/Meshes/csg";
  52939. export * from "babylonjs/Meshes/geometry";
  52940. export * from "babylonjs/Meshes/groundMesh";
  52941. export * from "babylonjs/Meshes/trailMesh";
  52942. export * from "babylonjs/Meshes/instancedMesh";
  52943. export * from "babylonjs/Meshes/linesMesh";
  52944. export * from "babylonjs/Meshes/mesh";
  52945. export * from "babylonjs/Meshes/mesh.vertexData";
  52946. export * from "babylonjs/Meshes/meshBuilder";
  52947. export * from "babylonjs/Meshes/meshSimplification";
  52948. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  52949. export * from "babylonjs/Meshes/polygonMesh";
  52950. export * from "babylonjs/Meshes/subMesh";
  52951. export * from "babylonjs/Meshes/transformNode";
  52952. export * from "babylonjs/Meshes/Builders/index";
  52953. }
  52954. declare module "babylonjs/Morph/index" {
  52955. export * from "babylonjs/Morph/morphTarget";
  52956. export * from "babylonjs/Morph/morphTargetManager";
  52957. }
  52958. declare module "babylonjs/Offline/database" {
  52959. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  52960. /**
  52961. * Class used to enable access to IndexedDB
  52962. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  52963. */
  52964. export class Database implements IOfflineProvider {
  52965. private _callbackManifestChecked;
  52966. private _currentSceneUrl;
  52967. private _db;
  52968. private _enableSceneOffline;
  52969. private _enableTexturesOffline;
  52970. private _manifestVersionFound;
  52971. private _mustUpdateRessources;
  52972. private _hasReachedQuota;
  52973. private _isSupported;
  52974. private _idbFactory;
  52975. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  52976. private static IsUASupportingBlobStorage;
  52977. /**
  52978. * Gets a boolean indicating if Database storate is enabled (off by default)
  52979. */
  52980. static IDBStorageEnabled: boolean;
  52981. /**
  52982. * Gets a boolean indicating if scene must be saved in the database
  52983. */
  52984. readonly enableSceneOffline: boolean;
  52985. /**
  52986. * Gets a boolean indicating if textures must be saved in the database
  52987. */
  52988. readonly enableTexturesOffline: boolean;
  52989. /**
  52990. * Creates a new Database
  52991. * @param urlToScene defines the url to load the scene
  52992. * @param callbackManifestChecked defines the callback to use when manifest is checked
  52993. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  52994. */
  52995. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  52996. private static _ParseURL;
  52997. private static _ReturnFullUrlLocation;
  52998. private _checkManifestFile;
  52999. /**
  53000. * Open the database and make it available
  53001. * @param successCallback defines the callback to call on success
  53002. * @param errorCallback defines the callback to call on error
  53003. */
  53004. open(successCallback: () => void, errorCallback: () => void): void;
  53005. /**
  53006. * Loads an image from the database
  53007. * @param url defines the url to load from
  53008. * @param image defines the target DOM image
  53009. */
  53010. loadImage(url: string, image: HTMLImageElement): void;
  53011. private _loadImageFromDBAsync;
  53012. private _saveImageIntoDBAsync;
  53013. private _checkVersionFromDB;
  53014. private _loadVersionFromDBAsync;
  53015. private _saveVersionIntoDBAsync;
  53016. /**
  53017. * Loads a file from database
  53018. * @param url defines the URL to load from
  53019. * @param sceneLoaded defines a callback to call on success
  53020. * @param progressCallBack defines a callback to call when progress changed
  53021. * @param errorCallback defines a callback to call on error
  53022. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53023. */
  53024. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53025. private _loadFileAsync;
  53026. private _saveFileAsync;
  53027. /**
  53028. * Validates if xhr data is correct
  53029. * @param xhr defines the request to validate
  53030. * @param dataType defines the expected data type
  53031. * @returns true if data is correct
  53032. */
  53033. private static _ValidateXHRData;
  53034. }
  53035. }
  53036. declare module "babylonjs/Offline/index" {
  53037. export * from "babylonjs/Offline/database";
  53038. export * from "babylonjs/Offline/IOfflineProvider";
  53039. }
  53040. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  53041. /** @hidden */
  53042. export var gpuUpdateParticlesPixelShader: {
  53043. name: string;
  53044. shader: string;
  53045. };
  53046. }
  53047. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  53048. /** @hidden */
  53049. export var gpuUpdateParticlesVertexShader: {
  53050. name: string;
  53051. shader: string;
  53052. };
  53053. }
  53054. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  53055. /** @hidden */
  53056. export var clipPlaneFragmentDeclaration2: {
  53057. name: string;
  53058. shader: string;
  53059. };
  53060. }
  53061. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  53062. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  53063. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53064. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53065. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53066. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53067. /** @hidden */
  53068. export var gpuRenderParticlesPixelShader: {
  53069. name: string;
  53070. shader: string;
  53071. };
  53072. }
  53073. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  53074. /** @hidden */
  53075. export var clipPlaneVertexDeclaration2: {
  53076. name: string;
  53077. shader: string;
  53078. };
  53079. }
  53080. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  53081. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  53082. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53083. /** @hidden */
  53084. export var gpuRenderParticlesVertexShader: {
  53085. name: string;
  53086. shader: string;
  53087. };
  53088. }
  53089. declare module "babylonjs/Particles/gpuParticleSystem" {
  53090. import { Nullable } from "babylonjs/types";
  53091. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  53092. import { Observable } from "babylonjs/Misc/observable";
  53093. import { Color4, Color3 } from "babylonjs/Maths/math";
  53094. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53095. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  53096. import { Scene, IDisposable } from "babylonjs/scene";
  53097. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  53098. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  53099. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  53100. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  53101. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  53102. /**
  53103. * This represents a GPU particle system in Babylon
  53104. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53105. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53106. */
  53107. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53108. /**
  53109. * The layer mask we are rendering the particles through.
  53110. */
  53111. layerMask: number;
  53112. private _capacity;
  53113. private _activeCount;
  53114. private _currentActiveCount;
  53115. private _accumulatedCount;
  53116. private _renderEffect;
  53117. private _updateEffect;
  53118. private _buffer0;
  53119. private _buffer1;
  53120. private _spriteBuffer;
  53121. private _updateVAO;
  53122. private _renderVAO;
  53123. private _targetIndex;
  53124. private _sourceBuffer;
  53125. private _targetBuffer;
  53126. private _engine;
  53127. private _currentRenderId;
  53128. private _started;
  53129. private _stopped;
  53130. private _timeDelta;
  53131. private _randomTexture;
  53132. private _randomTexture2;
  53133. private _attributesStrideSize;
  53134. private _updateEffectOptions;
  53135. private _randomTextureSize;
  53136. private _actualFrame;
  53137. private readonly _rawTextureWidth;
  53138. /**
  53139. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53140. */
  53141. static readonly IsSupported: boolean;
  53142. /**
  53143. * An event triggered when the system is disposed.
  53144. */
  53145. onDisposeObservable: Observable<GPUParticleSystem>;
  53146. /**
  53147. * Gets the maximum number of particles active at the same time.
  53148. * @returns The max number of active particles.
  53149. */
  53150. getCapacity(): number;
  53151. /**
  53152. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53153. * to override the particles.
  53154. */
  53155. forceDepthWrite: boolean;
  53156. /**
  53157. * Gets or set the number of active particles
  53158. */
  53159. activeParticleCount: number;
  53160. private _preWarmDone;
  53161. /**
  53162. * Is this system ready to be used/rendered
  53163. * @return true if the system is ready
  53164. */
  53165. isReady(): boolean;
  53166. /**
  53167. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53168. * @returns True if it has been started, otherwise false.
  53169. */
  53170. isStarted(): boolean;
  53171. /**
  53172. * Starts the particle system and begins to emit
  53173. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53174. */
  53175. start(delay?: number): void;
  53176. /**
  53177. * Stops the particle system.
  53178. */
  53179. stop(): void;
  53180. /**
  53181. * Remove all active particles
  53182. */
  53183. reset(): void;
  53184. /**
  53185. * Returns the string "GPUParticleSystem"
  53186. * @returns a string containing the class name
  53187. */
  53188. getClassName(): string;
  53189. private _colorGradientsTexture;
  53190. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53191. /**
  53192. * Adds a new color gradient
  53193. * @param gradient defines the gradient to use (between 0 and 1)
  53194. * @param color1 defines the color to affect to the specified gradient
  53195. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53196. * @returns the current particle system
  53197. */
  53198. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53199. /**
  53200. * Remove a specific color gradient
  53201. * @param gradient defines the gradient to remove
  53202. * @returns the current particle system
  53203. */
  53204. removeColorGradient(gradient: number): GPUParticleSystem;
  53205. private _angularSpeedGradientsTexture;
  53206. private _sizeGradientsTexture;
  53207. private _velocityGradientsTexture;
  53208. private _limitVelocityGradientsTexture;
  53209. private _dragGradientsTexture;
  53210. private _addFactorGradient;
  53211. /**
  53212. * Adds a new size gradient
  53213. * @param gradient defines the gradient to use (between 0 and 1)
  53214. * @param factor defines the size factor to affect to the specified gradient
  53215. * @returns the current particle system
  53216. */
  53217. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53218. /**
  53219. * Remove a specific size gradient
  53220. * @param gradient defines the gradient to remove
  53221. * @returns the current particle system
  53222. */
  53223. removeSizeGradient(gradient: number): GPUParticleSystem;
  53224. /**
  53225. * Adds a new angular speed gradient
  53226. * @param gradient defines the gradient to use (between 0 and 1)
  53227. * @param factor defines the angular speed to affect to the specified gradient
  53228. * @returns the current particle system
  53229. */
  53230. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53231. /**
  53232. * Remove a specific angular speed gradient
  53233. * @param gradient defines the gradient to remove
  53234. * @returns the current particle system
  53235. */
  53236. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53237. /**
  53238. * Adds a new velocity gradient
  53239. * @param gradient defines the gradient to use (between 0 and 1)
  53240. * @param factor defines the velocity to affect to the specified gradient
  53241. * @returns the current particle system
  53242. */
  53243. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53244. /**
  53245. * Remove a specific velocity gradient
  53246. * @param gradient defines the gradient to remove
  53247. * @returns the current particle system
  53248. */
  53249. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53250. /**
  53251. * Adds a new limit velocity gradient
  53252. * @param gradient defines the gradient to use (between 0 and 1)
  53253. * @param factor defines the limit velocity value to affect to the specified gradient
  53254. * @returns the current particle system
  53255. */
  53256. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53257. /**
  53258. * Remove a specific limit velocity gradient
  53259. * @param gradient defines the gradient to remove
  53260. * @returns the current particle system
  53261. */
  53262. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53263. /**
  53264. * Adds a new drag gradient
  53265. * @param gradient defines the gradient to use (between 0 and 1)
  53266. * @param factor defines the drag value to affect to the specified gradient
  53267. * @returns the current particle system
  53268. */
  53269. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53270. /**
  53271. * Remove a specific drag gradient
  53272. * @param gradient defines the gradient to remove
  53273. * @returns the current particle system
  53274. */
  53275. removeDragGradient(gradient: number): GPUParticleSystem;
  53276. /**
  53277. * Not supported by GPUParticleSystem
  53278. * @param gradient defines the gradient to use (between 0 and 1)
  53279. * @param factor defines the emit rate value to affect to the specified gradient
  53280. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53281. * @returns the current particle system
  53282. */
  53283. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53284. /**
  53285. * Not supported by GPUParticleSystem
  53286. * @param gradient defines the gradient to remove
  53287. * @returns the current particle system
  53288. */
  53289. removeEmitRateGradient(gradient: number): IParticleSystem;
  53290. /**
  53291. * Not supported by GPUParticleSystem
  53292. * @param gradient defines the gradient to use (between 0 and 1)
  53293. * @param factor defines the start size value to affect to the specified gradient
  53294. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53295. * @returns the current particle system
  53296. */
  53297. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53298. /**
  53299. * Not supported by GPUParticleSystem
  53300. * @param gradient defines the gradient to remove
  53301. * @returns the current particle system
  53302. */
  53303. removeStartSizeGradient(gradient: number): IParticleSystem;
  53304. /**
  53305. * Not supported by GPUParticleSystem
  53306. * @param gradient defines the gradient to use (between 0 and 1)
  53307. * @param min defines the color remap minimal range
  53308. * @param max defines the color remap maximal range
  53309. * @returns the current particle system
  53310. */
  53311. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53312. /**
  53313. * Not supported by GPUParticleSystem
  53314. * @param gradient defines the gradient to remove
  53315. * @returns the current particle system
  53316. */
  53317. removeColorRemapGradient(): IParticleSystem;
  53318. /**
  53319. * Not supported by GPUParticleSystem
  53320. * @param gradient defines the gradient to use (between 0 and 1)
  53321. * @param min defines the alpha remap minimal range
  53322. * @param max defines the alpha remap maximal range
  53323. * @returns the current particle system
  53324. */
  53325. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53326. /**
  53327. * Not supported by GPUParticleSystem
  53328. * @param gradient defines the gradient to remove
  53329. * @returns the current particle system
  53330. */
  53331. removeAlphaRemapGradient(): IParticleSystem;
  53332. /**
  53333. * Not supported by GPUParticleSystem
  53334. * @param gradient defines the gradient to use (between 0 and 1)
  53335. * @param color defines the color to affect to the specified gradient
  53336. * @returns the current particle system
  53337. */
  53338. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53339. /**
  53340. * Not supported by GPUParticleSystem
  53341. * @param gradient defines the gradient to remove
  53342. * @returns the current particle system
  53343. */
  53344. removeRampGradient(): IParticleSystem;
  53345. /**
  53346. * Not supported by GPUParticleSystem
  53347. * @returns the list of ramp gradients
  53348. */
  53349. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53350. /**
  53351. * Not supported by GPUParticleSystem
  53352. * Gets or sets a boolean indicating that ramp gradients must be used
  53353. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53354. */
  53355. useRampGradients: boolean;
  53356. /**
  53357. * Not supported by GPUParticleSystem
  53358. * @param gradient defines the gradient to use (between 0 and 1)
  53359. * @param factor defines the life time factor to affect to the specified gradient
  53360. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53361. * @returns the current particle system
  53362. */
  53363. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53364. /**
  53365. * Not supported by GPUParticleSystem
  53366. * @param gradient defines the gradient to remove
  53367. * @returns the current particle system
  53368. */
  53369. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53370. /**
  53371. * Instantiates a GPU particle system.
  53372. * 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.
  53373. * @param name The name of the particle system
  53374. * @param options The options used to create the system
  53375. * @param scene The scene the particle system belongs to
  53376. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53377. */
  53378. constructor(name: string, options: Partial<{
  53379. capacity: number;
  53380. randomTextureSize: number;
  53381. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53382. protected _reset(): void;
  53383. private _createUpdateVAO;
  53384. private _createRenderVAO;
  53385. private _initialize;
  53386. /** @hidden */
  53387. _recreateUpdateEffect(): void;
  53388. /** @hidden */
  53389. _recreateRenderEffect(): void;
  53390. /**
  53391. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53392. * @param preWarm defines if we are in the pre-warmimg phase
  53393. */
  53394. animate(preWarm?: boolean): void;
  53395. private _createFactorGradientTexture;
  53396. private _createSizeGradientTexture;
  53397. private _createAngularSpeedGradientTexture;
  53398. private _createVelocityGradientTexture;
  53399. private _createLimitVelocityGradientTexture;
  53400. private _createDragGradientTexture;
  53401. private _createColorGradientTexture;
  53402. /**
  53403. * Renders the particle system in its current state
  53404. * @param preWarm defines if the system should only update the particles but not render them
  53405. * @returns the current number of particles
  53406. */
  53407. render(preWarm?: boolean): number;
  53408. /**
  53409. * Rebuilds the particle system
  53410. */
  53411. rebuild(): void;
  53412. private _releaseBuffers;
  53413. private _releaseVAOs;
  53414. /**
  53415. * Disposes the particle system and free the associated resources
  53416. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53417. */
  53418. dispose(disposeTexture?: boolean): void;
  53419. /**
  53420. * Clones the particle system.
  53421. * @param name The name of the cloned object
  53422. * @param newEmitter The new emitter to use
  53423. * @returns the cloned particle system
  53424. */
  53425. clone(name: string, newEmitter: any): GPUParticleSystem;
  53426. /**
  53427. * Serializes the particle system to a JSON object.
  53428. * @returns the JSON object
  53429. */
  53430. serialize(): any;
  53431. /**
  53432. * Parses a JSON object to create a GPU particle system.
  53433. * @param parsedParticleSystem The JSON object to parse
  53434. * @param scene The scene to create the particle system in
  53435. * @param rootUrl The root url to use to load external dependencies like texture
  53436. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53437. * @returns the parsed GPU particle system
  53438. */
  53439. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53440. }
  53441. }
  53442. declare module "babylonjs/Particles/particleSystemSet" {
  53443. import { Nullable } from "babylonjs/types";
  53444. import { Color3 } from "babylonjs/Maths/math";
  53445. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53447. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53448. import { Scene, IDisposable } from "babylonjs/scene";
  53449. /**
  53450. * Represents a set of particle systems working together to create a specific effect
  53451. */
  53452. export class ParticleSystemSet implements IDisposable {
  53453. private _emitterCreationOptions;
  53454. private _emitterNode;
  53455. /**
  53456. * Gets the particle system list
  53457. */
  53458. systems: IParticleSystem[];
  53459. /**
  53460. * Gets the emitter node used with this set
  53461. */
  53462. readonly emitterNode: Nullable<TransformNode>;
  53463. /**
  53464. * Creates a new emitter mesh as a sphere
  53465. * @param options defines the options used to create the sphere
  53466. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  53467. * @param scene defines the hosting scene
  53468. */
  53469. setEmitterAsSphere(options: {
  53470. diameter: number;
  53471. segments: number;
  53472. color: Color3;
  53473. }, renderingGroupId: number, scene: Scene): void;
  53474. /**
  53475. * Starts all particle systems of the set
  53476. * @param emitter defines an optional mesh to use as emitter for the particle systems
  53477. */
  53478. start(emitter?: AbstractMesh): void;
  53479. /**
  53480. * Release all associated resources
  53481. */
  53482. dispose(): void;
  53483. /**
  53484. * Serialize the set into a JSON compatible object
  53485. * @returns a JSON compatible representation of the set
  53486. */
  53487. serialize(): any;
  53488. /**
  53489. * Parse a new ParticleSystemSet from a serialized source
  53490. * @param data defines a JSON compatible representation of the set
  53491. * @param scene defines the hosting scene
  53492. * @param gpu defines if we want GPU particles or CPU particles
  53493. * @returns a new ParticleSystemSet
  53494. */
  53495. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  53496. }
  53497. }
  53498. declare module "babylonjs/Particles/particleHelper" {
  53499. import { Nullable } from "babylonjs/types";
  53500. import { Scene } from "babylonjs/scene";
  53501. import { Vector3 } from "babylonjs/Maths/math";
  53502. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53503. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53504. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  53505. /**
  53506. * This class is made for on one-liner static method to help creating particle system set.
  53507. */
  53508. export class ParticleHelper {
  53509. /**
  53510. * Gets or sets base Assets URL
  53511. */
  53512. static BaseAssetsUrl: string;
  53513. /**
  53514. * Create a default particle system that you can tweak
  53515. * @param emitter defines the emitter to use
  53516. * @param capacity defines the system capacity (default is 500 particles)
  53517. * @param scene defines the hosting scene
  53518. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  53519. * @returns the new Particle system
  53520. */
  53521. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  53522. /**
  53523. * This is the main static method (one-liner) of this helper to create different particle systems
  53524. * @param type This string represents the type to the particle system to create
  53525. * @param scene The scene where the particle system should live
  53526. * @param gpu If the system will use gpu
  53527. * @returns the ParticleSystemSet created
  53528. */
  53529. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  53530. /**
  53531. * Static function used to export a particle system to a ParticleSystemSet variable.
  53532. * Please note that the emitter shape is not exported
  53533. * @param systems defines the particle systems to export
  53534. * @returns the created particle system set
  53535. */
  53536. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  53537. }
  53538. }
  53539. declare module "babylonjs/Particles/particleSystemComponent" {
  53540. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53541. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53542. import "babylonjs/Shaders/particles.vertex";
  53543. module "babylonjs/Engines/engine" {
  53544. interface Engine {
  53545. /**
  53546. * Create an effect to use with particle systems.
  53547. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  53548. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  53549. * @param uniformsNames defines a list of attribute names
  53550. * @param samplers defines an array of string used to represent textures
  53551. * @param defines defines the string containing the defines to use to compile the shaders
  53552. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  53553. * @param onCompiled defines a function to call when the effect creation is successful
  53554. * @param onError defines a function to call when the effect creation has failed
  53555. * @returns the new Effect
  53556. */
  53557. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  53558. }
  53559. }
  53560. module "babylonjs/Meshes/mesh" {
  53561. interface Mesh {
  53562. /**
  53563. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  53564. * @returns an array of IParticleSystem
  53565. */
  53566. getEmittedParticleSystems(): IParticleSystem[];
  53567. /**
  53568. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  53569. * @returns an array of IParticleSystem
  53570. */
  53571. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  53572. }
  53573. }
  53574. /**
  53575. * @hidden
  53576. */
  53577. export var _IDoNeedToBeInTheBuild: number;
  53578. }
  53579. declare module "babylonjs/Particles/index" {
  53580. export * from "babylonjs/Particles/baseParticleSystem";
  53581. export * from "babylonjs/Particles/EmitterTypes/index";
  53582. export * from "babylonjs/Particles/gpuParticleSystem";
  53583. export * from "babylonjs/Particles/IParticleSystem";
  53584. export * from "babylonjs/Particles/particle";
  53585. export * from "babylonjs/Particles/particleHelper";
  53586. export * from "babylonjs/Particles/particleSystem";
  53587. export * from "babylonjs/Particles/particleSystemComponent";
  53588. export * from "babylonjs/Particles/particleSystemSet";
  53589. export * from "babylonjs/Particles/solidParticle";
  53590. export * from "babylonjs/Particles/solidParticleSystem";
  53591. export * from "babylonjs/Particles/subEmitter";
  53592. }
  53593. declare module "babylonjs/Physics/physicsEngineComponent" {
  53594. import { Nullable } from "babylonjs/types";
  53595. import { Observable, Observer } from "babylonjs/Misc/observable";
  53596. import { Vector3 } from "babylonjs/Maths/math";
  53597. import { Mesh } from "babylonjs/Meshes/mesh";
  53598. import { ISceneComponent } from "babylonjs/sceneComponent";
  53599. import { Scene } from "babylonjs/scene";
  53600. import { Node } from "babylonjs/node";
  53601. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53602. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53603. module "babylonjs/scene" {
  53604. interface Scene {
  53605. /** @hidden (Backing field) */
  53606. _physicsEngine: Nullable<IPhysicsEngine>;
  53607. /**
  53608. * Gets the current physics engine
  53609. * @returns a IPhysicsEngine or null if none attached
  53610. */
  53611. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  53612. /**
  53613. * Enables physics to the current scene
  53614. * @param gravity defines the scene's gravity for the physics engine
  53615. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  53616. * @return a boolean indicating if the physics engine was initialized
  53617. */
  53618. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  53619. /**
  53620. * Disables and disposes the physics engine associated with the scene
  53621. */
  53622. disablePhysicsEngine(): void;
  53623. /**
  53624. * Gets a boolean indicating if there is an active physics engine
  53625. * @returns a boolean indicating if there is an active physics engine
  53626. */
  53627. isPhysicsEnabled(): boolean;
  53628. /**
  53629. * Deletes a physics compound impostor
  53630. * @param compound defines the compound to delete
  53631. */
  53632. deleteCompoundImpostor(compound: any): void;
  53633. /**
  53634. * An event triggered when physic simulation is about to be run
  53635. */
  53636. onBeforePhysicsObservable: Observable<Scene>;
  53637. /**
  53638. * An event triggered when physic simulation has been done
  53639. */
  53640. onAfterPhysicsObservable: Observable<Scene>;
  53641. }
  53642. }
  53643. module "babylonjs/Meshes/abstractMesh" {
  53644. interface AbstractMesh {
  53645. /** @hidden */
  53646. _physicsImpostor: Nullable<PhysicsImpostor>;
  53647. /**
  53648. * Gets or sets impostor used for physic simulation
  53649. * @see http://doc.babylonjs.com/features/physics_engine
  53650. */
  53651. physicsImpostor: Nullable<PhysicsImpostor>;
  53652. /**
  53653. * Gets the current physics impostor
  53654. * @see http://doc.babylonjs.com/features/physics_engine
  53655. * @returns a physics impostor or null
  53656. */
  53657. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  53658. /** Apply a physic impulse to the mesh
  53659. * @param force defines the force to apply
  53660. * @param contactPoint defines where to apply the force
  53661. * @returns the current mesh
  53662. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53663. */
  53664. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  53665. /**
  53666. * Creates a physic joint between two meshes
  53667. * @param otherMesh defines the other mesh to use
  53668. * @param pivot1 defines the pivot to use on this mesh
  53669. * @param pivot2 defines the pivot to use on the other mesh
  53670. * @param options defines additional options (can be plugin dependent)
  53671. * @returns the current mesh
  53672. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  53673. */
  53674. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  53675. /** @hidden */
  53676. _disposePhysicsObserver: Nullable<Observer<Node>>;
  53677. }
  53678. }
  53679. /**
  53680. * Defines the physics engine scene component responsible to manage a physics engine
  53681. */
  53682. export class PhysicsEngineSceneComponent implements ISceneComponent {
  53683. /**
  53684. * The component name helpful to identify the component in the list of scene components.
  53685. */
  53686. readonly name: string;
  53687. /**
  53688. * The scene the component belongs to.
  53689. */
  53690. scene: Scene;
  53691. /**
  53692. * Creates a new instance of the component for the given scene
  53693. * @param scene Defines the scene to register the component in
  53694. */
  53695. constructor(scene: Scene);
  53696. /**
  53697. * Registers the component in a given scene
  53698. */
  53699. register(): void;
  53700. /**
  53701. * Rebuilds the elements related to this component in case of
  53702. * context lost for instance.
  53703. */
  53704. rebuild(): void;
  53705. /**
  53706. * Disposes the component and the associated ressources
  53707. */
  53708. dispose(): void;
  53709. }
  53710. }
  53711. declare module "babylonjs/Physics/physicsHelper" {
  53712. import { Nullable } from "babylonjs/types";
  53713. import { Vector3 } from "babylonjs/Maths/math";
  53714. import { Mesh } from "babylonjs/Meshes/mesh";
  53715. import { Scene } from "babylonjs/scene";
  53716. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53717. /**
  53718. * A helper for physics simulations
  53719. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53720. */
  53721. export class PhysicsHelper {
  53722. private _scene;
  53723. private _physicsEngine;
  53724. /**
  53725. * Initializes the Physics helper
  53726. * @param scene Babylon.js scene
  53727. */
  53728. constructor(scene: Scene);
  53729. /**
  53730. * Applies a radial explosion impulse
  53731. * @param origin the origin of the explosion
  53732. * @param radiusOrEventOptions the radius or the options of radial explosion
  53733. * @param strength the explosion strength
  53734. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53735. * @returns A physics radial explosion event, or null
  53736. */
  53737. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53738. /**
  53739. * Applies a radial explosion force
  53740. * @param origin the origin of the explosion
  53741. * @param radiusOrEventOptions the radius or the options of radial explosion
  53742. * @param strength the explosion strength
  53743. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53744. * @returns A physics radial explosion event, or null
  53745. */
  53746. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53747. /**
  53748. * Creates a gravitational field
  53749. * @param origin the origin of the explosion
  53750. * @param radiusOrEventOptions the radius or the options of radial explosion
  53751. * @param strength the explosion strength
  53752. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53753. * @returns A physics gravitational field event, or null
  53754. */
  53755. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  53756. /**
  53757. * Creates a physics updraft event
  53758. * @param origin the origin of the updraft
  53759. * @param radiusOrEventOptions the radius or the options of the updraft
  53760. * @param strength the strength of the updraft
  53761. * @param height the height of the updraft
  53762. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  53763. * @returns A physics updraft event, or null
  53764. */
  53765. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  53766. /**
  53767. * Creates a physics vortex event
  53768. * @param origin the of the vortex
  53769. * @param radiusOrEventOptions the radius or the options of the vortex
  53770. * @param strength the strength of the vortex
  53771. * @param height the height of the vortex
  53772. * @returns a Physics vortex event, or null
  53773. * A physics vortex event or null
  53774. */
  53775. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  53776. }
  53777. /**
  53778. * Represents a physics radial explosion event
  53779. */
  53780. class PhysicsRadialExplosionEvent {
  53781. private _scene;
  53782. private _options;
  53783. private _sphere;
  53784. private _dataFetched;
  53785. /**
  53786. * Initializes a radial explosioin event
  53787. * @param _scene BabylonJS scene
  53788. * @param _options The options for the vortex event
  53789. */
  53790. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  53791. /**
  53792. * Returns the data related to the radial explosion event (sphere).
  53793. * @returns The radial explosion event data
  53794. */
  53795. getData(): PhysicsRadialExplosionEventData;
  53796. /**
  53797. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  53798. * @param impostor A physics imposter
  53799. * @param origin the origin of the explosion
  53800. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  53801. */
  53802. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  53803. /**
  53804. * Triggers affecterd impostors callbacks
  53805. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  53806. */
  53807. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  53808. /**
  53809. * Disposes the sphere.
  53810. * @param force Specifies if the sphere should be disposed by force
  53811. */
  53812. dispose(force?: boolean): void;
  53813. /*** Helpers ***/
  53814. private _prepareSphere;
  53815. private _intersectsWithSphere;
  53816. }
  53817. /**
  53818. * Represents a gravitational field event
  53819. */
  53820. class PhysicsGravitationalFieldEvent {
  53821. private _physicsHelper;
  53822. private _scene;
  53823. private _origin;
  53824. private _options;
  53825. private _tickCallback;
  53826. private _sphere;
  53827. private _dataFetched;
  53828. /**
  53829. * Initializes the physics gravitational field event
  53830. * @param _physicsHelper A physics helper
  53831. * @param _scene BabylonJS scene
  53832. * @param _origin The origin position of the gravitational field event
  53833. * @param _options The options for the vortex event
  53834. */
  53835. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  53836. /**
  53837. * Returns the data related to the gravitational field event (sphere).
  53838. * @returns A gravitational field event
  53839. */
  53840. getData(): PhysicsGravitationalFieldEventData;
  53841. /**
  53842. * Enables the gravitational field.
  53843. */
  53844. enable(): void;
  53845. /**
  53846. * Disables the gravitational field.
  53847. */
  53848. disable(): void;
  53849. /**
  53850. * Disposes the sphere.
  53851. * @param force The force to dispose from the gravitational field event
  53852. */
  53853. dispose(force?: boolean): void;
  53854. private _tick;
  53855. }
  53856. /**
  53857. * Represents a physics updraft event
  53858. */
  53859. class PhysicsUpdraftEvent {
  53860. private _scene;
  53861. private _origin;
  53862. private _options;
  53863. private _physicsEngine;
  53864. private _originTop;
  53865. private _originDirection;
  53866. private _tickCallback;
  53867. private _cylinder;
  53868. private _cylinderPosition;
  53869. private _dataFetched;
  53870. /**
  53871. * Initializes the physics updraft event
  53872. * @param _scene BabylonJS scene
  53873. * @param _origin The origin position of the updraft
  53874. * @param _options The options for the updraft event
  53875. */
  53876. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  53877. /**
  53878. * Returns the data related to the updraft event (cylinder).
  53879. * @returns A physics updraft event
  53880. */
  53881. getData(): PhysicsUpdraftEventData;
  53882. /**
  53883. * Enables the updraft.
  53884. */
  53885. enable(): void;
  53886. /**
  53887. * Disables the updraft.
  53888. */
  53889. disable(): void;
  53890. /**
  53891. * Disposes the cylinder.
  53892. * @param force Specifies if the updraft should be disposed by force
  53893. */
  53894. dispose(force?: boolean): void;
  53895. private getImpostorHitData;
  53896. private _tick;
  53897. /*** Helpers ***/
  53898. private _prepareCylinder;
  53899. private _intersectsWithCylinder;
  53900. }
  53901. /**
  53902. * Represents a physics vortex event
  53903. */
  53904. class PhysicsVortexEvent {
  53905. private _scene;
  53906. private _origin;
  53907. private _options;
  53908. private _physicsEngine;
  53909. private _originTop;
  53910. private _tickCallback;
  53911. private _cylinder;
  53912. private _cylinderPosition;
  53913. private _dataFetched;
  53914. /**
  53915. * Initializes the physics vortex event
  53916. * @param _scene The BabylonJS scene
  53917. * @param _origin The origin position of the vortex
  53918. * @param _options The options for the vortex event
  53919. */
  53920. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  53921. /**
  53922. * Returns the data related to the vortex event (cylinder).
  53923. * @returns The physics vortex event data
  53924. */
  53925. getData(): PhysicsVortexEventData;
  53926. /**
  53927. * Enables the vortex.
  53928. */
  53929. enable(): void;
  53930. /**
  53931. * Disables the cortex.
  53932. */
  53933. disable(): void;
  53934. /**
  53935. * Disposes the sphere.
  53936. * @param force
  53937. */
  53938. dispose(force?: boolean): void;
  53939. private getImpostorHitData;
  53940. private _tick;
  53941. /*** Helpers ***/
  53942. private _prepareCylinder;
  53943. private _intersectsWithCylinder;
  53944. }
  53945. /**
  53946. * Options fot the radial explosion event
  53947. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53948. */
  53949. export class PhysicsRadialExplosionEventOptions {
  53950. /**
  53951. * The radius of the sphere for the radial explosion.
  53952. */
  53953. radius: number;
  53954. /**
  53955. * The strenth of the explosion.
  53956. */
  53957. strength: number;
  53958. /**
  53959. * The strenght of the force in correspondence to the distance of the affected object
  53960. */
  53961. falloff: PhysicsRadialImpulseFalloff;
  53962. /**
  53963. * Sphere options for the radial explosion.
  53964. */
  53965. sphere: {
  53966. segments: number;
  53967. diameter: number;
  53968. };
  53969. /**
  53970. * Sphere options for the radial explosion.
  53971. */
  53972. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  53973. }
  53974. /**
  53975. * Options fot the updraft event
  53976. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53977. */
  53978. export class PhysicsUpdraftEventOptions {
  53979. /**
  53980. * The radius of the cylinder for the vortex
  53981. */
  53982. radius: number;
  53983. /**
  53984. * The strenth of the updraft.
  53985. */
  53986. strength: number;
  53987. /**
  53988. * The height of the cylinder for the updraft.
  53989. */
  53990. height: number;
  53991. /**
  53992. * The mode for the the updraft.
  53993. */
  53994. updraftMode: PhysicsUpdraftMode;
  53995. }
  53996. /**
  53997. * Options fot the vortex event
  53998. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53999. */
  54000. export class PhysicsVortexEventOptions {
  54001. /**
  54002. * The radius of the cylinder for the vortex
  54003. */
  54004. radius: number;
  54005. /**
  54006. * The strenth of the vortex.
  54007. */
  54008. strength: number;
  54009. /**
  54010. * The height of the cylinder for the vortex.
  54011. */
  54012. height: number;
  54013. /**
  54014. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54015. */
  54016. centripetalForceThreshold: number;
  54017. /**
  54018. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54019. */
  54020. centripetalForceMultiplier: number;
  54021. /**
  54022. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54023. */
  54024. centrifugalForceMultiplier: number;
  54025. /**
  54026. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54027. */
  54028. updraftForceMultiplier: number;
  54029. }
  54030. /**
  54031. * The strenght of the force in correspondence to the distance of the affected object
  54032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54033. */
  54034. export enum PhysicsRadialImpulseFalloff {
  54035. /** Defines that impulse is constant in strength across it's whole radius */
  54036. Constant = 0,
  54037. /** Defines that impulse gets weaker if it's further from the origin */
  54038. Linear = 1
  54039. }
  54040. /**
  54041. * The strength of the force in correspondence to the distance of the affected object
  54042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54043. */
  54044. export enum PhysicsUpdraftMode {
  54045. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54046. Center = 0,
  54047. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54048. Perpendicular = 1
  54049. }
  54050. /**
  54051. * Interface for a physics hit data
  54052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54053. */
  54054. export interface PhysicsHitData {
  54055. /**
  54056. * The force applied at the contact point
  54057. */
  54058. force: Vector3;
  54059. /**
  54060. * The contact point
  54061. */
  54062. contactPoint: Vector3;
  54063. /**
  54064. * The distance from the origin to the contact point
  54065. */
  54066. distanceFromOrigin: number;
  54067. }
  54068. /**
  54069. * Interface for radial explosion event data
  54070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54071. */
  54072. export interface PhysicsRadialExplosionEventData {
  54073. /**
  54074. * A sphere used for the radial explosion event
  54075. */
  54076. sphere: Mesh;
  54077. }
  54078. /**
  54079. * Interface for gravitational field event data
  54080. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54081. */
  54082. export interface PhysicsGravitationalFieldEventData {
  54083. /**
  54084. * A sphere mesh used for the gravitational field event
  54085. */
  54086. sphere: Mesh;
  54087. }
  54088. /**
  54089. * Interface for updraft event data
  54090. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54091. */
  54092. export interface PhysicsUpdraftEventData {
  54093. /**
  54094. * A cylinder used for the updraft event
  54095. */
  54096. cylinder: Mesh;
  54097. }
  54098. /**
  54099. * Interface for vortex event data
  54100. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54101. */
  54102. export interface PhysicsVortexEventData {
  54103. /**
  54104. * A cylinder used for the vortex event
  54105. */
  54106. cylinder: Mesh;
  54107. }
  54108. /**
  54109. * Interface for an affected physics impostor
  54110. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54111. */
  54112. export interface PhysicsAffectedImpostorWithData {
  54113. /**
  54114. * The impostor affected by the effect
  54115. */
  54116. impostor: PhysicsImpostor;
  54117. /**
  54118. * The data about the hit/horce from the explosion
  54119. */
  54120. hitData: PhysicsHitData;
  54121. }
  54122. }
  54123. declare module "babylonjs/Physics/Plugins/index" {
  54124. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  54125. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  54126. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  54127. }
  54128. declare module "babylonjs/Physics/index" {
  54129. export * from "babylonjs/Physics/IPhysicsEngine";
  54130. export * from "babylonjs/Physics/physicsEngine";
  54131. export * from "babylonjs/Physics/physicsEngineComponent";
  54132. export * from "babylonjs/Physics/physicsHelper";
  54133. export * from "babylonjs/Physics/physicsImpostor";
  54134. export * from "babylonjs/Physics/physicsJoint";
  54135. export * from "babylonjs/Physics/Plugins/index";
  54136. }
  54137. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  54138. /** @hidden */
  54139. export var blackAndWhitePixelShader: {
  54140. name: string;
  54141. shader: string;
  54142. };
  54143. }
  54144. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  54145. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54146. import { Camera } from "babylonjs/Cameras/camera";
  54147. import { Engine } from "babylonjs/Engines/engine";
  54148. import "babylonjs/Shaders/blackAndWhite.fragment";
  54149. /**
  54150. * Post process used to render in black and white
  54151. */
  54152. export class BlackAndWhitePostProcess extends PostProcess {
  54153. /**
  54154. * Linear about to convert he result to black and white (default: 1)
  54155. */
  54156. degree: number;
  54157. /**
  54158. * Creates a black and white post process
  54159. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54160. * @param name The name of the effect.
  54161. * @param options The required width/height ratio to downsize to before computing the render pass.
  54162. * @param camera The camera to apply the render pass to.
  54163. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54164. * @param engine The engine which the post process will be applied. (default: current engine)
  54165. * @param reusable If the post process can be reused on the same frame. (default: false)
  54166. */
  54167. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54168. }
  54169. }
  54170. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  54171. import { Nullable } from "babylonjs/types";
  54172. import { Camera } from "babylonjs/Cameras/camera";
  54173. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54174. import { Engine } from "babylonjs/Engines/engine";
  54175. /**
  54176. * This represents a set of one or more post processes in Babylon.
  54177. * A post process can be used to apply a shader to a texture after it is rendered.
  54178. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54179. */
  54180. export class PostProcessRenderEffect {
  54181. private _postProcesses;
  54182. private _getPostProcesses;
  54183. private _singleInstance;
  54184. private _cameras;
  54185. private _indicesForCamera;
  54186. /**
  54187. * Name of the effect
  54188. * @hidden
  54189. */
  54190. _name: string;
  54191. /**
  54192. * Instantiates a post process render effect.
  54193. * A post process can be used to apply a shader to a texture after it is rendered.
  54194. * @param engine The engine the effect is tied to
  54195. * @param name The name of the effect
  54196. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54197. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54198. */
  54199. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54200. /**
  54201. * Checks if all the post processes in the effect are supported.
  54202. */
  54203. readonly isSupported: boolean;
  54204. /**
  54205. * Updates the current state of the effect
  54206. * @hidden
  54207. */
  54208. _update(): void;
  54209. /**
  54210. * Attaches the effect on cameras
  54211. * @param cameras The camera to attach to.
  54212. * @hidden
  54213. */
  54214. _attachCameras(cameras: Camera): void;
  54215. /**
  54216. * Attaches the effect on cameras
  54217. * @param cameras The camera to attach to.
  54218. * @hidden
  54219. */
  54220. _attachCameras(cameras: Camera[]): void;
  54221. /**
  54222. * Detatches the effect on cameras
  54223. * @param cameras The camera to detatch from.
  54224. * @hidden
  54225. */
  54226. _detachCameras(cameras: Camera): void;
  54227. /**
  54228. * Detatches the effect on cameras
  54229. * @param cameras The camera to detatch from.
  54230. * @hidden
  54231. */
  54232. _detachCameras(cameras: Camera[]): void;
  54233. /**
  54234. * Enables the effect on given cameras
  54235. * @param cameras The camera to enable.
  54236. * @hidden
  54237. */
  54238. _enable(cameras: Camera): void;
  54239. /**
  54240. * Enables the effect on given cameras
  54241. * @param cameras The camera to enable.
  54242. * @hidden
  54243. */
  54244. _enable(cameras: Nullable<Camera[]>): void;
  54245. /**
  54246. * Disables the effect on the given cameras
  54247. * @param cameras The camera to disable.
  54248. * @hidden
  54249. */
  54250. _disable(cameras: Camera): void;
  54251. /**
  54252. * Disables the effect on the given cameras
  54253. * @param cameras The camera to disable.
  54254. * @hidden
  54255. */
  54256. _disable(cameras: Nullable<Camera[]>): void;
  54257. /**
  54258. * Gets a list of the post processes contained in the effect.
  54259. * @param camera The camera to get the post processes on.
  54260. * @returns The list of the post processes in the effect.
  54261. */
  54262. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54263. }
  54264. }
  54265. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  54266. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54267. /** @hidden */
  54268. export var extractHighlightsPixelShader: {
  54269. name: string;
  54270. shader: string;
  54271. };
  54272. }
  54273. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  54274. import { Nullable } from "babylonjs/types";
  54275. import { Camera } from "babylonjs/Cameras/camera";
  54276. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54277. import { Engine } from "babylonjs/Engines/engine";
  54278. import "babylonjs/Shaders/extractHighlights.fragment";
  54279. /**
  54280. * 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.
  54281. */
  54282. export class ExtractHighlightsPostProcess extends PostProcess {
  54283. /**
  54284. * The luminance threshold, pixels below this value will be set to black.
  54285. */
  54286. threshold: number;
  54287. /** @hidden */
  54288. _exposure: number;
  54289. /**
  54290. * Post process which has the input texture to be used when performing highlight extraction
  54291. * @hidden
  54292. */
  54293. _inputPostProcess: Nullable<PostProcess>;
  54294. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54295. }
  54296. }
  54297. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  54298. /** @hidden */
  54299. export var bloomMergePixelShader: {
  54300. name: string;
  54301. shader: string;
  54302. };
  54303. }
  54304. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  54305. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54306. import { Nullable } from "babylonjs/types";
  54307. import { Engine } from "babylonjs/Engines/engine";
  54308. import { Camera } from "babylonjs/Cameras/camera";
  54309. import "babylonjs/Shaders/bloomMerge.fragment";
  54310. /**
  54311. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54312. */
  54313. export class BloomMergePostProcess extends PostProcess {
  54314. /** Weight of the bloom to be added to the original input. */
  54315. weight: number;
  54316. /**
  54317. * Creates a new instance of @see BloomMergePostProcess
  54318. * @param name The name of the effect.
  54319. * @param originalFromInput Post process which's input will be used for the merge.
  54320. * @param blurred Blurred highlights post process which's output will be used.
  54321. * @param weight Weight of the bloom to be added to the original input.
  54322. * @param options The required width/height ratio to downsize to before computing the render pass.
  54323. * @param camera The camera to apply the render pass to.
  54324. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54325. * @param engine The engine which the post process will be applied. (default: current engine)
  54326. * @param reusable If the post process can be reused on the same frame. (default: false)
  54327. * @param textureType Type of textures used when performing the post process. (default: 0)
  54328. * @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)
  54329. */
  54330. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54331. /** Weight of the bloom to be added to the original input. */
  54332. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54333. }
  54334. }
  54335. declare module "babylonjs/PostProcesses/bloomEffect" {
  54336. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54337. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54338. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54339. import { Camera } from "babylonjs/Cameras/camera";
  54340. import { Scene } from "babylonjs/scene";
  54341. /**
  54342. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54343. */
  54344. export class BloomEffect extends PostProcessRenderEffect {
  54345. private bloomScale;
  54346. /**
  54347. * @hidden Internal
  54348. */
  54349. _effects: Array<PostProcess>;
  54350. /**
  54351. * @hidden Internal
  54352. */
  54353. _downscale: ExtractHighlightsPostProcess;
  54354. private _blurX;
  54355. private _blurY;
  54356. private _merge;
  54357. /**
  54358. * The luminance threshold to find bright areas of the image to bloom.
  54359. */
  54360. threshold: number;
  54361. /**
  54362. * The strength of the bloom.
  54363. */
  54364. weight: number;
  54365. /**
  54366. * Specifies the size of the bloom blur kernel, relative to the final output size
  54367. */
  54368. kernel: number;
  54369. /**
  54370. * Creates a new instance of @see BloomEffect
  54371. * @param scene The scene the effect belongs to.
  54372. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54373. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54374. * @param bloomWeight The the strength of bloom.
  54375. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54376. * @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)
  54377. */
  54378. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54379. /**
  54380. * Disposes each of the internal effects for a given camera.
  54381. * @param camera The camera to dispose the effect on.
  54382. */
  54383. disposeEffects(camera: Camera): void;
  54384. /**
  54385. * @hidden Internal
  54386. */
  54387. _updateEffects(): void;
  54388. /**
  54389. * Internal
  54390. * @returns if all the contained post processes are ready.
  54391. * @hidden
  54392. */
  54393. _isReady(): boolean;
  54394. }
  54395. }
  54396. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  54397. /** @hidden */
  54398. export var chromaticAberrationPixelShader: {
  54399. name: string;
  54400. shader: string;
  54401. };
  54402. }
  54403. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  54404. import { Vector2 } from "babylonjs/Maths/math";
  54405. import { Nullable } from "babylonjs/types";
  54406. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54407. import { Camera } from "babylonjs/Cameras/camera";
  54408. import { Engine } from "babylonjs/Engines/engine";
  54409. import "babylonjs/Shaders/chromaticAberration.fragment";
  54410. /**
  54411. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54412. */
  54413. export class ChromaticAberrationPostProcess extends PostProcess {
  54414. /**
  54415. * The amount of seperation of rgb channels (default: 30)
  54416. */
  54417. aberrationAmount: number;
  54418. /**
  54419. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54420. */
  54421. radialIntensity: number;
  54422. /**
  54423. * 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))
  54424. */
  54425. direction: Vector2;
  54426. /**
  54427. * 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))
  54428. */
  54429. centerPosition: Vector2;
  54430. /**
  54431. * Creates a new instance ChromaticAberrationPostProcess
  54432. * @param name The name of the effect.
  54433. * @param screenWidth The width of the screen to apply the effect on.
  54434. * @param screenHeight The height of the screen to apply the effect on.
  54435. * @param options The required width/height ratio to downsize to before computing the render pass.
  54436. * @param camera The camera to apply the render pass to.
  54437. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54438. * @param engine The engine which the post process will be applied. (default: current engine)
  54439. * @param reusable If the post process can be reused on the same frame. (default: false)
  54440. * @param textureType Type of textures used when performing the post process. (default: 0)
  54441. * @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)
  54442. */
  54443. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54444. }
  54445. }
  54446. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  54447. /** @hidden */
  54448. export var circleOfConfusionPixelShader: {
  54449. name: string;
  54450. shader: string;
  54451. };
  54452. }
  54453. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  54454. import { Nullable } from "babylonjs/types";
  54455. import { Engine } from "babylonjs/Engines/engine";
  54456. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54457. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54458. import { Camera } from "babylonjs/Cameras/camera";
  54459. import "babylonjs/Shaders/circleOfConfusion.fragment";
  54460. /**
  54461. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  54462. */
  54463. export class CircleOfConfusionPostProcess extends PostProcess {
  54464. /**
  54465. * 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.
  54466. */
  54467. lensSize: number;
  54468. /**
  54469. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54470. */
  54471. fStop: number;
  54472. /**
  54473. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54474. */
  54475. focusDistance: number;
  54476. /**
  54477. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  54478. */
  54479. focalLength: number;
  54480. private _depthTexture;
  54481. /**
  54482. * Creates a new instance CircleOfConfusionPostProcess
  54483. * @param name The name of the effect.
  54484. * @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.
  54485. * @param options The required width/height ratio to downsize to before computing the render pass.
  54486. * @param camera The camera to apply the render pass to.
  54487. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54488. * @param engine The engine which the post process will be applied. (default: current engine)
  54489. * @param reusable If the post process can be reused on the same frame. (default: false)
  54490. * @param textureType Type of textures used when performing the post process. (default: 0)
  54491. * @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)
  54492. */
  54493. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54494. /**
  54495. * 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.
  54496. */
  54497. depthTexture: RenderTargetTexture;
  54498. }
  54499. }
  54500. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  54501. /** @hidden */
  54502. export var colorCorrectionPixelShader: {
  54503. name: string;
  54504. shader: string;
  54505. };
  54506. }
  54507. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  54508. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54509. import { Engine } from "babylonjs/Engines/engine";
  54510. import { Camera } from "babylonjs/Cameras/camera";
  54511. import "babylonjs/Shaders/colorCorrection.fragment";
  54512. /**
  54513. *
  54514. * This post-process allows the modification of rendered colors by using
  54515. * a 'look-up table' (LUT). This effect is also called Color Grading.
  54516. *
  54517. * The object needs to be provided an url to a texture containing the color
  54518. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  54519. * Use an image editing software to tweak the LUT to match your needs.
  54520. *
  54521. * For an example of a color LUT, see here:
  54522. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  54523. * For explanations on color grading, see here:
  54524. * @see http://udn.epicgames.com/Three/ColorGrading.html
  54525. *
  54526. */
  54527. export class ColorCorrectionPostProcess extends PostProcess {
  54528. private _colorTableTexture;
  54529. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54530. }
  54531. }
  54532. declare module "babylonjs/Shaders/convolution.fragment" {
  54533. /** @hidden */
  54534. export var convolutionPixelShader: {
  54535. name: string;
  54536. shader: string;
  54537. };
  54538. }
  54539. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  54540. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54541. import { Nullable } from "babylonjs/types";
  54542. import { Camera } from "babylonjs/Cameras/camera";
  54543. import { Engine } from "babylonjs/Engines/engine";
  54544. import "babylonjs/Shaders/convolution.fragment";
  54545. /**
  54546. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  54547. * input texture to perform effects such as edge detection or sharpening
  54548. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54549. */
  54550. export class ConvolutionPostProcess extends PostProcess {
  54551. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54552. kernel: number[];
  54553. /**
  54554. * Creates a new instance ConvolutionPostProcess
  54555. * @param name The name of the effect.
  54556. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  54557. * @param options The required width/height ratio to downsize to before computing the render pass.
  54558. * @param camera The camera to apply the render pass to.
  54559. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54560. * @param engine The engine which the post process will be applied. (default: current engine)
  54561. * @param reusable If the post process can be reused on the same frame. (default: false)
  54562. * @param textureType Type of textures used when performing the post process. (default: 0)
  54563. */
  54564. constructor(name: string,
  54565. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54566. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54567. /**
  54568. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54569. */
  54570. static EdgeDetect0Kernel: number[];
  54571. /**
  54572. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54573. */
  54574. static EdgeDetect1Kernel: number[];
  54575. /**
  54576. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54577. */
  54578. static EdgeDetect2Kernel: number[];
  54579. /**
  54580. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54581. */
  54582. static SharpenKernel: number[];
  54583. /**
  54584. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54585. */
  54586. static EmbossKernel: number[];
  54587. /**
  54588. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54589. */
  54590. static GaussianKernel: number[];
  54591. }
  54592. }
  54593. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  54594. import { Nullable } from "babylonjs/types";
  54595. import { Vector2 } from "babylonjs/Maths/math";
  54596. import { Camera } from "babylonjs/Cameras/camera";
  54597. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54598. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54599. import { Engine } from "babylonjs/Engines/engine";
  54600. import { Scene } from "babylonjs/scene";
  54601. /**
  54602. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  54603. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  54604. * based on samples that have a large difference in distance than the center pixel.
  54605. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  54606. */
  54607. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  54608. direction: Vector2;
  54609. /**
  54610. * Creates a new instance CircleOfConfusionPostProcess
  54611. * @param name The name of the effect.
  54612. * @param scene The scene the effect belongs to.
  54613. * @param direction The direction the blur should be applied.
  54614. * @param kernel The size of the kernel used to blur.
  54615. * @param options The required width/height ratio to downsize to before computing the render pass.
  54616. * @param camera The camera to apply the render pass to.
  54617. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  54618. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  54619. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54620. * @param engine The engine which the post process will be applied. (default: current engine)
  54621. * @param reusable If the post process can be reused on the same frame. (default: false)
  54622. * @param textureType Type of textures used when performing the post process. (default: 0)
  54623. * @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)
  54624. */
  54625. 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);
  54626. }
  54627. }
  54628. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  54629. /** @hidden */
  54630. export var depthOfFieldMergePixelShader: {
  54631. name: string;
  54632. shader: string;
  54633. };
  54634. }
  54635. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  54636. import { Nullable } from "babylonjs/types";
  54637. import { Camera } from "babylonjs/Cameras/camera";
  54638. import { Effect } from "babylonjs/Materials/effect";
  54639. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54640. import { Engine } from "babylonjs/Engines/engine";
  54641. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  54642. /**
  54643. * Options to be set when merging outputs from the default pipeline.
  54644. */
  54645. export class DepthOfFieldMergePostProcessOptions {
  54646. /**
  54647. * The original image to merge on top of
  54648. */
  54649. originalFromInput: PostProcess;
  54650. /**
  54651. * Parameters to perform the merge of the depth of field effect
  54652. */
  54653. depthOfField?: {
  54654. circleOfConfusion: PostProcess;
  54655. blurSteps: Array<PostProcess>;
  54656. };
  54657. /**
  54658. * Parameters to perform the merge of bloom effect
  54659. */
  54660. bloom?: {
  54661. blurred: PostProcess;
  54662. weight: number;
  54663. };
  54664. }
  54665. /**
  54666. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54667. */
  54668. export class DepthOfFieldMergePostProcess extends PostProcess {
  54669. private blurSteps;
  54670. /**
  54671. * Creates a new instance of DepthOfFieldMergePostProcess
  54672. * @param name The name of the effect.
  54673. * @param originalFromInput Post process which's input will be used for the merge.
  54674. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  54675. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  54676. * @param options The required width/height ratio to downsize to before computing the render pass.
  54677. * @param camera The camera to apply the render pass to.
  54678. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54679. * @param engine The engine which the post process will be applied. (default: current engine)
  54680. * @param reusable If the post process can be reused on the same frame. (default: false)
  54681. * @param textureType Type of textures used when performing the post process. (default: 0)
  54682. * @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)
  54683. */
  54684. 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);
  54685. /**
  54686. * Updates the effect with the current post process compile time values and recompiles the shader.
  54687. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  54688. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  54689. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  54690. * @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
  54691. * @param onCompiled Called when the shader has been compiled.
  54692. * @param onError Called if there is an error when compiling a shader.
  54693. */
  54694. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  54695. }
  54696. }
  54697. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  54698. import { Nullable } from "babylonjs/types";
  54699. import { Camera } from "babylonjs/Cameras/camera";
  54700. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54701. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54702. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54703. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  54704. import { Scene } from "babylonjs/scene";
  54705. /**
  54706. * Specifies the level of max blur that should be applied when using the depth of field effect
  54707. */
  54708. export enum DepthOfFieldEffectBlurLevel {
  54709. /**
  54710. * Subtle blur
  54711. */
  54712. Low = 0,
  54713. /**
  54714. * Medium blur
  54715. */
  54716. Medium = 1,
  54717. /**
  54718. * Large blur
  54719. */
  54720. High = 2
  54721. }
  54722. /**
  54723. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  54724. */
  54725. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  54726. private _circleOfConfusion;
  54727. /**
  54728. * @hidden Internal, blurs from high to low
  54729. */
  54730. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  54731. private _depthOfFieldBlurY;
  54732. private _dofMerge;
  54733. /**
  54734. * @hidden Internal post processes in depth of field effect
  54735. */
  54736. _effects: Array<PostProcess>;
  54737. /**
  54738. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  54739. */
  54740. focalLength: number;
  54741. /**
  54742. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54743. */
  54744. fStop: number;
  54745. /**
  54746. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54747. */
  54748. focusDistance: number;
  54749. /**
  54750. * 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.
  54751. */
  54752. lensSize: number;
  54753. /**
  54754. * Creates a new instance DepthOfFieldEffect
  54755. * @param scene The scene the effect belongs to.
  54756. * @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.
  54757. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54758. * @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)
  54759. */
  54760. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  54761. /**
  54762. * 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.
  54763. */
  54764. depthTexture: RenderTargetTexture;
  54765. /**
  54766. * Disposes each of the internal effects for a given camera.
  54767. * @param camera The camera to dispose the effect on.
  54768. */
  54769. disposeEffects(camera: Camera): void;
  54770. /**
  54771. * @hidden Internal
  54772. */
  54773. _updateEffects(): void;
  54774. /**
  54775. * Internal
  54776. * @returns if all the contained post processes are ready.
  54777. * @hidden
  54778. */
  54779. _isReady(): boolean;
  54780. }
  54781. }
  54782. declare module "babylonjs/Shaders/displayPass.fragment" {
  54783. /** @hidden */
  54784. export var displayPassPixelShader: {
  54785. name: string;
  54786. shader: string;
  54787. };
  54788. }
  54789. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  54790. import { Nullable } from "babylonjs/types";
  54791. import { Camera } from "babylonjs/Cameras/camera";
  54792. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54793. import { Engine } from "babylonjs/Engines/engine";
  54794. import "babylonjs/Shaders/displayPass.fragment";
  54795. /**
  54796. * DisplayPassPostProcess which produces an output the same as it's input
  54797. */
  54798. export class DisplayPassPostProcess extends PostProcess {
  54799. /**
  54800. * Creates the DisplayPassPostProcess
  54801. * @param name The name of the effect.
  54802. * @param options The required width/height ratio to downsize to before computing the render pass.
  54803. * @param camera The camera to apply the render pass to.
  54804. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54805. * @param engine The engine which the post process will be applied. (default: current engine)
  54806. * @param reusable If the post process can be reused on the same frame. (default: false)
  54807. */
  54808. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54809. }
  54810. }
  54811. declare module "babylonjs/Shaders/filter.fragment" {
  54812. /** @hidden */
  54813. export var filterPixelShader: {
  54814. name: string;
  54815. shader: string;
  54816. };
  54817. }
  54818. declare module "babylonjs/PostProcesses/filterPostProcess" {
  54819. import { Nullable } from "babylonjs/types";
  54820. import { Matrix } from "babylonjs/Maths/math";
  54821. import { Camera } from "babylonjs/Cameras/camera";
  54822. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54823. import { Engine } from "babylonjs/Engines/engine";
  54824. import "babylonjs/Shaders/filter.fragment";
  54825. /**
  54826. * Applies a kernel filter to the image
  54827. */
  54828. export class FilterPostProcess extends PostProcess {
  54829. /** The matrix to be applied to the image */
  54830. kernelMatrix: Matrix;
  54831. /**
  54832. *
  54833. * @param name The name of the effect.
  54834. * @param kernelMatrix The matrix to be applied to the image
  54835. * @param options The required width/height ratio to downsize to before computing the render pass.
  54836. * @param camera The camera to apply the render pass to.
  54837. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54838. * @param engine The engine which the post process will be applied. (default: current engine)
  54839. * @param reusable If the post process can be reused on the same frame. (default: false)
  54840. */
  54841. constructor(name: string,
  54842. /** The matrix to be applied to the image */
  54843. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54844. }
  54845. }
  54846. declare module "babylonjs/Shaders/fxaa.fragment" {
  54847. /** @hidden */
  54848. export var fxaaPixelShader: {
  54849. name: string;
  54850. shader: string;
  54851. };
  54852. }
  54853. declare module "babylonjs/Shaders/fxaa.vertex" {
  54854. /** @hidden */
  54855. export var fxaaVertexShader: {
  54856. name: string;
  54857. shader: string;
  54858. };
  54859. }
  54860. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  54861. import { Nullable } from "babylonjs/types";
  54862. import { Camera } from "babylonjs/Cameras/camera";
  54863. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54864. import { Engine } from "babylonjs/Engines/engine";
  54865. import "babylonjs/Shaders/fxaa.fragment";
  54866. import "babylonjs/Shaders/fxaa.vertex";
  54867. /**
  54868. * Fxaa post process
  54869. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  54870. */
  54871. export class FxaaPostProcess extends PostProcess {
  54872. /** @hidden */
  54873. texelWidth: number;
  54874. /** @hidden */
  54875. texelHeight: number;
  54876. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54877. private _getDefines;
  54878. }
  54879. }
  54880. declare module "babylonjs/Shaders/grain.fragment" {
  54881. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54882. /** @hidden */
  54883. export var grainPixelShader: {
  54884. name: string;
  54885. shader: string;
  54886. };
  54887. }
  54888. declare module "babylonjs/PostProcesses/grainPostProcess" {
  54889. import { Nullable } from "babylonjs/types";
  54890. import { Camera } from "babylonjs/Cameras/camera";
  54891. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54892. import { Engine } from "babylonjs/Engines/engine";
  54893. import "babylonjs/Shaders/grain.fragment";
  54894. /**
  54895. * The GrainPostProcess adds noise to the image at mid luminance levels
  54896. */
  54897. export class GrainPostProcess extends PostProcess {
  54898. /**
  54899. * The intensity of the grain added (default: 30)
  54900. */
  54901. intensity: number;
  54902. /**
  54903. * If the grain should be randomized on every frame
  54904. */
  54905. animated: boolean;
  54906. /**
  54907. * Creates a new instance of @see GrainPostProcess
  54908. * @param name The name of the effect.
  54909. * @param options The required width/height ratio to downsize to before computing the render pass.
  54910. * @param camera The camera to apply the render pass to.
  54911. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54912. * @param engine The engine which the post process will be applied. (default: current engine)
  54913. * @param reusable If the post process can be reused on the same frame. (default: false)
  54914. * @param textureType Type of textures used when performing the post process. (default: 0)
  54915. * @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)
  54916. */
  54917. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54918. }
  54919. }
  54920. declare module "babylonjs/Shaders/highlights.fragment" {
  54921. /** @hidden */
  54922. export var highlightsPixelShader: {
  54923. name: string;
  54924. shader: string;
  54925. };
  54926. }
  54927. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  54928. import { Nullable } from "babylonjs/types";
  54929. import { Camera } from "babylonjs/Cameras/camera";
  54930. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54931. import { Engine } from "babylonjs/Engines/engine";
  54932. import "babylonjs/Shaders/highlights.fragment";
  54933. /**
  54934. * Extracts highlights from the image
  54935. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54936. */
  54937. export class HighlightsPostProcess extends PostProcess {
  54938. /**
  54939. * Extracts highlights from the image
  54940. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54941. * @param name The name of the effect.
  54942. * @param options The required width/height ratio to downsize to before computing the render pass.
  54943. * @param camera The camera to apply the render pass to.
  54944. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54945. * @param engine The engine which the post process will be applied. (default: current engine)
  54946. * @param reusable If the post process can be reused on the same frame. (default: false)
  54947. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  54948. */
  54949. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54950. }
  54951. }
  54952. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  54953. /** @hidden */
  54954. export var mrtFragmentDeclaration: {
  54955. name: string;
  54956. shader: string;
  54957. };
  54958. }
  54959. declare module "babylonjs/Shaders/geometry.fragment" {
  54960. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  54961. /** @hidden */
  54962. export var geometryPixelShader: {
  54963. name: string;
  54964. shader: string;
  54965. };
  54966. }
  54967. declare module "babylonjs/Shaders/geometry.vertex" {
  54968. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54969. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54970. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54971. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54972. /** @hidden */
  54973. export var geometryVertexShader: {
  54974. name: string;
  54975. shader: string;
  54976. };
  54977. }
  54978. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  54979. import { Matrix } from "babylonjs/Maths/math";
  54980. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54981. import { Mesh } from "babylonjs/Meshes/mesh";
  54982. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  54983. import { Effect } from "babylonjs/Materials/effect";
  54984. import { Scene } from "babylonjs/scene";
  54985. import "babylonjs/Shaders/geometry.fragment";
  54986. import "babylonjs/Shaders/geometry.vertex";
  54987. /**
  54988. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  54989. */
  54990. export class GeometryBufferRenderer {
  54991. /**
  54992. * Constant used to retrieve the position texture index in the G-Buffer textures array
  54993. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  54994. */
  54995. static readonly POSITION_TEXTURE_TYPE: number;
  54996. /**
  54997. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  54998. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  54999. */
  55000. static readonly VELOCITY_TEXTURE_TYPE: number;
  55001. /**
  55002. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55003. * in order to compute objects velocities when enableVelocity is set to "true"
  55004. * @hidden
  55005. */
  55006. _previousTransformationMatrices: {
  55007. [index: number]: Matrix;
  55008. };
  55009. private _scene;
  55010. private _multiRenderTarget;
  55011. private _ratio;
  55012. private _enablePosition;
  55013. private _enableVelocity;
  55014. private _positionIndex;
  55015. private _velocityIndex;
  55016. protected _effect: Effect;
  55017. protected _cachedDefines: string;
  55018. /**
  55019. * Set the render list (meshes to be rendered) used in the G buffer.
  55020. */
  55021. renderList: Mesh[];
  55022. /**
  55023. * Gets wether or not G buffer are supported by the running hardware.
  55024. * This requires draw buffer supports
  55025. */
  55026. readonly isSupported: boolean;
  55027. /**
  55028. * Returns the index of the given texture type in the G-Buffer textures array
  55029. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55030. * @returns the index of the given texture type in the G-Buffer textures array
  55031. */
  55032. getTextureIndex(textureType: number): number;
  55033. /**
  55034. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55035. */
  55036. /**
  55037. * Sets whether or not objects positions are enabled for the G buffer.
  55038. */
  55039. enablePosition: boolean;
  55040. /**
  55041. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55042. */
  55043. /**
  55044. * Sets wether or not objects velocities are enabled for the G buffer.
  55045. */
  55046. enableVelocity: boolean;
  55047. /**
  55048. * Gets the scene associated with the buffer.
  55049. */
  55050. readonly scene: Scene;
  55051. /**
  55052. * Gets the ratio used by the buffer during its creation.
  55053. * How big is the buffer related to the main canvas.
  55054. */
  55055. readonly ratio: number;
  55056. /** @hidden */
  55057. static _SceneComponentInitialization: (scene: Scene) => void;
  55058. /**
  55059. * Creates a new G Buffer for the scene
  55060. * @param scene The scene the buffer belongs to
  55061. * @param ratio How big is the buffer related to the main canvas.
  55062. */
  55063. constructor(scene: Scene, ratio?: number);
  55064. /**
  55065. * Checks wether everything is ready to render a submesh to the G buffer.
  55066. * @param subMesh the submesh to check readiness for
  55067. * @param useInstances is the mesh drawn using instance or not
  55068. * @returns true if ready otherwise false
  55069. */
  55070. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55071. /**
  55072. * Gets the current underlying G Buffer.
  55073. * @returns the buffer
  55074. */
  55075. getGBuffer(): MultiRenderTarget;
  55076. /**
  55077. * Gets the number of samples used to render the buffer (anti aliasing).
  55078. */
  55079. /**
  55080. * Sets the number of samples used to render the buffer (anti aliasing).
  55081. */
  55082. samples: number;
  55083. /**
  55084. * Disposes the renderer and frees up associated resources.
  55085. */
  55086. dispose(): void;
  55087. protected _createRenderTargets(): void;
  55088. }
  55089. }
  55090. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55091. import { Nullable } from "babylonjs/types";
  55092. import { Scene } from "babylonjs/scene";
  55093. import { ISceneComponent } from "babylonjs/sceneComponent";
  55094. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55095. module "babylonjs/scene" {
  55096. interface Scene {
  55097. /** @hidden (Backing field) */
  55098. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55099. /**
  55100. * Gets or Sets the current geometry buffer associated to the scene.
  55101. */
  55102. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55103. /**
  55104. * Enables a GeometryBufferRender and associates it with the scene
  55105. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55106. * @returns the GeometryBufferRenderer
  55107. */
  55108. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55109. /**
  55110. * Disables the GeometryBufferRender associated with the scene
  55111. */
  55112. disableGeometryBufferRenderer(): void;
  55113. }
  55114. }
  55115. /**
  55116. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55117. * in several rendering techniques.
  55118. */
  55119. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55120. /**
  55121. * The component name helpful to identify the component in the list of scene components.
  55122. */
  55123. readonly name: string;
  55124. /**
  55125. * The scene the component belongs to.
  55126. */
  55127. scene: Scene;
  55128. /**
  55129. * Creates a new instance of the component for the given scene
  55130. * @param scene Defines the scene to register the component in
  55131. */
  55132. constructor(scene: Scene);
  55133. /**
  55134. * Registers the component in a given scene
  55135. */
  55136. register(): void;
  55137. /**
  55138. * Rebuilds the elements related to this component in case of
  55139. * context lost for instance.
  55140. */
  55141. rebuild(): void;
  55142. /**
  55143. * Disposes the component and the associated ressources
  55144. */
  55145. dispose(): void;
  55146. private _gatherRenderTargets;
  55147. }
  55148. }
  55149. declare module "babylonjs/Shaders/motionBlur.fragment" {
  55150. /** @hidden */
  55151. export var motionBlurPixelShader: {
  55152. name: string;
  55153. shader: string;
  55154. };
  55155. }
  55156. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  55157. import { Nullable } from "babylonjs/types";
  55158. import { Camera } from "babylonjs/Cameras/camera";
  55159. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55160. import { Scene } from "babylonjs/scene";
  55161. import "babylonjs/Animations/animatable";
  55162. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55163. import "babylonjs/Shaders/motionBlur.fragment";
  55164. import { Engine } from "babylonjs/Engines/engine";
  55165. /**
  55166. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55167. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55168. * As an example, all you have to do is to create the post-process:
  55169. * var mb = new BABYLON.MotionBlurPostProcess(
  55170. * 'mb', // The name of the effect.
  55171. * scene, // The scene containing the objects to blur according to their velocity.
  55172. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55173. * camera // The camera to apply the render pass to.
  55174. * );
  55175. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55176. */
  55177. export class MotionBlurPostProcess extends PostProcess {
  55178. /**
  55179. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55180. */
  55181. motionStrength: number;
  55182. /**
  55183. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55184. */
  55185. /**
  55186. * Sets the number of iterations to be used for motion blur quality
  55187. */
  55188. motionBlurSamples: number;
  55189. private _motionBlurSamples;
  55190. private _geometryBufferRenderer;
  55191. /**
  55192. * Creates a new instance MotionBlurPostProcess
  55193. * @param name The name of the effect.
  55194. * @param scene The scene containing the objects to blur according to their velocity.
  55195. * @param options The required width/height ratio to downsize to before computing the render pass.
  55196. * @param camera The camera to apply the render pass to.
  55197. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55198. * @param engine The engine which the post process will be applied. (default: current engine)
  55199. * @param reusable If the post process can be reused on the same frame. (default: false)
  55200. * @param textureType Type of textures used when performing the post process. (default: 0)
  55201. * @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)
  55202. */
  55203. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55204. /**
  55205. * Disposes the post process.
  55206. * @param camera The camera to dispose the post process on.
  55207. */
  55208. dispose(camera?: Camera): void;
  55209. }
  55210. }
  55211. declare module "babylonjs/Shaders/refraction.fragment" {
  55212. /** @hidden */
  55213. export var refractionPixelShader: {
  55214. name: string;
  55215. shader: string;
  55216. };
  55217. }
  55218. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  55219. import { Color3 } from "babylonjs/Maths/math";
  55220. import { Camera } from "babylonjs/Cameras/camera";
  55221. import { Texture } from "babylonjs/Materials/Textures/texture";
  55222. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55223. import { Engine } from "babylonjs/Engines/engine";
  55224. import "babylonjs/Shaders/refraction.fragment";
  55225. /**
  55226. * Post process which applies a refractin texture
  55227. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55228. */
  55229. export class RefractionPostProcess extends PostProcess {
  55230. /** the base color of the refraction (used to taint the rendering) */
  55231. color: Color3;
  55232. /** simulated refraction depth */
  55233. depth: number;
  55234. /** the coefficient of the base color (0 to remove base color tainting) */
  55235. colorLevel: number;
  55236. private _refTexture;
  55237. private _ownRefractionTexture;
  55238. /**
  55239. * Gets or sets the refraction texture
  55240. * Please note that you are responsible for disposing the texture if you set it manually
  55241. */
  55242. refractionTexture: Texture;
  55243. /**
  55244. * Initializes the RefractionPostProcess
  55245. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55246. * @param name The name of the effect.
  55247. * @param refractionTextureUrl Url of the refraction texture to use
  55248. * @param color the base color of the refraction (used to taint the rendering)
  55249. * @param depth simulated refraction depth
  55250. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55251. * @param camera The camera to apply the render pass to.
  55252. * @param options The required width/height ratio to downsize to before computing the render pass.
  55253. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55254. * @param engine The engine which the post process will be applied. (default: current engine)
  55255. * @param reusable If the post process can be reused on the same frame. (default: false)
  55256. */
  55257. constructor(name: string, refractionTextureUrl: string,
  55258. /** the base color of the refraction (used to taint the rendering) */
  55259. color: Color3,
  55260. /** simulated refraction depth */
  55261. depth: number,
  55262. /** the coefficient of the base color (0 to remove base color tainting) */
  55263. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55264. /**
  55265. * Disposes of the post process
  55266. * @param camera Camera to dispose post process on
  55267. */
  55268. dispose(camera: Camera): void;
  55269. }
  55270. }
  55271. declare module "babylonjs/Shaders/sharpen.fragment" {
  55272. /** @hidden */
  55273. export var sharpenPixelShader: {
  55274. name: string;
  55275. shader: string;
  55276. };
  55277. }
  55278. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  55279. import { Nullable } from "babylonjs/types";
  55280. import { Camera } from "babylonjs/Cameras/camera";
  55281. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55282. import "babylonjs/Shaders/sharpen.fragment";
  55283. import { Engine } from "babylonjs/Engines/engine";
  55284. /**
  55285. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55286. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55287. */
  55288. export class SharpenPostProcess extends PostProcess {
  55289. /**
  55290. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55291. */
  55292. colorAmount: number;
  55293. /**
  55294. * How much sharpness should be applied (default: 0.3)
  55295. */
  55296. edgeAmount: number;
  55297. /**
  55298. * Creates a new instance ConvolutionPostProcess
  55299. * @param name The name of the effect.
  55300. * @param options The required width/height ratio to downsize to before computing the render pass.
  55301. * @param camera The camera to apply the render pass to.
  55302. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55303. * @param engine The engine which the post process will be applied. (default: current engine)
  55304. * @param reusable If the post process can be reused on the same frame. (default: false)
  55305. * @param textureType Type of textures used when performing the post process. (default: 0)
  55306. * @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)
  55307. */
  55308. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55309. }
  55310. }
  55311. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  55312. import { Nullable } from "babylonjs/types";
  55313. import { Camera } from "babylonjs/Cameras/camera";
  55314. import { Engine } from "babylonjs/Engines/engine";
  55315. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55316. import { IInspectable } from "babylonjs/Misc/iInspectable";
  55317. /**
  55318. * PostProcessRenderPipeline
  55319. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55320. */
  55321. export class PostProcessRenderPipeline {
  55322. private engine;
  55323. private _renderEffects;
  55324. private _renderEffectsForIsolatedPass;
  55325. /**
  55326. * List of inspectable custom properties (used by the Inspector)
  55327. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55328. */
  55329. inspectableCustomProperties: IInspectable[];
  55330. /**
  55331. * @hidden
  55332. */
  55333. protected _cameras: Camera[];
  55334. /** @hidden */
  55335. _name: string;
  55336. /**
  55337. * Gets pipeline name
  55338. */
  55339. readonly name: string;
  55340. /**
  55341. * Initializes a PostProcessRenderPipeline
  55342. * @param engine engine to add the pipeline to
  55343. * @param name name of the pipeline
  55344. */
  55345. constructor(engine: Engine, name: string);
  55346. /**
  55347. * Gets the class name
  55348. * @returns "PostProcessRenderPipeline"
  55349. */
  55350. getClassName(): string;
  55351. /**
  55352. * If all the render effects in the pipeline are supported
  55353. */
  55354. readonly isSupported: boolean;
  55355. /**
  55356. * Adds an effect to the pipeline
  55357. * @param renderEffect the effect to add
  55358. */
  55359. addEffect(renderEffect: PostProcessRenderEffect): void;
  55360. /** @hidden */
  55361. _rebuild(): void;
  55362. /** @hidden */
  55363. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55364. /** @hidden */
  55365. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55366. /** @hidden */
  55367. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55368. /** @hidden */
  55369. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55370. /** @hidden */
  55371. _attachCameras(cameras: Camera, unique: boolean): void;
  55372. /** @hidden */
  55373. _attachCameras(cameras: Camera[], unique: boolean): void;
  55374. /** @hidden */
  55375. _detachCameras(cameras: Camera): void;
  55376. /** @hidden */
  55377. _detachCameras(cameras: Nullable<Camera[]>): void;
  55378. /** @hidden */
  55379. _update(): void;
  55380. /** @hidden */
  55381. _reset(): void;
  55382. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55383. /**
  55384. * Disposes of the pipeline
  55385. */
  55386. dispose(): void;
  55387. }
  55388. }
  55389. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  55390. import { Camera } from "babylonjs/Cameras/camera";
  55391. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55392. /**
  55393. * PostProcessRenderPipelineManager class
  55394. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55395. */
  55396. export class PostProcessRenderPipelineManager {
  55397. private _renderPipelines;
  55398. /**
  55399. * Initializes a PostProcessRenderPipelineManager
  55400. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55401. */
  55402. constructor();
  55403. /**
  55404. * Gets the list of supported render pipelines
  55405. */
  55406. readonly supportedPipelines: PostProcessRenderPipeline[];
  55407. /**
  55408. * Adds a pipeline to the manager
  55409. * @param renderPipeline The pipeline to add
  55410. */
  55411. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55412. /**
  55413. * Attaches a camera to the pipeline
  55414. * @param renderPipelineName The name of the pipeline to attach to
  55415. * @param cameras the camera to attach
  55416. * @param unique if the camera can be attached multiple times to the pipeline
  55417. */
  55418. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55419. /**
  55420. * Detaches a camera from the pipeline
  55421. * @param renderPipelineName The name of the pipeline to detach from
  55422. * @param cameras the camera to detach
  55423. */
  55424. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55425. /**
  55426. * Enables an effect by name on a pipeline
  55427. * @param renderPipelineName the name of the pipeline to enable the effect in
  55428. * @param renderEffectName the name of the effect to enable
  55429. * @param cameras the cameras that the effect should be enabled on
  55430. */
  55431. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55432. /**
  55433. * Disables an effect by name on a pipeline
  55434. * @param renderPipelineName the name of the pipeline to disable the effect in
  55435. * @param renderEffectName the name of the effect to disable
  55436. * @param cameras the cameras that the effect should be disabled on
  55437. */
  55438. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55439. /**
  55440. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55441. */
  55442. update(): void;
  55443. /** @hidden */
  55444. _rebuild(): void;
  55445. /**
  55446. * Disposes of the manager and pipelines
  55447. */
  55448. dispose(): void;
  55449. }
  55450. }
  55451. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  55452. import { ISceneComponent } from "babylonjs/sceneComponent";
  55453. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55454. import { Scene } from "babylonjs/scene";
  55455. module "babylonjs/scene" {
  55456. interface Scene {
  55457. /** @hidden (Backing field) */
  55458. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55459. /**
  55460. * Gets the postprocess render pipeline manager
  55461. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55462. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55463. */
  55464. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55465. }
  55466. }
  55467. /**
  55468. * Defines the Render Pipeline scene component responsible to rendering pipelines
  55469. */
  55470. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  55471. /**
  55472. * The component name helpfull to identify the component in the list of scene components.
  55473. */
  55474. readonly name: string;
  55475. /**
  55476. * The scene the component belongs to.
  55477. */
  55478. scene: Scene;
  55479. /**
  55480. * Creates a new instance of the component for the given scene
  55481. * @param scene Defines the scene to register the component in
  55482. */
  55483. constructor(scene: Scene);
  55484. /**
  55485. * Registers the component in a given scene
  55486. */
  55487. register(): void;
  55488. /**
  55489. * Rebuilds the elements related to this component in case of
  55490. * context lost for instance.
  55491. */
  55492. rebuild(): void;
  55493. /**
  55494. * Disposes the component and the associated ressources
  55495. */
  55496. dispose(): void;
  55497. private _gatherRenderTargets;
  55498. }
  55499. }
  55500. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  55501. import { IAnimatable } from "babylonjs/Misc/tools";
  55502. import { Camera } from "babylonjs/Cameras/camera";
  55503. import { IDisposable } from "babylonjs/scene";
  55504. import { Scene } from "babylonjs/scene";
  55505. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  55506. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55507. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55508. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  55509. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  55510. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55511. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  55512. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  55513. import { Animation } from "babylonjs/Animations/animation";
  55514. /**
  55515. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  55516. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55517. */
  55518. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55519. private _scene;
  55520. private _camerasToBeAttached;
  55521. /**
  55522. * ID of the sharpen post process,
  55523. */
  55524. private readonly SharpenPostProcessId;
  55525. /**
  55526. * @ignore
  55527. * ID of the image processing post process;
  55528. */
  55529. readonly ImageProcessingPostProcessId: string;
  55530. /**
  55531. * @ignore
  55532. * ID of the Fast Approximate Anti-Aliasing post process;
  55533. */
  55534. readonly FxaaPostProcessId: string;
  55535. /**
  55536. * ID of the chromatic aberration post process,
  55537. */
  55538. private readonly ChromaticAberrationPostProcessId;
  55539. /**
  55540. * ID of the grain post process
  55541. */
  55542. private readonly GrainPostProcessId;
  55543. /**
  55544. * Sharpen post process which will apply a sharpen convolution to enhance edges
  55545. */
  55546. sharpen: SharpenPostProcess;
  55547. private _sharpenEffect;
  55548. private bloom;
  55549. /**
  55550. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  55551. */
  55552. depthOfField: DepthOfFieldEffect;
  55553. /**
  55554. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55555. */
  55556. fxaa: FxaaPostProcess;
  55557. /**
  55558. * Image post processing pass used to perform operations such as tone mapping or color grading.
  55559. */
  55560. imageProcessing: ImageProcessingPostProcess;
  55561. /**
  55562. * Chromatic aberration post process which will shift rgb colors in the image
  55563. */
  55564. chromaticAberration: ChromaticAberrationPostProcess;
  55565. private _chromaticAberrationEffect;
  55566. /**
  55567. * Grain post process which add noise to the image
  55568. */
  55569. grain: GrainPostProcess;
  55570. private _grainEffect;
  55571. /**
  55572. * Glow post process which adds a glow to emissive areas of the image
  55573. */
  55574. private _glowLayer;
  55575. /**
  55576. * Animations which can be used to tweak settings over a period of time
  55577. */
  55578. animations: Animation[];
  55579. private _imageProcessingConfigurationObserver;
  55580. private _sharpenEnabled;
  55581. private _bloomEnabled;
  55582. private _depthOfFieldEnabled;
  55583. private _depthOfFieldBlurLevel;
  55584. private _fxaaEnabled;
  55585. private _imageProcessingEnabled;
  55586. private _defaultPipelineTextureType;
  55587. private _bloomScale;
  55588. private _chromaticAberrationEnabled;
  55589. private _grainEnabled;
  55590. private _buildAllowed;
  55591. /**
  55592. * Gets active scene
  55593. */
  55594. readonly scene: Scene;
  55595. /**
  55596. * Enable or disable the sharpen process from the pipeline
  55597. */
  55598. sharpenEnabled: boolean;
  55599. private _resizeObserver;
  55600. private _hardwareScaleLevel;
  55601. private _bloomKernel;
  55602. /**
  55603. * Specifies the size of the bloom blur kernel, relative to the final output size
  55604. */
  55605. bloomKernel: number;
  55606. /**
  55607. * Specifies the weight of the bloom in the final rendering
  55608. */
  55609. private _bloomWeight;
  55610. /**
  55611. * Specifies the luma threshold for the area that will be blurred by the bloom
  55612. */
  55613. private _bloomThreshold;
  55614. private _hdr;
  55615. /**
  55616. * The strength of the bloom.
  55617. */
  55618. bloomWeight: number;
  55619. /**
  55620. * The strength of the bloom.
  55621. */
  55622. bloomThreshold: number;
  55623. /**
  55624. * The scale of the bloom, lower value will provide better performance.
  55625. */
  55626. bloomScale: number;
  55627. /**
  55628. * Enable or disable the bloom from the pipeline
  55629. */
  55630. bloomEnabled: boolean;
  55631. private _rebuildBloom;
  55632. /**
  55633. * If the depth of field is enabled.
  55634. */
  55635. depthOfFieldEnabled: boolean;
  55636. /**
  55637. * Blur level of the depth of field effect. (Higher blur will effect performance)
  55638. */
  55639. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  55640. /**
  55641. * If the anti aliasing is enabled.
  55642. */
  55643. fxaaEnabled: boolean;
  55644. private _samples;
  55645. /**
  55646. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55647. */
  55648. samples: number;
  55649. /**
  55650. * If image processing is enabled.
  55651. */
  55652. imageProcessingEnabled: boolean;
  55653. /**
  55654. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  55655. */
  55656. glowLayerEnabled: boolean;
  55657. /**
  55658. * Enable or disable the chromaticAberration process from the pipeline
  55659. */
  55660. chromaticAberrationEnabled: boolean;
  55661. /**
  55662. * Enable or disable the grain process from the pipeline
  55663. */
  55664. grainEnabled: boolean;
  55665. /**
  55666. * @constructor
  55667. * @param name - The rendering pipeline name (default: "")
  55668. * @param hdr - If high dynamic range textures should be used (default: true)
  55669. * @param scene - The scene linked to this pipeline (default: the last created scene)
  55670. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  55671. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  55672. */
  55673. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  55674. /**
  55675. * Get the class name
  55676. * @returns "DefaultRenderingPipeline"
  55677. */
  55678. getClassName(): string;
  55679. /**
  55680. * Force the compilation of the entire pipeline.
  55681. */
  55682. prepare(): void;
  55683. private _hasCleared;
  55684. private _prevPostProcess;
  55685. private _prevPrevPostProcess;
  55686. private _setAutoClearAndTextureSharing;
  55687. private _depthOfFieldSceneObserver;
  55688. private _buildPipeline;
  55689. private _disposePostProcesses;
  55690. /**
  55691. * Adds a camera to the pipeline
  55692. * @param camera the camera to be added
  55693. */
  55694. addCamera(camera: Camera): void;
  55695. /**
  55696. * Removes a camera from the pipeline
  55697. * @param camera the camera to remove
  55698. */
  55699. removeCamera(camera: Camera): void;
  55700. /**
  55701. * Dispose of the pipeline and stop all post processes
  55702. */
  55703. dispose(): void;
  55704. /**
  55705. * Serialize the rendering pipeline (Used when exporting)
  55706. * @returns the serialized object
  55707. */
  55708. serialize(): any;
  55709. /**
  55710. * Parse the serialized pipeline
  55711. * @param source Source pipeline.
  55712. * @param scene The scene to load the pipeline to.
  55713. * @param rootUrl The URL of the serialized pipeline.
  55714. * @returns An instantiated pipeline from the serialized object.
  55715. */
  55716. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  55717. }
  55718. }
  55719. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  55720. /** @hidden */
  55721. export var lensHighlightsPixelShader: {
  55722. name: string;
  55723. shader: string;
  55724. };
  55725. }
  55726. declare module "babylonjs/Shaders/depthOfField.fragment" {
  55727. /** @hidden */
  55728. export var depthOfFieldPixelShader: {
  55729. name: string;
  55730. shader: string;
  55731. };
  55732. }
  55733. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  55734. import { Camera } from "babylonjs/Cameras/camera";
  55735. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55736. import { Scene } from "babylonjs/scene";
  55737. import "babylonjs/Shaders/chromaticAberration.fragment";
  55738. import "babylonjs/Shaders/lensHighlights.fragment";
  55739. import "babylonjs/Shaders/depthOfField.fragment";
  55740. /**
  55741. * BABYLON.JS Chromatic Aberration GLSL Shader
  55742. * Author: Olivier Guyot
  55743. * Separates very slightly R, G and B colors on the edges of the screen
  55744. * Inspired by Francois Tarlier & Martins Upitis
  55745. */
  55746. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  55747. /**
  55748. * @ignore
  55749. * The chromatic aberration PostProcess id in the pipeline
  55750. */
  55751. LensChromaticAberrationEffect: string;
  55752. /**
  55753. * @ignore
  55754. * The highlights enhancing PostProcess id in the pipeline
  55755. */
  55756. HighlightsEnhancingEffect: string;
  55757. /**
  55758. * @ignore
  55759. * The depth-of-field PostProcess id in the pipeline
  55760. */
  55761. LensDepthOfFieldEffect: string;
  55762. private _scene;
  55763. private _depthTexture;
  55764. private _grainTexture;
  55765. private _chromaticAberrationPostProcess;
  55766. private _highlightsPostProcess;
  55767. private _depthOfFieldPostProcess;
  55768. private _edgeBlur;
  55769. private _grainAmount;
  55770. private _chromaticAberration;
  55771. private _distortion;
  55772. private _highlightsGain;
  55773. private _highlightsThreshold;
  55774. private _dofDistance;
  55775. private _dofAperture;
  55776. private _dofDarken;
  55777. private _dofPentagon;
  55778. private _blurNoise;
  55779. /**
  55780. * @constructor
  55781. *
  55782. * Effect parameters are as follow:
  55783. * {
  55784. * chromatic_aberration: number; // from 0 to x (1 for realism)
  55785. * edge_blur: number; // from 0 to x (1 for realism)
  55786. * distortion: number; // from 0 to x (1 for realism)
  55787. * grain_amount: number; // from 0 to 1
  55788. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  55789. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  55790. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  55791. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  55792. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  55793. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  55794. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  55795. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  55796. * }
  55797. * Note: if an effect parameter is unset, effect is disabled
  55798. *
  55799. * @param name The rendering pipeline name
  55800. * @param parameters - An object containing all parameters (see above)
  55801. * @param scene The scene linked to this pipeline
  55802. * @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)
  55803. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55804. */
  55805. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  55806. /**
  55807. * Get the class name
  55808. * @returns "LensRenderingPipeline"
  55809. */
  55810. getClassName(): string;
  55811. /**
  55812. * Gets associated scene
  55813. */
  55814. readonly scene: Scene;
  55815. /**
  55816. * Gets or sets the edge blur
  55817. */
  55818. edgeBlur: number;
  55819. /**
  55820. * Gets or sets the grain amount
  55821. */
  55822. grainAmount: number;
  55823. /**
  55824. * Gets or sets the chromatic aberration amount
  55825. */
  55826. chromaticAberration: number;
  55827. /**
  55828. * Gets or sets the depth of field aperture
  55829. */
  55830. dofAperture: number;
  55831. /**
  55832. * Gets or sets the edge distortion
  55833. */
  55834. edgeDistortion: number;
  55835. /**
  55836. * Gets or sets the depth of field distortion
  55837. */
  55838. dofDistortion: number;
  55839. /**
  55840. * Gets or sets the darken out of focus amount
  55841. */
  55842. darkenOutOfFocus: number;
  55843. /**
  55844. * Gets or sets a boolean indicating if blur noise is enabled
  55845. */
  55846. blurNoise: boolean;
  55847. /**
  55848. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  55849. */
  55850. pentagonBokeh: boolean;
  55851. /**
  55852. * Gets or sets the highlight grain amount
  55853. */
  55854. highlightsGain: number;
  55855. /**
  55856. * Gets or sets the highlight threshold
  55857. */
  55858. highlightsThreshold: number;
  55859. /**
  55860. * Sets the amount of blur at the edges
  55861. * @param amount blur amount
  55862. */
  55863. setEdgeBlur(amount: number): void;
  55864. /**
  55865. * Sets edge blur to 0
  55866. */
  55867. disableEdgeBlur(): void;
  55868. /**
  55869. * Sets the amout of grain
  55870. * @param amount Amount of grain
  55871. */
  55872. setGrainAmount(amount: number): void;
  55873. /**
  55874. * Set grain amount to 0
  55875. */
  55876. disableGrain(): void;
  55877. /**
  55878. * Sets the chromatic aberration amount
  55879. * @param amount amount of chromatic aberration
  55880. */
  55881. setChromaticAberration(amount: number): void;
  55882. /**
  55883. * Sets chromatic aberration amount to 0
  55884. */
  55885. disableChromaticAberration(): void;
  55886. /**
  55887. * Sets the EdgeDistortion amount
  55888. * @param amount amount of EdgeDistortion
  55889. */
  55890. setEdgeDistortion(amount: number): void;
  55891. /**
  55892. * Sets edge distortion to 0
  55893. */
  55894. disableEdgeDistortion(): void;
  55895. /**
  55896. * Sets the FocusDistance amount
  55897. * @param amount amount of FocusDistance
  55898. */
  55899. setFocusDistance(amount: number): void;
  55900. /**
  55901. * Disables depth of field
  55902. */
  55903. disableDepthOfField(): void;
  55904. /**
  55905. * Sets the Aperture amount
  55906. * @param amount amount of Aperture
  55907. */
  55908. setAperture(amount: number): void;
  55909. /**
  55910. * Sets the DarkenOutOfFocus amount
  55911. * @param amount amount of DarkenOutOfFocus
  55912. */
  55913. setDarkenOutOfFocus(amount: number): void;
  55914. private _pentagonBokehIsEnabled;
  55915. /**
  55916. * Creates a pentagon bokeh effect
  55917. */
  55918. enablePentagonBokeh(): void;
  55919. /**
  55920. * Disables the pentagon bokeh effect
  55921. */
  55922. disablePentagonBokeh(): void;
  55923. /**
  55924. * Enables noise blur
  55925. */
  55926. enableNoiseBlur(): void;
  55927. /**
  55928. * Disables noise blur
  55929. */
  55930. disableNoiseBlur(): void;
  55931. /**
  55932. * Sets the HighlightsGain amount
  55933. * @param amount amount of HighlightsGain
  55934. */
  55935. setHighlightsGain(amount: number): void;
  55936. /**
  55937. * Sets the HighlightsThreshold amount
  55938. * @param amount amount of HighlightsThreshold
  55939. */
  55940. setHighlightsThreshold(amount: number): void;
  55941. /**
  55942. * Disables highlights
  55943. */
  55944. disableHighlights(): void;
  55945. /**
  55946. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  55947. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  55948. */
  55949. dispose(disableDepthRender?: boolean): void;
  55950. private _createChromaticAberrationPostProcess;
  55951. private _createHighlightsPostProcess;
  55952. private _createDepthOfFieldPostProcess;
  55953. private _createGrainTexture;
  55954. }
  55955. }
  55956. declare module "babylonjs/Shaders/ssao2.fragment" {
  55957. /** @hidden */
  55958. export var ssao2PixelShader: {
  55959. name: string;
  55960. shader: string;
  55961. };
  55962. }
  55963. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  55964. /** @hidden */
  55965. export var ssaoCombinePixelShader: {
  55966. name: string;
  55967. shader: string;
  55968. };
  55969. }
  55970. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  55971. import { Camera } from "babylonjs/Cameras/camera";
  55972. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55973. import { Scene } from "babylonjs/scene";
  55974. import "babylonjs/Shaders/ssao2.fragment";
  55975. import "babylonjs/Shaders/ssaoCombine.fragment";
  55976. /**
  55977. * Render pipeline to produce ssao effect
  55978. */
  55979. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  55980. /**
  55981. * @ignore
  55982. * The PassPostProcess id in the pipeline that contains the original scene color
  55983. */
  55984. SSAOOriginalSceneColorEffect: string;
  55985. /**
  55986. * @ignore
  55987. * The SSAO PostProcess id in the pipeline
  55988. */
  55989. SSAORenderEffect: string;
  55990. /**
  55991. * @ignore
  55992. * The horizontal blur PostProcess id in the pipeline
  55993. */
  55994. SSAOBlurHRenderEffect: string;
  55995. /**
  55996. * @ignore
  55997. * The vertical blur PostProcess id in the pipeline
  55998. */
  55999. SSAOBlurVRenderEffect: string;
  56000. /**
  56001. * @ignore
  56002. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56003. */
  56004. SSAOCombineRenderEffect: string;
  56005. /**
  56006. * The output strength of the SSAO post-process. Default value is 1.0.
  56007. */
  56008. totalStrength: number;
  56009. /**
  56010. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56011. */
  56012. maxZ: number;
  56013. /**
  56014. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56015. */
  56016. minZAspect: number;
  56017. private _samples;
  56018. /**
  56019. * Number of samples used for the SSAO calculations. Default value is 8
  56020. */
  56021. samples: number;
  56022. private _textureSamples;
  56023. /**
  56024. * Number of samples to use for antialiasing
  56025. */
  56026. textureSamples: number;
  56027. /**
  56028. * Ratio object used for SSAO ratio and blur ratio
  56029. */
  56030. private _ratio;
  56031. /**
  56032. * Dynamically generated sphere sampler.
  56033. */
  56034. private _sampleSphere;
  56035. /**
  56036. * Blur filter offsets
  56037. */
  56038. private _samplerOffsets;
  56039. private _expensiveBlur;
  56040. /**
  56041. * If bilateral blur should be used
  56042. */
  56043. expensiveBlur: boolean;
  56044. /**
  56045. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56046. */
  56047. radius: number;
  56048. /**
  56049. * The base color of the SSAO post-process
  56050. * The final result is "base + ssao" between [0, 1]
  56051. */
  56052. base: number;
  56053. /**
  56054. * Support test.
  56055. */
  56056. static readonly IsSupported: boolean;
  56057. private _scene;
  56058. private _depthTexture;
  56059. private _normalTexture;
  56060. private _randomTexture;
  56061. private _originalColorPostProcess;
  56062. private _ssaoPostProcess;
  56063. private _blurHPostProcess;
  56064. private _blurVPostProcess;
  56065. private _ssaoCombinePostProcess;
  56066. private _firstUpdate;
  56067. /**
  56068. * Gets active scene
  56069. */
  56070. readonly scene: Scene;
  56071. /**
  56072. * @constructor
  56073. * @param name The rendering pipeline name
  56074. * @param scene The scene linked to this pipeline
  56075. * @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 }
  56076. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56077. */
  56078. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56079. /**
  56080. * Get the class name
  56081. * @returns "SSAO2RenderingPipeline"
  56082. */
  56083. getClassName(): string;
  56084. /**
  56085. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56086. */
  56087. dispose(disableGeometryBufferRenderer?: boolean): void;
  56088. private _createBlurPostProcess;
  56089. /** @hidden */
  56090. _rebuild(): void;
  56091. private _bits;
  56092. private _radicalInverse_VdC;
  56093. private _hammersley;
  56094. private _hemisphereSample_uniform;
  56095. private _generateHemisphere;
  56096. private _createSSAOPostProcess;
  56097. private _createSSAOCombinePostProcess;
  56098. private _createRandomTexture;
  56099. /**
  56100. * Serialize the rendering pipeline (Used when exporting)
  56101. * @returns the serialized object
  56102. */
  56103. serialize(): any;
  56104. /**
  56105. * Parse the serialized pipeline
  56106. * @param source Source pipeline.
  56107. * @param scene The scene to load the pipeline to.
  56108. * @param rootUrl The URL of the serialized pipeline.
  56109. * @returns An instantiated pipeline from the serialized object.
  56110. */
  56111. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56112. }
  56113. }
  56114. declare module "babylonjs/Shaders/ssao.fragment" {
  56115. /** @hidden */
  56116. export var ssaoPixelShader: {
  56117. name: string;
  56118. shader: string;
  56119. };
  56120. }
  56121. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  56122. import { Camera } from "babylonjs/Cameras/camera";
  56123. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56124. import { Scene } from "babylonjs/scene";
  56125. import "babylonjs/Shaders/ssao.fragment";
  56126. import "babylonjs/Shaders/ssaoCombine.fragment";
  56127. /**
  56128. * Render pipeline to produce ssao effect
  56129. */
  56130. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56131. /**
  56132. * @ignore
  56133. * The PassPostProcess id in the pipeline that contains the original scene color
  56134. */
  56135. SSAOOriginalSceneColorEffect: string;
  56136. /**
  56137. * @ignore
  56138. * The SSAO PostProcess id in the pipeline
  56139. */
  56140. SSAORenderEffect: string;
  56141. /**
  56142. * @ignore
  56143. * The horizontal blur PostProcess id in the pipeline
  56144. */
  56145. SSAOBlurHRenderEffect: string;
  56146. /**
  56147. * @ignore
  56148. * The vertical blur PostProcess id in the pipeline
  56149. */
  56150. SSAOBlurVRenderEffect: string;
  56151. /**
  56152. * @ignore
  56153. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56154. */
  56155. SSAOCombineRenderEffect: string;
  56156. /**
  56157. * The output strength of the SSAO post-process. Default value is 1.0.
  56158. */
  56159. totalStrength: number;
  56160. /**
  56161. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56162. */
  56163. radius: number;
  56164. /**
  56165. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56166. * Must not be equal to fallOff and superior to fallOff.
  56167. * Default value is 0.0075
  56168. */
  56169. area: number;
  56170. /**
  56171. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56172. * Must not be equal to area and inferior to area.
  56173. * Default value is 0.000001
  56174. */
  56175. fallOff: number;
  56176. /**
  56177. * The base color of the SSAO post-process
  56178. * The final result is "base + ssao" between [0, 1]
  56179. */
  56180. base: number;
  56181. private _scene;
  56182. private _depthTexture;
  56183. private _randomTexture;
  56184. private _originalColorPostProcess;
  56185. private _ssaoPostProcess;
  56186. private _blurHPostProcess;
  56187. private _blurVPostProcess;
  56188. private _ssaoCombinePostProcess;
  56189. private _firstUpdate;
  56190. /**
  56191. * Gets active scene
  56192. */
  56193. readonly scene: Scene;
  56194. /**
  56195. * @constructor
  56196. * @param name - The rendering pipeline name
  56197. * @param scene - The scene linked to this pipeline
  56198. * @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 }
  56199. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56200. */
  56201. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56202. /**
  56203. * Get the class name
  56204. * @returns "SSAORenderingPipeline"
  56205. */
  56206. getClassName(): string;
  56207. /**
  56208. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56209. */
  56210. dispose(disableDepthRender?: boolean): void;
  56211. private _createBlurPostProcess;
  56212. /** @hidden */
  56213. _rebuild(): void;
  56214. private _createSSAOPostProcess;
  56215. private _createSSAOCombinePostProcess;
  56216. private _createRandomTexture;
  56217. }
  56218. }
  56219. declare module "babylonjs/Shaders/standard.fragment" {
  56220. /** @hidden */
  56221. export var standardPixelShader: {
  56222. name: string;
  56223. shader: string;
  56224. };
  56225. }
  56226. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  56227. import { Nullable } from "babylonjs/types";
  56228. import { IAnimatable } from "babylonjs/Misc/tools";
  56229. import { Camera } from "babylonjs/Cameras/camera";
  56230. import { Texture } from "babylonjs/Materials/Textures/texture";
  56231. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56232. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56233. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  56234. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56235. import { IDisposable } from "babylonjs/scene";
  56236. import { SpotLight } from "babylonjs/Lights/spotLight";
  56237. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56238. import { Scene } from "babylonjs/scene";
  56239. import { Animation } from "babylonjs/Animations/animation";
  56240. import "babylonjs/Shaders/standard.fragment";
  56241. /**
  56242. * Standard rendering pipeline
  56243. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56244. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56245. */
  56246. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56247. /**
  56248. * Public members
  56249. */
  56250. /**
  56251. * Post-process which contains the original scene color before the pipeline applies all the effects
  56252. */
  56253. originalPostProcess: Nullable<PostProcess>;
  56254. /**
  56255. * Post-process used to down scale an image x4
  56256. */
  56257. downSampleX4PostProcess: Nullable<PostProcess>;
  56258. /**
  56259. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56260. */
  56261. brightPassPostProcess: Nullable<PostProcess>;
  56262. /**
  56263. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56264. */
  56265. blurHPostProcesses: PostProcess[];
  56266. /**
  56267. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56268. */
  56269. blurVPostProcesses: PostProcess[];
  56270. /**
  56271. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56272. */
  56273. textureAdderPostProcess: Nullable<PostProcess>;
  56274. /**
  56275. * Post-process used to create volumetric lighting effect
  56276. */
  56277. volumetricLightPostProcess: Nullable<PostProcess>;
  56278. /**
  56279. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56280. */
  56281. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56282. /**
  56283. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56284. */
  56285. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56286. /**
  56287. * Post-process used to merge the volumetric light effect and the real scene color
  56288. */
  56289. volumetricLightMergePostProces: Nullable<PostProcess>;
  56290. /**
  56291. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56292. */
  56293. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56294. /**
  56295. * Base post-process used to calculate the average luminance of the final image for HDR
  56296. */
  56297. luminancePostProcess: Nullable<PostProcess>;
  56298. /**
  56299. * Post-processes used to create down sample post-processes in order to get
  56300. * the average luminance of the final image for HDR
  56301. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56302. */
  56303. luminanceDownSamplePostProcesses: PostProcess[];
  56304. /**
  56305. * Post-process used to create a HDR effect (light adaptation)
  56306. */
  56307. hdrPostProcess: Nullable<PostProcess>;
  56308. /**
  56309. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56310. */
  56311. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56312. /**
  56313. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56314. */
  56315. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56316. /**
  56317. * Post-process used to merge the final HDR post-process and the real scene color
  56318. */
  56319. hdrFinalPostProcess: Nullable<PostProcess>;
  56320. /**
  56321. * Post-process used to create a lens flare effect
  56322. */
  56323. lensFlarePostProcess: Nullable<PostProcess>;
  56324. /**
  56325. * Post-process that merges the result of the lens flare post-process and the real scene color
  56326. */
  56327. lensFlareComposePostProcess: Nullable<PostProcess>;
  56328. /**
  56329. * Post-process used to create a motion blur effect
  56330. */
  56331. motionBlurPostProcess: Nullable<PostProcess>;
  56332. /**
  56333. * Post-process used to create a depth of field effect
  56334. */
  56335. depthOfFieldPostProcess: Nullable<PostProcess>;
  56336. /**
  56337. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56338. */
  56339. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56340. /**
  56341. * Represents the brightness threshold in order to configure the illuminated surfaces
  56342. */
  56343. brightThreshold: number;
  56344. /**
  56345. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56346. */
  56347. blurWidth: number;
  56348. /**
  56349. * Sets if the blur for highlighted surfaces must be only horizontal
  56350. */
  56351. horizontalBlur: boolean;
  56352. /**
  56353. * Gets the overall exposure used by the pipeline
  56354. */
  56355. /**
  56356. * Sets the overall exposure used by the pipeline
  56357. */
  56358. exposure: number;
  56359. /**
  56360. * Texture used typically to simulate "dirty" on camera lens
  56361. */
  56362. lensTexture: Nullable<Texture>;
  56363. /**
  56364. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56365. */
  56366. volumetricLightCoefficient: number;
  56367. /**
  56368. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56369. */
  56370. volumetricLightPower: number;
  56371. /**
  56372. * Used the set the blur intensity to smooth the volumetric lights
  56373. */
  56374. volumetricLightBlurScale: number;
  56375. /**
  56376. * Light (spot or directional) used to generate the volumetric lights rays
  56377. * The source light must have a shadow generate so the pipeline can get its
  56378. * depth map
  56379. */
  56380. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56381. /**
  56382. * For eye adaptation, represents the minimum luminance the eye can see
  56383. */
  56384. hdrMinimumLuminance: number;
  56385. /**
  56386. * For eye adaptation, represents the decrease luminance speed
  56387. */
  56388. hdrDecreaseRate: number;
  56389. /**
  56390. * For eye adaptation, represents the increase luminance speed
  56391. */
  56392. hdrIncreaseRate: number;
  56393. /**
  56394. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56395. */
  56396. /**
  56397. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56398. */
  56399. hdrAutoExposure: boolean;
  56400. /**
  56401. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56402. */
  56403. lensColorTexture: Nullable<Texture>;
  56404. /**
  56405. * The overall strengh for the lens flare effect
  56406. */
  56407. lensFlareStrength: number;
  56408. /**
  56409. * Dispersion coefficient for lens flare ghosts
  56410. */
  56411. lensFlareGhostDispersal: number;
  56412. /**
  56413. * Main lens flare halo width
  56414. */
  56415. lensFlareHaloWidth: number;
  56416. /**
  56417. * Based on the lens distortion effect, defines how much the lens flare result
  56418. * is distorted
  56419. */
  56420. lensFlareDistortionStrength: number;
  56421. /**
  56422. * Lens star texture must be used to simulate rays on the flares and is available
  56423. * in the documentation
  56424. */
  56425. lensStarTexture: Nullable<Texture>;
  56426. /**
  56427. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56428. * flare effect by taking account of the dirt texture
  56429. */
  56430. lensFlareDirtTexture: Nullable<Texture>;
  56431. /**
  56432. * Represents the focal length for the depth of field effect
  56433. */
  56434. depthOfFieldDistance: number;
  56435. /**
  56436. * Represents the blur intensity for the blurred part of the depth of field effect
  56437. */
  56438. depthOfFieldBlurWidth: number;
  56439. /**
  56440. * For motion blur, defines how much the image is blurred by the movement
  56441. */
  56442. motionStrength: number;
  56443. /**
  56444. * List of animations for the pipeline (IAnimatable implementation)
  56445. */
  56446. animations: Animation[];
  56447. /**
  56448. * Private members
  56449. */
  56450. private _scene;
  56451. private _currentDepthOfFieldSource;
  56452. private _basePostProcess;
  56453. private _fixedExposure;
  56454. private _currentExposure;
  56455. private _hdrAutoExposure;
  56456. private _hdrCurrentLuminance;
  56457. private _floatTextureType;
  56458. private _ratio;
  56459. private _bloomEnabled;
  56460. private _depthOfFieldEnabled;
  56461. private _vlsEnabled;
  56462. private _lensFlareEnabled;
  56463. private _hdrEnabled;
  56464. private _motionBlurEnabled;
  56465. private _fxaaEnabled;
  56466. private _motionBlurSamples;
  56467. private _volumetricLightStepsCount;
  56468. private _samples;
  56469. /**
  56470. * @ignore
  56471. * Specifies if the bloom pipeline is enabled
  56472. */
  56473. BloomEnabled: boolean;
  56474. /**
  56475. * @ignore
  56476. * Specifies if the depth of field pipeline is enabed
  56477. */
  56478. DepthOfFieldEnabled: boolean;
  56479. /**
  56480. * @ignore
  56481. * Specifies if the lens flare pipeline is enabed
  56482. */
  56483. LensFlareEnabled: boolean;
  56484. /**
  56485. * @ignore
  56486. * Specifies if the HDR pipeline is enabled
  56487. */
  56488. HDREnabled: boolean;
  56489. /**
  56490. * @ignore
  56491. * Specifies if the volumetric lights scattering effect is enabled
  56492. */
  56493. VLSEnabled: boolean;
  56494. /**
  56495. * @ignore
  56496. * Specifies if the motion blur effect is enabled
  56497. */
  56498. MotionBlurEnabled: boolean;
  56499. /**
  56500. * Specifies if anti-aliasing is enabled
  56501. */
  56502. fxaaEnabled: boolean;
  56503. /**
  56504. * Specifies the number of steps used to calculate the volumetric lights
  56505. * Typically in interval [50, 200]
  56506. */
  56507. volumetricLightStepsCount: number;
  56508. /**
  56509. * Specifies the number of samples used for the motion blur effect
  56510. * Typically in interval [16, 64]
  56511. */
  56512. motionBlurSamples: number;
  56513. /**
  56514. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56515. */
  56516. samples: number;
  56517. /**
  56518. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56519. * @constructor
  56520. * @param name The rendering pipeline name
  56521. * @param scene The scene linked to this pipeline
  56522. * @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)
  56523. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  56524. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56525. */
  56526. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  56527. private _buildPipeline;
  56528. private _createDownSampleX4PostProcess;
  56529. private _createBrightPassPostProcess;
  56530. private _createBlurPostProcesses;
  56531. private _createTextureAdderPostProcess;
  56532. private _createVolumetricLightPostProcess;
  56533. private _createLuminancePostProcesses;
  56534. private _createHdrPostProcess;
  56535. private _createLensFlarePostProcess;
  56536. private _createDepthOfFieldPostProcess;
  56537. private _createMotionBlurPostProcess;
  56538. private _getDepthTexture;
  56539. private _disposePostProcesses;
  56540. /**
  56541. * Dispose of the pipeline and stop all post processes
  56542. */
  56543. dispose(): void;
  56544. /**
  56545. * Serialize the rendering pipeline (Used when exporting)
  56546. * @returns the serialized object
  56547. */
  56548. serialize(): any;
  56549. /**
  56550. * Parse the serialized pipeline
  56551. * @param source Source pipeline.
  56552. * @param scene The scene to load the pipeline to.
  56553. * @param rootUrl The URL of the serialized pipeline.
  56554. * @returns An instantiated pipeline from the serialized object.
  56555. */
  56556. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  56557. /**
  56558. * Luminance steps
  56559. */
  56560. static LuminanceSteps: number;
  56561. }
  56562. }
  56563. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  56564. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  56565. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  56566. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  56567. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  56568. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  56569. }
  56570. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  56571. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  56572. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  56573. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56574. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  56575. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  56576. }
  56577. declare module "babylonjs/Shaders/tonemap.fragment" {
  56578. /** @hidden */
  56579. export var tonemapPixelShader: {
  56580. name: string;
  56581. shader: string;
  56582. };
  56583. }
  56584. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  56585. import { Camera } from "babylonjs/Cameras/camera";
  56586. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56587. import "babylonjs/Shaders/tonemap.fragment";
  56588. import { Engine } from "babylonjs/Engines/engine";
  56589. /** Defines operator used for tonemapping */
  56590. export enum TonemappingOperator {
  56591. /** Hable */
  56592. Hable = 0,
  56593. /** Reinhard */
  56594. Reinhard = 1,
  56595. /** HejiDawson */
  56596. HejiDawson = 2,
  56597. /** Photographic */
  56598. Photographic = 3
  56599. }
  56600. /**
  56601. * Defines a post process to apply tone mapping
  56602. */
  56603. export class TonemapPostProcess extends PostProcess {
  56604. private _operator;
  56605. /** Defines the required exposure adjustement */
  56606. exposureAdjustment: number;
  56607. /**
  56608. * Creates a new TonemapPostProcess
  56609. * @param name defines the name of the postprocess
  56610. * @param _operator defines the operator to use
  56611. * @param exposureAdjustment defines the required exposure adjustement
  56612. * @param camera defines the camera to use (can be null)
  56613. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  56614. * @param engine defines the hosting engine (can be ignore if camera is set)
  56615. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56616. */
  56617. constructor(name: string, _operator: TonemappingOperator,
  56618. /** Defines the required exposure adjustement */
  56619. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  56620. }
  56621. }
  56622. declare module "babylonjs/Shaders/depth.vertex" {
  56623. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56624. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56625. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56626. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56627. /** @hidden */
  56628. export var depthVertexShader: {
  56629. name: string;
  56630. shader: string;
  56631. };
  56632. }
  56633. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  56634. /** @hidden */
  56635. export var volumetricLightScatteringPixelShader: {
  56636. name: string;
  56637. shader: string;
  56638. };
  56639. }
  56640. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  56641. /** @hidden */
  56642. export var volumetricLightScatteringPassPixelShader: {
  56643. name: string;
  56644. shader: string;
  56645. };
  56646. }
  56647. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  56648. import { Vector3 } from "babylonjs/Maths/math";
  56649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56650. import { Mesh } from "babylonjs/Meshes/mesh";
  56651. import { Camera } from "babylonjs/Cameras/camera";
  56652. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56653. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56654. import { Scene } from "babylonjs/scene";
  56655. import "babylonjs/Meshes/Builders/planeBuilder";
  56656. import "babylonjs/Shaders/depth.vertex";
  56657. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  56658. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  56659. import { Engine } from "babylonjs/Engines/engine";
  56660. /**
  56661. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  56662. */
  56663. export class VolumetricLightScatteringPostProcess extends PostProcess {
  56664. private _volumetricLightScatteringPass;
  56665. private _volumetricLightScatteringRTT;
  56666. private _viewPort;
  56667. private _screenCoordinates;
  56668. private _cachedDefines;
  56669. /**
  56670. * If not undefined, the mesh position is computed from the attached node position
  56671. */
  56672. attachedNode: {
  56673. position: Vector3;
  56674. };
  56675. /**
  56676. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  56677. */
  56678. customMeshPosition: Vector3;
  56679. /**
  56680. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  56681. */
  56682. useCustomMeshPosition: boolean;
  56683. /**
  56684. * If the post-process should inverse the light scattering direction
  56685. */
  56686. invert: boolean;
  56687. /**
  56688. * The internal mesh used by the post-process
  56689. */
  56690. mesh: Mesh;
  56691. /**
  56692. * @hidden
  56693. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  56694. */
  56695. useDiffuseColor: boolean;
  56696. /**
  56697. * Array containing the excluded meshes not rendered in the internal pass
  56698. */
  56699. excludedMeshes: AbstractMesh[];
  56700. /**
  56701. * Controls the overall intensity of the post-process
  56702. */
  56703. exposure: number;
  56704. /**
  56705. * Dissipates each sample's contribution in range [0, 1]
  56706. */
  56707. decay: number;
  56708. /**
  56709. * Controls the overall intensity of each sample
  56710. */
  56711. weight: number;
  56712. /**
  56713. * Controls the density of each sample
  56714. */
  56715. density: number;
  56716. /**
  56717. * @constructor
  56718. * @param name The post-process name
  56719. * @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)
  56720. * @param camera The camera that the post-process will be attached to
  56721. * @param mesh The mesh used to create the light scattering
  56722. * @param samples The post-process quality, default 100
  56723. * @param samplingModeThe post-process filtering mode
  56724. * @param engine The babylon engine
  56725. * @param reusable If the post-process is reusable
  56726. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  56727. */
  56728. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  56729. /**
  56730. * Returns the string "VolumetricLightScatteringPostProcess"
  56731. * @returns "VolumetricLightScatteringPostProcess"
  56732. */
  56733. getClassName(): string;
  56734. private _isReady;
  56735. /**
  56736. * Sets the new light position for light scattering effect
  56737. * @param position The new custom light position
  56738. */
  56739. setCustomMeshPosition(position: Vector3): void;
  56740. /**
  56741. * Returns the light position for light scattering effect
  56742. * @return Vector3 The custom light position
  56743. */
  56744. getCustomMeshPosition(): Vector3;
  56745. /**
  56746. * Disposes the internal assets and detaches the post-process from the camera
  56747. */
  56748. dispose(camera: Camera): void;
  56749. /**
  56750. * Returns the render target texture used by the post-process
  56751. * @return the render target texture used by the post-process
  56752. */
  56753. getPass(): RenderTargetTexture;
  56754. private _meshExcluded;
  56755. private _createPass;
  56756. private _updateMeshScreenCoordinates;
  56757. /**
  56758. * Creates a default mesh for the Volumeric Light Scattering post-process
  56759. * @param name The mesh name
  56760. * @param scene The scene where to create the mesh
  56761. * @return the default mesh
  56762. */
  56763. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  56764. }
  56765. }
  56766. declare module "babylonjs/PostProcesses/index" {
  56767. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  56768. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  56769. export * from "babylonjs/PostProcesses/bloomEffect";
  56770. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  56771. export * from "babylonjs/PostProcesses/blurPostProcess";
  56772. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  56773. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  56774. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  56775. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  56776. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  56777. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  56778. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  56779. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  56780. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  56781. export * from "babylonjs/PostProcesses/filterPostProcess";
  56782. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  56783. export * from "babylonjs/PostProcesses/grainPostProcess";
  56784. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  56785. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  56786. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  56787. export * from "babylonjs/PostProcesses/passPostProcess";
  56788. export * from "babylonjs/PostProcesses/postProcess";
  56789. export * from "babylonjs/PostProcesses/postProcessManager";
  56790. export * from "babylonjs/PostProcesses/refractionPostProcess";
  56791. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  56792. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  56793. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  56794. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  56795. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  56796. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  56797. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  56798. }
  56799. declare module "babylonjs/Probes/index" {
  56800. export * from "babylonjs/Probes/reflectionProbe";
  56801. }
  56802. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  56803. import { Scene } from "babylonjs/scene";
  56804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56805. import { Color3 } from "babylonjs/Maths/math";
  56806. import { SmartArray } from "babylonjs/Misc/smartArray";
  56807. import { ISceneComponent } from "babylonjs/sceneComponent";
  56808. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  56809. import "babylonjs/Meshes/Builders/boxBuilder";
  56810. import "babylonjs/Shaders/color.fragment";
  56811. import "babylonjs/Shaders/color.vertex";
  56812. module "babylonjs/scene" {
  56813. interface Scene {
  56814. /** @hidden (Backing field) */
  56815. _boundingBoxRenderer: BoundingBoxRenderer;
  56816. /** @hidden (Backing field) */
  56817. _forceShowBoundingBoxes: boolean;
  56818. /**
  56819. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  56820. */
  56821. forceShowBoundingBoxes: boolean;
  56822. /**
  56823. * Gets the bounding box renderer associated with the scene
  56824. * @returns a BoundingBoxRenderer
  56825. */
  56826. getBoundingBoxRenderer(): BoundingBoxRenderer;
  56827. }
  56828. }
  56829. module "babylonjs/Meshes/abstractMesh" {
  56830. interface AbstractMesh {
  56831. /** @hidden (Backing field) */
  56832. _showBoundingBox: boolean;
  56833. /**
  56834. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  56835. */
  56836. showBoundingBox: boolean;
  56837. }
  56838. }
  56839. /**
  56840. * Component responsible of rendering the bounding box of the meshes in a scene.
  56841. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  56842. */
  56843. export class BoundingBoxRenderer implements ISceneComponent {
  56844. /**
  56845. * The component name helpfull to identify the component in the list of scene components.
  56846. */
  56847. readonly name: string;
  56848. /**
  56849. * The scene the component belongs to.
  56850. */
  56851. scene: Scene;
  56852. /**
  56853. * Color of the bounding box lines placed in front of an object
  56854. */
  56855. frontColor: Color3;
  56856. /**
  56857. * Color of the bounding box lines placed behind an object
  56858. */
  56859. backColor: Color3;
  56860. /**
  56861. * Defines if the renderer should show the back lines or not
  56862. */
  56863. showBackLines: boolean;
  56864. /**
  56865. * @hidden
  56866. */
  56867. renderList: SmartArray<BoundingBox>;
  56868. private _colorShader;
  56869. private _vertexBuffers;
  56870. private _indexBuffer;
  56871. /**
  56872. * Instantiates a new bounding box renderer in a scene.
  56873. * @param scene the scene the renderer renders in
  56874. */
  56875. constructor(scene: Scene);
  56876. /**
  56877. * Registers the component in a given scene
  56878. */
  56879. register(): void;
  56880. private _evaluateSubMesh;
  56881. private _activeMesh;
  56882. private _prepareRessources;
  56883. private _createIndexBuffer;
  56884. /**
  56885. * Rebuilds the elements related to this component in case of
  56886. * context lost for instance.
  56887. */
  56888. rebuild(): void;
  56889. /**
  56890. * @hidden
  56891. */
  56892. reset(): void;
  56893. /**
  56894. * Render the bounding boxes of a specific rendering group
  56895. * @param renderingGroupId defines the rendering group to render
  56896. */
  56897. render(renderingGroupId: number): void;
  56898. /**
  56899. * In case of occlusion queries, we can render the occlusion bounding box through this method
  56900. * @param mesh Define the mesh to render the occlusion bounding box for
  56901. */
  56902. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  56903. /**
  56904. * Dispose and release the resources attached to this renderer.
  56905. */
  56906. dispose(): void;
  56907. }
  56908. }
  56909. declare module "babylonjs/Shaders/depth.fragment" {
  56910. /** @hidden */
  56911. export var depthPixelShader: {
  56912. name: string;
  56913. shader: string;
  56914. };
  56915. }
  56916. declare module "babylonjs/Rendering/depthRenderer" {
  56917. import { Nullable } from "babylonjs/types";
  56918. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56919. import { Scene } from "babylonjs/scene";
  56920. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56921. import { Camera } from "babylonjs/Cameras/camera";
  56922. import "babylonjs/Shaders/depth.fragment";
  56923. import "babylonjs/Shaders/depth.vertex";
  56924. /**
  56925. * This represents a depth renderer in Babylon.
  56926. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56927. */
  56928. export class DepthRenderer {
  56929. private _scene;
  56930. private _depthMap;
  56931. private _effect;
  56932. private _cachedDefines;
  56933. private _camera;
  56934. /**
  56935. * Specifiess that the depth renderer will only be used within
  56936. * the camera it is created for.
  56937. * This can help forcing its rendering during the camera processing.
  56938. */
  56939. useOnlyInActiveCamera: boolean;
  56940. /** @hidden */
  56941. static _SceneComponentInitialization: (scene: Scene) => void;
  56942. /**
  56943. * Instantiates a depth renderer
  56944. * @param scene The scene the renderer belongs to
  56945. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56946. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56947. */
  56948. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  56949. /**
  56950. * Creates the depth rendering effect and checks if the effect is ready.
  56951. * @param subMesh The submesh to be used to render the depth map of
  56952. * @param useInstances If multiple world instances should be used
  56953. * @returns if the depth renderer is ready to render the depth map
  56954. */
  56955. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56956. /**
  56957. * Gets the texture which the depth map will be written to.
  56958. * @returns The depth map texture
  56959. */
  56960. getDepthMap(): RenderTargetTexture;
  56961. /**
  56962. * Disposes of the depth renderer.
  56963. */
  56964. dispose(): void;
  56965. }
  56966. }
  56967. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  56968. import { Nullable } from "babylonjs/types";
  56969. import { Scene } from "babylonjs/scene";
  56970. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56971. import { Camera } from "babylonjs/Cameras/camera";
  56972. import { ISceneComponent } from "babylonjs/sceneComponent";
  56973. module "babylonjs/scene" {
  56974. interface Scene {
  56975. /** @hidden (Backing field) */
  56976. _depthRenderer: {
  56977. [id: string]: DepthRenderer;
  56978. };
  56979. /**
  56980. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  56981. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  56982. * @returns the created depth renderer
  56983. */
  56984. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  56985. /**
  56986. * Disables a depth renderer for a given camera
  56987. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  56988. */
  56989. disableDepthRenderer(camera?: Nullable<Camera>): void;
  56990. }
  56991. }
  56992. /**
  56993. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  56994. * in several rendering techniques.
  56995. */
  56996. export class DepthRendererSceneComponent implements ISceneComponent {
  56997. /**
  56998. * The component name helpfull to identify the component in the list of scene components.
  56999. */
  57000. readonly name: string;
  57001. /**
  57002. * The scene the component belongs to.
  57003. */
  57004. scene: Scene;
  57005. /**
  57006. * Creates a new instance of the component for the given scene
  57007. * @param scene Defines the scene to register the component in
  57008. */
  57009. constructor(scene: Scene);
  57010. /**
  57011. * Registers the component in a given scene
  57012. */
  57013. register(): void;
  57014. /**
  57015. * Rebuilds the elements related to this component in case of
  57016. * context lost for instance.
  57017. */
  57018. rebuild(): void;
  57019. /**
  57020. * Disposes the component and the associated ressources
  57021. */
  57022. dispose(): void;
  57023. private _gatherRenderTargets;
  57024. private _gatherActiveCameraRenderTargets;
  57025. }
  57026. }
  57027. declare module "babylonjs/Shaders/outline.fragment" {
  57028. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57029. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57030. /** @hidden */
  57031. export var outlinePixelShader: {
  57032. name: string;
  57033. shader: string;
  57034. };
  57035. }
  57036. declare module "babylonjs/Shaders/outline.vertex" {
  57037. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57038. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57039. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57040. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57041. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57042. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57043. /** @hidden */
  57044. export var outlineVertexShader: {
  57045. name: string;
  57046. shader: string;
  57047. };
  57048. }
  57049. declare module "babylonjs/Rendering/outlineRenderer" {
  57050. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57051. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  57052. import { Scene } from "babylonjs/scene";
  57053. import { ISceneComponent } from "babylonjs/sceneComponent";
  57054. import "babylonjs/Shaders/outline.fragment";
  57055. import "babylonjs/Shaders/outline.vertex";
  57056. module "babylonjs/scene" {
  57057. interface Scene {
  57058. /** @hidden */
  57059. _outlineRenderer: OutlineRenderer;
  57060. /**
  57061. * Gets the outline renderer associated with the scene
  57062. * @returns a OutlineRenderer
  57063. */
  57064. getOutlineRenderer(): OutlineRenderer;
  57065. }
  57066. }
  57067. module "babylonjs/Meshes/abstractMesh" {
  57068. interface AbstractMesh {
  57069. /** @hidden (Backing field) */
  57070. _renderOutline: boolean;
  57071. /**
  57072. * Gets or sets a boolean indicating if the outline must be rendered as well
  57073. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57074. */
  57075. renderOutline: boolean;
  57076. /** @hidden (Backing field) */
  57077. _renderOverlay: boolean;
  57078. /**
  57079. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57080. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57081. */
  57082. renderOverlay: boolean;
  57083. }
  57084. }
  57085. /**
  57086. * This class is responsible to draw bothe outline/overlay of meshes.
  57087. * It should not be used directly but through the available method on mesh.
  57088. */
  57089. export class OutlineRenderer implements ISceneComponent {
  57090. /**
  57091. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57092. */
  57093. private static _StencilReference;
  57094. /**
  57095. * The name of the component. Each component must have a unique name.
  57096. */
  57097. name: string;
  57098. /**
  57099. * The scene the component belongs to.
  57100. */
  57101. scene: Scene;
  57102. /**
  57103. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57104. */
  57105. zOffset: number;
  57106. private _engine;
  57107. private _effect;
  57108. private _cachedDefines;
  57109. private _savedDepthWrite;
  57110. /**
  57111. * Instantiates a new outline renderer. (There could be only one per scene).
  57112. * @param scene Defines the scene it belongs to
  57113. */
  57114. constructor(scene: Scene);
  57115. /**
  57116. * Register the component to one instance of a scene.
  57117. */
  57118. register(): void;
  57119. /**
  57120. * Rebuilds the elements related to this component in case of
  57121. * context lost for instance.
  57122. */
  57123. rebuild(): void;
  57124. /**
  57125. * Disposes the component and the associated ressources.
  57126. */
  57127. dispose(): void;
  57128. /**
  57129. * Renders the outline in the canvas.
  57130. * @param subMesh Defines the sumesh to render
  57131. * @param batch Defines the batch of meshes in case of instances
  57132. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57133. */
  57134. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57135. /**
  57136. * Returns whether or not the outline renderer is ready for a given submesh.
  57137. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57138. * @param subMesh Defines the submesh to check readyness for
  57139. * @param useInstances Defines wheter wee are trying to render instances or not
  57140. * @returns true if ready otherwise false
  57141. */
  57142. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57143. private _beforeRenderingMesh;
  57144. private _afterRenderingMesh;
  57145. }
  57146. }
  57147. declare module "babylonjs/Rendering/index" {
  57148. export * from "babylonjs/Rendering/boundingBoxRenderer";
  57149. export * from "babylonjs/Rendering/depthRenderer";
  57150. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  57151. export * from "babylonjs/Rendering/edgesRenderer";
  57152. export * from "babylonjs/Rendering/geometryBufferRenderer";
  57153. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  57154. export * from "babylonjs/Rendering/outlineRenderer";
  57155. export * from "babylonjs/Rendering/renderingGroup";
  57156. export * from "babylonjs/Rendering/renderingManager";
  57157. export * from "babylonjs/Rendering/utilityLayerRenderer";
  57158. }
  57159. declare module "babylonjs/Sprites/index" {
  57160. export * from "babylonjs/Sprites/sprite";
  57161. export * from "babylonjs/Sprites/spriteManager";
  57162. export * from "babylonjs/Sprites/spriteSceneComponent";
  57163. }
  57164. declare module "babylonjs/Misc/assetsManager" {
  57165. import { Scene } from "babylonjs/scene";
  57166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57167. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57168. import { Skeleton } from "babylonjs/Bones/skeleton";
  57169. import { Observable } from "babylonjs/Misc/observable";
  57170. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57171. import { Texture } from "babylonjs/Materials/Textures/texture";
  57172. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57173. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  57174. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57175. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  57176. /**
  57177. * Defines the list of states available for a task inside a AssetsManager
  57178. */
  57179. export enum AssetTaskState {
  57180. /**
  57181. * Initialization
  57182. */
  57183. INIT = 0,
  57184. /**
  57185. * Running
  57186. */
  57187. RUNNING = 1,
  57188. /**
  57189. * Done
  57190. */
  57191. DONE = 2,
  57192. /**
  57193. * Error
  57194. */
  57195. ERROR = 3
  57196. }
  57197. /**
  57198. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57199. */
  57200. export abstract class AbstractAssetTask {
  57201. /**
  57202. * Task name
  57203. */ name: string;
  57204. /**
  57205. * Callback called when the task is successful
  57206. */
  57207. onSuccess: (task: any) => void;
  57208. /**
  57209. * Callback called when the task is not successful
  57210. */
  57211. onError: (task: any, message?: string, exception?: any) => void;
  57212. /**
  57213. * Creates a new AssetsManager
  57214. * @param name defines the name of the task
  57215. */
  57216. constructor(
  57217. /**
  57218. * Task name
  57219. */ name: string);
  57220. private _isCompleted;
  57221. private _taskState;
  57222. private _errorObject;
  57223. /**
  57224. * Get if the task is completed
  57225. */
  57226. readonly isCompleted: boolean;
  57227. /**
  57228. * Gets the current state of the task
  57229. */
  57230. readonly taskState: AssetTaskState;
  57231. /**
  57232. * Gets the current error object (if task is in error)
  57233. */
  57234. readonly errorObject: {
  57235. message?: string;
  57236. exception?: any;
  57237. };
  57238. /**
  57239. * Internal only
  57240. * @hidden
  57241. */
  57242. _setErrorObject(message?: string, exception?: any): void;
  57243. /**
  57244. * Execute the current task
  57245. * @param scene defines the scene where you want your assets to be loaded
  57246. * @param onSuccess is a callback called when the task is successfully executed
  57247. * @param onError is a callback called if an error occurs
  57248. */
  57249. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57250. /**
  57251. * Execute the current task
  57252. * @param scene defines the scene where you want your assets to be loaded
  57253. * @param onSuccess is a callback called when the task is successfully executed
  57254. * @param onError is a callback called if an error occurs
  57255. */
  57256. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57257. /**
  57258. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57259. * This can be used with failed tasks that have the reason for failure fixed.
  57260. */
  57261. reset(): void;
  57262. private onErrorCallback;
  57263. private onDoneCallback;
  57264. }
  57265. /**
  57266. * Define the interface used by progress events raised during assets loading
  57267. */
  57268. export interface IAssetsProgressEvent {
  57269. /**
  57270. * Defines the number of remaining tasks to process
  57271. */
  57272. remainingCount: number;
  57273. /**
  57274. * Defines the total number of tasks
  57275. */
  57276. totalCount: number;
  57277. /**
  57278. * Defines the task that was just processed
  57279. */
  57280. task: AbstractAssetTask;
  57281. }
  57282. /**
  57283. * Class used to share progress information about assets loading
  57284. */
  57285. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57286. /**
  57287. * Defines the number of remaining tasks to process
  57288. */
  57289. remainingCount: number;
  57290. /**
  57291. * Defines the total number of tasks
  57292. */
  57293. totalCount: number;
  57294. /**
  57295. * Defines the task that was just processed
  57296. */
  57297. task: AbstractAssetTask;
  57298. /**
  57299. * Creates a AssetsProgressEvent
  57300. * @param remainingCount defines the number of remaining tasks to process
  57301. * @param totalCount defines the total number of tasks
  57302. * @param task defines the task that was just processed
  57303. */
  57304. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57305. }
  57306. /**
  57307. * Define a task used by AssetsManager to load meshes
  57308. */
  57309. export class MeshAssetTask extends AbstractAssetTask {
  57310. /**
  57311. * Defines the name of the task
  57312. */
  57313. name: string;
  57314. /**
  57315. * Defines the list of mesh's names you want to load
  57316. */
  57317. meshesNames: any;
  57318. /**
  57319. * Defines the root url to use as a base to load your meshes and associated resources
  57320. */
  57321. rootUrl: string;
  57322. /**
  57323. * Defines the filename of the scene to load from
  57324. */
  57325. sceneFilename: string;
  57326. /**
  57327. * Gets the list of loaded meshes
  57328. */
  57329. loadedMeshes: Array<AbstractMesh>;
  57330. /**
  57331. * Gets the list of loaded particle systems
  57332. */
  57333. loadedParticleSystems: Array<IParticleSystem>;
  57334. /**
  57335. * Gets the list of loaded skeletons
  57336. */
  57337. loadedSkeletons: Array<Skeleton>;
  57338. /**
  57339. * Gets the list of loaded animation groups
  57340. */
  57341. loadedAnimationGroups: Array<AnimationGroup>;
  57342. /**
  57343. * Callback called when the task is successful
  57344. */
  57345. onSuccess: (task: MeshAssetTask) => void;
  57346. /**
  57347. * Callback called when the task is successful
  57348. */
  57349. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57350. /**
  57351. * Creates a new MeshAssetTask
  57352. * @param name defines the name of the task
  57353. * @param meshesNames defines the list of mesh's names you want to load
  57354. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57355. * @param sceneFilename defines the filename of the scene to load from
  57356. */
  57357. constructor(
  57358. /**
  57359. * Defines the name of the task
  57360. */
  57361. name: string,
  57362. /**
  57363. * Defines the list of mesh's names you want to load
  57364. */
  57365. meshesNames: any,
  57366. /**
  57367. * Defines the root url to use as a base to load your meshes and associated resources
  57368. */
  57369. rootUrl: string,
  57370. /**
  57371. * Defines the filename of the scene to load from
  57372. */
  57373. sceneFilename: string);
  57374. /**
  57375. * Execute the current task
  57376. * @param scene defines the scene where you want your assets to be loaded
  57377. * @param onSuccess is a callback called when the task is successfully executed
  57378. * @param onError is a callback called if an error occurs
  57379. */
  57380. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57381. }
  57382. /**
  57383. * Define a task used by AssetsManager to load text content
  57384. */
  57385. export class TextFileAssetTask extends AbstractAssetTask {
  57386. /**
  57387. * Defines the name of the task
  57388. */
  57389. name: string;
  57390. /**
  57391. * Defines the location of the file to load
  57392. */
  57393. url: string;
  57394. /**
  57395. * Gets the loaded text string
  57396. */
  57397. text: string;
  57398. /**
  57399. * Callback called when the task is successful
  57400. */
  57401. onSuccess: (task: TextFileAssetTask) => void;
  57402. /**
  57403. * Callback called when the task is successful
  57404. */
  57405. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57406. /**
  57407. * Creates a new TextFileAssetTask object
  57408. * @param name defines the name of the task
  57409. * @param url defines the location of the file to load
  57410. */
  57411. constructor(
  57412. /**
  57413. * Defines the name of the task
  57414. */
  57415. name: string,
  57416. /**
  57417. * Defines the location of the file to load
  57418. */
  57419. url: string);
  57420. /**
  57421. * Execute the current task
  57422. * @param scene defines the scene where you want your assets to be loaded
  57423. * @param onSuccess is a callback called when the task is successfully executed
  57424. * @param onError is a callback called if an error occurs
  57425. */
  57426. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57427. }
  57428. /**
  57429. * Define a task used by AssetsManager to load binary data
  57430. */
  57431. export class BinaryFileAssetTask extends AbstractAssetTask {
  57432. /**
  57433. * Defines the name of the task
  57434. */
  57435. name: string;
  57436. /**
  57437. * Defines the location of the file to load
  57438. */
  57439. url: string;
  57440. /**
  57441. * Gets the lodaded data (as an array buffer)
  57442. */
  57443. data: ArrayBuffer;
  57444. /**
  57445. * Callback called when the task is successful
  57446. */
  57447. onSuccess: (task: BinaryFileAssetTask) => void;
  57448. /**
  57449. * Callback called when the task is successful
  57450. */
  57451. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  57452. /**
  57453. * Creates a new BinaryFileAssetTask object
  57454. * @param name defines the name of the new task
  57455. * @param url defines the location of the file to load
  57456. */
  57457. constructor(
  57458. /**
  57459. * Defines the name of the task
  57460. */
  57461. name: string,
  57462. /**
  57463. * Defines the location of the file to load
  57464. */
  57465. url: string);
  57466. /**
  57467. * Execute the current task
  57468. * @param scene defines the scene where you want your assets to be loaded
  57469. * @param onSuccess is a callback called when the task is successfully executed
  57470. * @param onError is a callback called if an error occurs
  57471. */
  57472. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57473. }
  57474. /**
  57475. * Define a task used by AssetsManager to load images
  57476. */
  57477. export class ImageAssetTask extends AbstractAssetTask {
  57478. /**
  57479. * Defines the name of the task
  57480. */
  57481. name: string;
  57482. /**
  57483. * Defines the location of the image to load
  57484. */
  57485. url: string;
  57486. /**
  57487. * Gets the loaded images
  57488. */
  57489. image: HTMLImageElement;
  57490. /**
  57491. * Callback called when the task is successful
  57492. */
  57493. onSuccess: (task: ImageAssetTask) => void;
  57494. /**
  57495. * Callback called when the task is successful
  57496. */
  57497. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  57498. /**
  57499. * Creates a new ImageAssetTask
  57500. * @param name defines the name of the task
  57501. * @param url defines the location of the image to load
  57502. */
  57503. constructor(
  57504. /**
  57505. * Defines the name of the task
  57506. */
  57507. name: string,
  57508. /**
  57509. * Defines the location of the image to load
  57510. */
  57511. url: string);
  57512. /**
  57513. * Execute the current task
  57514. * @param scene defines the scene where you want your assets to be loaded
  57515. * @param onSuccess is a callback called when the task is successfully executed
  57516. * @param onError is a callback called if an error occurs
  57517. */
  57518. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57519. }
  57520. /**
  57521. * Defines the interface used by texture loading tasks
  57522. */
  57523. export interface ITextureAssetTask<TEX extends BaseTexture> {
  57524. /**
  57525. * Gets the loaded texture
  57526. */
  57527. texture: TEX;
  57528. }
  57529. /**
  57530. * Define a task used by AssetsManager to load 2D textures
  57531. */
  57532. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  57533. /**
  57534. * Defines the name of the task
  57535. */
  57536. name: string;
  57537. /**
  57538. * Defines the location of the file to load
  57539. */
  57540. url: string;
  57541. /**
  57542. * Defines if mipmap should not be generated (default is false)
  57543. */
  57544. noMipmap?: boolean | undefined;
  57545. /**
  57546. * Defines if texture must be inverted on Y axis (default is false)
  57547. */
  57548. invertY?: boolean | undefined;
  57549. /**
  57550. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57551. */
  57552. samplingMode: number;
  57553. /**
  57554. * Gets the loaded texture
  57555. */
  57556. texture: Texture;
  57557. /**
  57558. * Callback called when the task is successful
  57559. */
  57560. onSuccess: (task: TextureAssetTask) => void;
  57561. /**
  57562. * Callback called when the task is successful
  57563. */
  57564. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  57565. /**
  57566. * Creates a new TextureAssetTask object
  57567. * @param name defines the name of the task
  57568. * @param url defines the location of the file to load
  57569. * @param noMipmap defines if mipmap should not be generated (default is false)
  57570. * @param invertY defines if texture must be inverted on Y axis (default is false)
  57571. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57572. */
  57573. constructor(
  57574. /**
  57575. * Defines the name of the task
  57576. */
  57577. name: string,
  57578. /**
  57579. * Defines the location of the file to load
  57580. */
  57581. url: string,
  57582. /**
  57583. * Defines if mipmap should not be generated (default is false)
  57584. */
  57585. noMipmap?: boolean | undefined,
  57586. /**
  57587. * Defines if texture must be inverted on Y axis (default is false)
  57588. */
  57589. invertY?: boolean | undefined,
  57590. /**
  57591. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57592. */
  57593. samplingMode?: number);
  57594. /**
  57595. * Execute the current task
  57596. * @param scene defines the scene where you want your assets to be loaded
  57597. * @param onSuccess is a callback called when the task is successfully executed
  57598. * @param onError is a callback called if an error occurs
  57599. */
  57600. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57601. }
  57602. /**
  57603. * Define a task used by AssetsManager to load cube textures
  57604. */
  57605. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  57606. /**
  57607. * Defines the name of the task
  57608. */
  57609. name: string;
  57610. /**
  57611. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57612. */
  57613. url: string;
  57614. /**
  57615. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57616. */
  57617. extensions?: string[] | undefined;
  57618. /**
  57619. * Defines if mipmaps should not be generated (default is false)
  57620. */
  57621. noMipmap?: boolean | undefined;
  57622. /**
  57623. * Defines the explicit list of files (undefined by default)
  57624. */
  57625. files?: string[] | undefined;
  57626. /**
  57627. * Gets the loaded texture
  57628. */
  57629. texture: CubeTexture;
  57630. /**
  57631. * Callback called when the task is successful
  57632. */
  57633. onSuccess: (task: CubeTextureAssetTask) => void;
  57634. /**
  57635. * Callback called when the task is successful
  57636. */
  57637. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  57638. /**
  57639. * Creates a new CubeTextureAssetTask
  57640. * @param name defines the name of the task
  57641. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57642. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57643. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57644. * @param files defines the explicit list of files (undefined by default)
  57645. */
  57646. constructor(
  57647. /**
  57648. * Defines the name of the task
  57649. */
  57650. name: string,
  57651. /**
  57652. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57653. */
  57654. url: string,
  57655. /**
  57656. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57657. */
  57658. extensions?: string[] | undefined,
  57659. /**
  57660. * Defines if mipmaps should not be generated (default is false)
  57661. */
  57662. noMipmap?: boolean | undefined,
  57663. /**
  57664. * Defines the explicit list of files (undefined by default)
  57665. */
  57666. files?: string[] | undefined);
  57667. /**
  57668. * Execute the current task
  57669. * @param scene defines the scene where you want your assets to be loaded
  57670. * @param onSuccess is a callback called when the task is successfully executed
  57671. * @param onError is a callback called if an error occurs
  57672. */
  57673. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57674. }
  57675. /**
  57676. * Define a task used by AssetsManager to load HDR cube textures
  57677. */
  57678. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  57679. /**
  57680. * Defines the name of the task
  57681. */
  57682. name: string;
  57683. /**
  57684. * Defines the location of the file to load
  57685. */
  57686. url: string;
  57687. /**
  57688. * Defines the desired size (the more it increases the longer the generation will be)
  57689. */
  57690. size: number;
  57691. /**
  57692. * Defines if mipmaps should not be generated (default is false)
  57693. */
  57694. noMipmap: boolean;
  57695. /**
  57696. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57697. */
  57698. generateHarmonics: boolean;
  57699. /**
  57700. * 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)
  57701. */
  57702. gammaSpace: boolean;
  57703. /**
  57704. * Internal Use Only
  57705. */
  57706. reserved: boolean;
  57707. /**
  57708. * Gets the loaded texture
  57709. */
  57710. texture: HDRCubeTexture;
  57711. /**
  57712. * Callback called when the task is successful
  57713. */
  57714. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  57715. /**
  57716. * Callback called when the task is successful
  57717. */
  57718. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  57719. /**
  57720. * Creates a new HDRCubeTextureAssetTask object
  57721. * @param name defines the name of the task
  57722. * @param url defines the location of the file to load
  57723. * @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.
  57724. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57725. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57726. * @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)
  57727. * @param reserved Internal use only
  57728. */
  57729. constructor(
  57730. /**
  57731. * Defines the name of the task
  57732. */
  57733. name: string,
  57734. /**
  57735. * Defines the location of the file to load
  57736. */
  57737. url: string,
  57738. /**
  57739. * Defines the desired size (the more it increases the longer the generation will be)
  57740. */
  57741. size: number,
  57742. /**
  57743. * Defines if mipmaps should not be generated (default is false)
  57744. */
  57745. noMipmap?: boolean,
  57746. /**
  57747. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57748. */
  57749. generateHarmonics?: boolean,
  57750. /**
  57751. * 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)
  57752. */
  57753. gammaSpace?: boolean,
  57754. /**
  57755. * Internal Use Only
  57756. */
  57757. reserved?: boolean);
  57758. /**
  57759. * Execute the current task
  57760. * @param scene defines the scene where you want your assets to be loaded
  57761. * @param onSuccess is a callback called when the task is successfully executed
  57762. * @param onError is a callback called if an error occurs
  57763. */
  57764. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57765. }
  57766. /**
  57767. * Define a task used by AssetsManager to load Equirectangular cube textures
  57768. */
  57769. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  57770. /**
  57771. * Defines the name of the task
  57772. */
  57773. name: string;
  57774. /**
  57775. * Defines the location of the file to load
  57776. */
  57777. url: string;
  57778. /**
  57779. * Defines the desired size (the more it increases the longer the generation will be)
  57780. */
  57781. size: number;
  57782. /**
  57783. * Defines if mipmaps should not be generated (default is false)
  57784. */
  57785. noMipmap: boolean;
  57786. /**
  57787. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57788. * but the standard material would require them in Gamma space) (default is true)
  57789. */
  57790. gammaSpace: boolean;
  57791. /**
  57792. * Gets the loaded texture
  57793. */
  57794. texture: EquiRectangularCubeTexture;
  57795. /**
  57796. * Callback called when the task is successful
  57797. */
  57798. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  57799. /**
  57800. * Callback called when the task is successful
  57801. */
  57802. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  57803. /**
  57804. * Creates a new EquiRectangularCubeTextureAssetTask object
  57805. * @param name defines the name of the task
  57806. * @param url defines the location of the file to load
  57807. * @param size defines the desired size (the more it increases the longer the generation will be)
  57808. * If the size is omitted this implies you are using a preprocessed cubemap.
  57809. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57810. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  57811. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  57812. * (default is true)
  57813. */
  57814. constructor(
  57815. /**
  57816. * Defines the name of the task
  57817. */
  57818. name: string,
  57819. /**
  57820. * Defines the location of the file to load
  57821. */
  57822. url: string,
  57823. /**
  57824. * Defines the desired size (the more it increases the longer the generation will be)
  57825. */
  57826. size: number,
  57827. /**
  57828. * Defines if mipmaps should not be generated (default is false)
  57829. */
  57830. noMipmap?: boolean,
  57831. /**
  57832. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57833. * but the standard material would require them in Gamma space) (default is true)
  57834. */
  57835. gammaSpace?: boolean);
  57836. /**
  57837. * Execute the current task
  57838. * @param scene defines the scene where you want your assets to be loaded
  57839. * @param onSuccess is a callback called when the task is successfully executed
  57840. * @param onError is a callback called if an error occurs
  57841. */
  57842. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57843. }
  57844. /**
  57845. * This class can be used to easily import assets into a scene
  57846. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  57847. */
  57848. export class AssetsManager {
  57849. private _scene;
  57850. private _isLoading;
  57851. protected _tasks: AbstractAssetTask[];
  57852. protected _waitingTasksCount: number;
  57853. protected _totalTasksCount: number;
  57854. /**
  57855. * Callback called when all tasks are processed
  57856. */
  57857. onFinish: (tasks: AbstractAssetTask[]) => void;
  57858. /**
  57859. * Callback called when a task is successful
  57860. */
  57861. onTaskSuccess: (task: AbstractAssetTask) => void;
  57862. /**
  57863. * Callback called when a task had an error
  57864. */
  57865. onTaskError: (task: AbstractAssetTask) => void;
  57866. /**
  57867. * Callback called when a task is done (whatever the result is)
  57868. */
  57869. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  57870. /**
  57871. * Observable called when all tasks are processed
  57872. */
  57873. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  57874. /**
  57875. * Observable called when a task had an error
  57876. */
  57877. onTaskErrorObservable: Observable<AbstractAssetTask>;
  57878. /**
  57879. * Observable called when all tasks were executed
  57880. */
  57881. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  57882. /**
  57883. * Observable called when a task is done (whatever the result is)
  57884. */
  57885. onProgressObservable: Observable<IAssetsProgressEvent>;
  57886. /**
  57887. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  57888. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  57889. */
  57890. useDefaultLoadingScreen: boolean;
  57891. /**
  57892. * Creates a new AssetsManager
  57893. * @param scene defines the scene to work on
  57894. */
  57895. constructor(scene: Scene);
  57896. /**
  57897. * Add a MeshAssetTask to the list of active tasks
  57898. * @param taskName defines the name of the new task
  57899. * @param meshesNames defines the name of meshes to load
  57900. * @param rootUrl defines the root url to use to locate files
  57901. * @param sceneFilename defines the filename of the scene file
  57902. * @returns a new MeshAssetTask object
  57903. */
  57904. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  57905. /**
  57906. * Add a TextFileAssetTask to the list of active tasks
  57907. * @param taskName defines the name of the new task
  57908. * @param url defines the url of the file to load
  57909. * @returns a new TextFileAssetTask object
  57910. */
  57911. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  57912. /**
  57913. * Add a BinaryFileAssetTask to the list of active tasks
  57914. * @param taskName defines the name of the new task
  57915. * @param url defines the url of the file to load
  57916. * @returns a new BinaryFileAssetTask object
  57917. */
  57918. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  57919. /**
  57920. * Add a ImageAssetTask to the list of active tasks
  57921. * @param taskName defines the name of the new task
  57922. * @param url defines the url of the file to load
  57923. * @returns a new ImageAssetTask object
  57924. */
  57925. addImageTask(taskName: string, url: string): ImageAssetTask;
  57926. /**
  57927. * Add a TextureAssetTask to the list of active tasks
  57928. * @param taskName defines the name of the new task
  57929. * @param url defines the url of the file to load
  57930. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57931. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  57932. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57933. * @returns a new TextureAssetTask object
  57934. */
  57935. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  57936. /**
  57937. * Add a CubeTextureAssetTask to the list of active tasks
  57938. * @param taskName defines the name of the new task
  57939. * @param url defines the url of the file to load
  57940. * @param extensions defines the extension to use to load the cube map (can be null)
  57941. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57942. * @param files defines the list of files to load (can be null)
  57943. * @returns a new CubeTextureAssetTask object
  57944. */
  57945. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  57946. /**
  57947. *
  57948. * Add a HDRCubeTextureAssetTask to the list of active tasks
  57949. * @param taskName defines the name of the new task
  57950. * @param url defines the url of the file to load
  57951. * @param size defines the size you want for the cubemap (can be null)
  57952. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57953. * @param generateHarmonics defines if you want to automatically generate (true by default)
  57954. * @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)
  57955. * @param reserved Internal use only
  57956. * @returns a new HDRCubeTextureAssetTask object
  57957. */
  57958. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  57959. /**
  57960. *
  57961. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  57962. * @param taskName defines the name of the new task
  57963. * @param url defines the url of the file to load
  57964. * @param size defines the size you want for the cubemap (can be null)
  57965. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57966. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  57967. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  57968. * @returns a new EquiRectangularCubeTextureAssetTask object
  57969. */
  57970. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  57971. /**
  57972. * Remove a task from the assets manager.
  57973. * @param task the task to remove
  57974. */
  57975. removeTask(task: AbstractAssetTask): void;
  57976. private _decreaseWaitingTasksCount;
  57977. private _runTask;
  57978. /**
  57979. * Reset the AssetsManager and remove all tasks
  57980. * @return the current instance of the AssetsManager
  57981. */
  57982. reset(): AssetsManager;
  57983. /**
  57984. * Start the loading process
  57985. * @return the current instance of the AssetsManager
  57986. */
  57987. load(): AssetsManager;
  57988. /**
  57989. * Start the loading process as an async operation
  57990. * @return a promise returning the list of failed tasks
  57991. */
  57992. loadAsync(): Promise<void>;
  57993. }
  57994. }
  57995. declare module "babylonjs/Misc/deferred" {
  57996. /**
  57997. * Wrapper class for promise with external resolve and reject.
  57998. */
  57999. export class Deferred<T> {
  58000. /**
  58001. * The promise associated with this deferred object.
  58002. */
  58003. readonly promise: Promise<T>;
  58004. private _resolve;
  58005. private _reject;
  58006. /**
  58007. * The resolve method of the promise associated with this deferred object.
  58008. */
  58009. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58010. /**
  58011. * The reject method of the promise associated with this deferred object.
  58012. */
  58013. readonly reject: (reason?: any) => void;
  58014. /**
  58015. * Constructor for this deferred object.
  58016. */
  58017. constructor();
  58018. }
  58019. }
  58020. declare module "babylonjs/Misc/meshExploder" {
  58021. import { Mesh } from "babylonjs/Meshes/mesh";
  58022. /**
  58023. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58024. */
  58025. export class MeshExploder {
  58026. private _centerMesh;
  58027. private _meshes;
  58028. private _meshesOrigins;
  58029. private _toCenterVectors;
  58030. private _scaledDirection;
  58031. private _newPosition;
  58032. private _centerPosition;
  58033. /**
  58034. * Explodes meshes from a center mesh.
  58035. * @param meshes The meshes to explode.
  58036. * @param centerMesh The mesh to be center of explosion.
  58037. */
  58038. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58039. private _setCenterMesh;
  58040. /**
  58041. * Get class name
  58042. * @returns "MeshExploder"
  58043. */
  58044. getClassName(): string;
  58045. /**
  58046. * "Exploded meshes"
  58047. * @returns Array of meshes with the centerMesh at index 0.
  58048. */
  58049. getMeshes(): Array<Mesh>;
  58050. /**
  58051. * Explodes meshes giving a specific direction
  58052. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58053. */
  58054. explode(direction?: number): void;
  58055. }
  58056. }
  58057. declare module "babylonjs/Misc/filesInput" {
  58058. import { Engine } from "babylonjs/Engines/engine";
  58059. import { Scene } from "babylonjs/scene";
  58060. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  58061. /**
  58062. * Class used to help managing file picking and drag'n'drop
  58063. */
  58064. export class FilesInput {
  58065. /**
  58066. * List of files ready to be loaded
  58067. */
  58068. static readonly FilesToLoad: {
  58069. [key: string]: File;
  58070. };
  58071. /**
  58072. * Callback called when a file is processed
  58073. */
  58074. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58075. private _engine;
  58076. private _currentScene;
  58077. private _sceneLoadedCallback;
  58078. private _progressCallback;
  58079. private _additionalRenderLoopLogicCallback;
  58080. private _textureLoadingCallback;
  58081. private _startingProcessingFilesCallback;
  58082. private _onReloadCallback;
  58083. private _errorCallback;
  58084. private _elementToMonitor;
  58085. private _sceneFileToLoad;
  58086. private _filesToLoad;
  58087. /**
  58088. * Creates a new FilesInput
  58089. * @param engine defines the rendering engine
  58090. * @param scene defines the hosting scene
  58091. * @param sceneLoadedCallback callback called when scene is loaded
  58092. * @param progressCallback callback called to track progress
  58093. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58094. * @param textureLoadingCallback callback called when a texture is loading
  58095. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58096. * @param onReloadCallback callback called when a reload is requested
  58097. * @param errorCallback callback call if an error occurs
  58098. */
  58099. 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);
  58100. private _dragEnterHandler;
  58101. private _dragOverHandler;
  58102. private _dropHandler;
  58103. /**
  58104. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58105. * @param elementToMonitor defines the DOM element to track
  58106. */
  58107. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58108. /**
  58109. * Release all associated resources
  58110. */
  58111. dispose(): void;
  58112. private renderFunction;
  58113. private drag;
  58114. private drop;
  58115. private _traverseFolder;
  58116. private _processFiles;
  58117. /**
  58118. * Load files from a drop event
  58119. * @param event defines the drop event to use as source
  58120. */
  58121. loadFiles(event: any): void;
  58122. private _processReload;
  58123. /**
  58124. * Reload the current scene from the loaded files
  58125. */
  58126. reload(): void;
  58127. }
  58128. }
  58129. declare module "babylonjs/Misc/HighDynamicRange/index" {
  58130. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  58131. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  58132. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  58133. }
  58134. declare module "babylonjs/Misc/sceneOptimizer" {
  58135. import { Scene, IDisposable } from "babylonjs/scene";
  58136. import { Observable } from "babylonjs/Misc/observable";
  58137. /**
  58138. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58139. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58140. */
  58141. export class SceneOptimization {
  58142. /**
  58143. * Defines the priority of this optimization (0 by default which means first in the list)
  58144. */
  58145. priority: number;
  58146. /**
  58147. * Gets a string describing the action executed by the current optimization
  58148. * @returns description string
  58149. */
  58150. getDescription(): string;
  58151. /**
  58152. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58153. * @param scene defines the current scene where to apply this optimization
  58154. * @param optimizer defines the current optimizer
  58155. * @returns true if everything that can be done was applied
  58156. */
  58157. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58158. /**
  58159. * Creates the SceneOptimization object
  58160. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58161. * @param desc defines the description associated with the optimization
  58162. */
  58163. constructor(
  58164. /**
  58165. * Defines the priority of this optimization (0 by default which means first in the list)
  58166. */
  58167. priority?: number);
  58168. }
  58169. /**
  58170. * Defines an optimization used to reduce the size of render target textures
  58171. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58172. */
  58173. export class TextureOptimization extends SceneOptimization {
  58174. /**
  58175. * Defines the priority of this optimization (0 by default which means first in the list)
  58176. */
  58177. priority: number;
  58178. /**
  58179. * 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
  58180. */
  58181. maximumSize: number;
  58182. /**
  58183. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58184. */
  58185. step: number;
  58186. /**
  58187. * Gets a string describing the action executed by the current optimization
  58188. * @returns description string
  58189. */
  58190. getDescription(): string;
  58191. /**
  58192. * Creates the TextureOptimization object
  58193. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58194. * @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
  58195. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58196. */
  58197. constructor(
  58198. /**
  58199. * Defines the priority of this optimization (0 by default which means first in the list)
  58200. */
  58201. priority?: number,
  58202. /**
  58203. * 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
  58204. */
  58205. maximumSize?: number,
  58206. /**
  58207. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58208. */
  58209. step?: number);
  58210. /**
  58211. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58212. * @param scene defines the current scene where to apply this optimization
  58213. * @param optimizer defines the current optimizer
  58214. * @returns true if everything that can be done was applied
  58215. */
  58216. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58217. }
  58218. /**
  58219. * Defines an optimization used to increase or decrease the rendering resolution
  58220. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58221. */
  58222. export class HardwareScalingOptimization extends SceneOptimization {
  58223. /**
  58224. * Defines the priority of this optimization (0 by default which means first in the list)
  58225. */
  58226. priority: number;
  58227. /**
  58228. * Defines the maximum scale to use (2 by default)
  58229. */
  58230. maximumScale: number;
  58231. /**
  58232. * Defines the step to use between two passes (0.5 by default)
  58233. */
  58234. step: number;
  58235. private _currentScale;
  58236. private _directionOffset;
  58237. /**
  58238. * Gets a string describing the action executed by the current optimization
  58239. * @return description string
  58240. */
  58241. getDescription(): string;
  58242. /**
  58243. * Creates the HardwareScalingOptimization object
  58244. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58245. * @param maximumScale defines the maximum scale to use (2 by default)
  58246. * @param step defines the step to use between two passes (0.5 by default)
  58247. */
  58248. constructor(
  58249. /**
  58250. * Defines the priority of this optimization (0 by default which means first in the list)
  58251. */
  58252. priority?: number,
  58253. /**
  58254. * Defines the maximum scale to use (2 by default)
  58255. */
  58256. maximumScale?: number,
  58257. /**
  58258. * Defines the step to use between two passes (0.5 by default)
  58259. */
  58260. step?: number);
  58261. /**
  58262. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58263. * @param scene defines the current scene where to apply this optimization
  58264. * @param optimizer defines the current optimizer
  58265. * @returns true if everything that can be done was applied
  58266. */
  58267. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58268. }
  58269. /**
  58270. * Defines an optimization used to remove shadows
  58271. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58272. */
  58273. export class ShadowsOptimization extends SceneOptimization {
  58274. /**
  58275. * Gets a string describing the action executed by the current optimization
  58276. * @return description string
  58277. */
  58278. getDescription(): string;
  58279. /**
  58280. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58281. * @param scene defines the current scene where to apply this optimization
  58282. * @param optimizer defines the current optimizer
  58283. * @returns true if everything that can be done was applied
  58284. */
  58285. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58286. }
  58287. /**
  58288. * Defines an optimization used to turn post-processes off
  58289. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58290. */
  58291. export class PostProcessesOptimization extends SceneOptimization {
  58292. /**
  58293. * Gets a string describing the action executed by the current optimization
  58294. * @return description string
  58295. */
  58296. getDescription(): string;
  58297. /**
  58298. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58299. * @param scene defines the current scene where to apply this optimization
  58300. * @param optimizer defines the current optimizer
  58301. * @returns true if everything that can be done was applied
  58302. */
  58303. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58304. }
  58305. /**
  58306. * Defines an optimization used to turn lens flares off
  58307. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58308. */
  58309. export class LensFlaresOptimization extends SceneOptimization {
  58310. /**
  58311. * Gets a string describing the action executed by the current optimization
  58312. * @return description string
  58313. */
  58314. getDescription(): string;
  58315. /**
  58316. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58317. * @param scene defines the current scene where to apply this optimization
  58318. * @param optimizer defines the current optimizer
  58319. * @returns true if everything that can be done was applied
  58320. */
  58321. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58322. }
  58323. /**
  58324. * Defines an optimization based on user defined callback.
  58325. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58326. */
  58327. export class CustomOptimization extends SceneOptimization {
  58328. /**
  58329. * Callback called to apply the custom optimization.
  58330. */
  58331. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58332. /**
  58333. * Callback called to get custom description
  58334. */
  58335. onGetDescription: () => string;
  58336. /**
  58337. * Gets a string describing the action executed by the current optimization
  58338. * @returns description string
  58339. */
  58340. getDescription(): string;
  58341. /**
  58342. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58343. * @param scene defines the current scene where to apply this optimization
  58344. * @param optimizer defines the current optimizer
  58345. * @returns true if everything that can be done was applied
  58346. */
  58347. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58348. }
  58349. /**
  58350. * Defines an optimization used to turn particles off
  58351. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58352. */
  58353. export class ParticlesOptimization extends SceneOptimization {
  58354. /**
  58355. * Gets a string describing the action executed by the current optimization
  58356. * @return description string
  58357. */
  58358. getDescription(): string;
  58359. /**
  58360. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58361. * @param scene defines the current scene where to apply this optimization
  58362. * @param optimizer defines the current optimizer
  58363. * @returns true if everything that can be done was applied
  58364. */
  58365. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58366. }
  58367. /**
  58368. * Defines an optimization used to turn render targets off
  58369. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58370. */
  58371. export class RenderTargetsOptimization extends SceneOptimization {
  58372. /**
  58373. * Gets a string describing the action executed by the current optimization
  58374. * @return description string
  58375. */
  58376. getDescription(): string;
  58377. /**
  58378. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58379. * @param scene defines the current scene where to apply this optimization
  58380. * @param optimizer defines the current optimizer
  58381. * @returns true if everything that can be done was applied
  58382. */
  58383. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58384. }
  58385. /**
  58386. * Defines an optimization used to merge meshes with compatible materials
  58387. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58388. */
  58389. export class MergeMeshesOptimization extends SceneOptimization {
  58390. private static _UpdateSelectionTree;
  58391. /**
  58392. * Gets or sets a boolean which defines if optimization octree has to be updated
  58393. */
  58394. /**
  58395. * Gets or sets a boolean which defines if optimization octree has to be updated
  58396. */
  58397. static UpdateSelectionTree: boolean;
  58398. /**
  58399. * Gets a string describing the action executed by the current optimization
  58400. * @return description string
  58401. */
  58402. getDescription(): string;
  58403. private _canBeMerged;
  58404. /**
  58405. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58406. * @param scene defines the current scene where to apply this optimization
  58407. * @param optimizer defines the current optimizer
  58408. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58409. * @returns true if everything that can be done was applied
  58410. */
  58411. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58412. }
  58413. /**
  58414. * Defines a list of options used by SceneOptimizer
  58415. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58416. */
  58417. export class SceneOptimizerOptions {
  58418. /**
  58419. * Defines the target frame rate to reach (60 by default)
  58420. */
  58421. targetFrameRate: number;
  58422. /**
  58423. * Defines the interval between two checkes (2000ms by default)
  58424. */
  58425. trackerDuration: number;
  58426. /**
  58427. * Gets the list of optimizations to apply
  58428. */
  58429. optimizations: SceneOptimization[];
  58430. /**
  58431. * Creates a new list of options used by SceneOptimizer
  58432. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58433. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58434. */
  58435. constructor(
  58436. /**
  58437. * Defines the target frame rate to reach (60 by default)
  58438. */
  58439. targetFrameRate?: number,
  58440. /**
  58441. * Defines the interval between two checkes (2000ms by default)
  58442. */
  58443. trackerDuration?: number);
  58444. /**
  58445. * Add a new optimization
  58446. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  58447. * @returns the current SceneOptimizerOptions
  58448. */
  58449. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  58450. /**
  58451. * Add a new custom optimization
  58452. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  58453. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  58454. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58455. * @returns the current SceneOptimizerOptions
  58456. */
  58457. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  58458. /**
  58459. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  58460. * @param targetFrameRate defines the target frame rate (60 by default)
  58461. * @returns a SceneOptimizerOptions object
  58462. */
  58463. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58464. /**
  58465. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  58466. * @param targetFrameRate defines the target frame rate (60 by default)
  58467. * @returns a SceneOptimizerOptions object
  58468. */
  58469. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58470. /**
  58471. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  58472. * @param targetFrameRate defines the target frame rate (60 by default)
  58473. * @returns a SceneOptimizerOptions object
  58474. */
  58475. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58476. }
  58477. /**
  58478. * Class used to run optimizations in order to reach a target frame rate
  58479. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58480. */
  58481. export class SceneOptimizer implements IDisposable {
  58482. private _isRunning;
  58483. private _options;
  58484. private _scene;
  58485. private _currentPriorityLevel;
  58486. private _targetFrameRate;
  58487. private _trackerDuration;
  58488. private _currentFrameRate;
  58489. private _sceneDisposeObserver;
  58490. private _improvementMode;
  58491. /**
  58492. * Defines an observable called when the optimizer reaches the target frame rate
  58493. */
  58494. onSuccessObservable: Observable<SceneOptimizer>;
  58495. /**
  58496. * Defines an observable called when the optimizer enables an optimization
  58497. */
  58498. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  58499. /**
  58500. * Defines an observable called when the optimizer is not able to reach the target frame rate
  58501. */
  58502. onFailureObservable: Observable<SceneOptimizer>;
  58503. /**
  58504. * Gets a boolean indicating if the optimizer is in improvement mode
  58505. */
  58506. readonly isInImprovementMode: boolean;
  58507. /**
  58508. * Gets the current priority level (0 at start)
  58509. */
  58510. readonly currentPriorityLevel: number;
  58511. /**
  58512. * Gets the current frame rate checked by the SceneOptimizer
  58513. */
  58514. readonly currentFrameRate: number;
  58515. /**
  58516. * Gets or sets the current target frame rate (60 by default)
  58517. */
  58518. /**
  58519. * Gets or sets the current target frame rate (60 by default)
  58520. */
  58521. targetFrameRate: number;
  58522. /**
  58523. * Gets or sets the current interval between two checks (every 2000ms by default)
  58524. */
  58525. /**
  58526. * Gets or sets the current interval between two checks (every 2000ms by default)
  58527. */
  58528. trackerDuration: number;
  58529. /**
  58530. * Gets the list of active optimizations
  58531. */
  58532. readonly optimizations: SceneOptimization[];
  58533. /**
  58534. * Creates a new SceneOptimizer
  58535. * @param scene defines the scene to work on
  58536. * @param options defines the options to use with the SceneOptimizer
  58537. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  58538. * @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)
  58539. */
  58540. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  58541. /**
  58542. * Stops the current optimizer
  58543. */
  58544. stop(): void;
  58545. /**
  58546. * Reset the optimizer to initial step (current priority level = 0)
  58547. */
  58548. reset(): void;
  58549. /**
  58550. * Start the optimizer. By default it will try to reach a specific framerate
  58551. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  58552. */
  58553. start(): void;
  58554. private _checkCurrentState;
  58555. /**
  58556. * Release all resources
  58557. */
  58558. dispose(): void;
  58559. /**
  58560. * Helper function to create a SceneOptimizer with one single line of code
  58561. * @param scene defines the scene to work on
  58562. * @param options defines the options to use with the SceneOptimizer
  58563. * @param onSuccess defines a callback to call on success
  58564. * @param onFailure defines a callback to call on failure
  58565. * @returns the new SceneOptimizer object
  58566. */
  58567. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  58568. }
  58569. }
  58570. declare module "babylonjs/Misc/sceneSerializer" {
  58571. import { Scene } from "babylonjs/scene";
  58572. /**
  58573. * Class used to serialize a scene into a string
  58574. */
  58575. export class SceneSerializer {
  58576. /**
  58577. * Clear cache used by a previous serialization
  58578. */
  58579. static ClearCache(): void;
  58580. /**
  58581. * Serialize a scene into a JSON compatible object
  58582. * @param scene defines the scene to serialize
  58583. * @returns a JSON compatible object
  58584. */
  58585. static Serialize(scene: Scene): any;
  58586. /**
  58587. * Serialize a mesh into a JSON compatible object
  58588. * @param toSerialize defines the mesh to serialize
  58589. * @param withParents defines if parents must be serialized as well
  58590. * @param withChildren defines if children must be serialized as well
  58591. * @returns a JSON compatible object
  58592. */
  58593. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  58594. }
  58595. }
  58596. declare module "babylonjs/Misc/textureTools" {
  58597. import { Texture } from "babylonjs/Materials/Textures/texture";
  58598. /**
  58599. * Class used to host texture specific utilities
  58600. */
  58601. export class TextureTools {
  58602. /**
  58603. * Uses the GPU to create a copy texture rescaled at a given size
  58604. * @param texture Texture to copy from
  58605. * @param width defines the desired width
  58606. * @param height defines the desired height
  58607. * @param useBilinearMode defines if bilinear mode has to be used
  58608. * @return the generated texture
  58609. */
  58610. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  58611. }
  58612. }
  58613. declare module "babylonjs/Misc/videoRecorder" {
  58614. import { Nullable } from "babylonjs/types";
  58615. import { Engine } from "babylonjs/Engines/engine";
  58616. /**
  58617. * This represents the different options avilable for the video capture.
  58618. */
  58619. export interface VideoRecorderOptions {
  58620. /** Defines the mime type of the video */
  58621. mimeType: string;
  58622. /** Defines the video the video should be recorded at */
  58623. fps: number;
  58624. /** Defines the chunk size for the recording data */
  58625. recordChunckSize: number;
  58626. /** The audio tracks to attach to the record */
  58627. audioTracks?: MediaStreamTrack[];
  58628. }
  58629. /**
  58630. * This can helps recording videos from BabylonJS.
  58631. * This is based on the available WebRTC functionalities of the browser.
  58632. *
  58633. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  58634. */
  58635. export class VideoRecorder {
  58636. private static readonly _defaultOptions;
  58637. /**
  58638. * Returns wehther or not the VideoRecorder is available in your browser.
  58639. * @param engine Defines the Babylon Engine to check the support for
  58640. * @returns true if supported otherwise false
  58641. */
  58642. static IsSupported(engine: Engine): boolean;
  58643. private readonly _options;
  58644. private _canvas;
  58645. private _mediaRecorder;
  58646. private _recordedChunks;
  58647. private _fileName;
  58648. private _resolve;
  58649. private _reject;
  58650. /**
  58651. * True wether a recording is already in progress.
  58652. */
  58653. readonly isRecording: boolean;
  58654. /**
  58655. * Create a new VideoCapture object which can help converting what you see in Babylon to
  58656. * a video file.
  58657. * @param engine Defines the BabylonJS Engine you wish to record
  58658. * @param options Defines options that can be used to customized the capture
  58659. */
  58660. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  58661. /**
  58662. * Stops the current recording before the default capture timeout passed in the startRecording
  58663. * functions.
  58664. */
  58665. stopRecording(): void;
  58666. /**
  58667. * Starts recording the canvas for a max duration specified in parameters.
  58668. * @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.
  58669. * @param maxDuration Defines the maximum recording time in seconds.
  58670. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  58671. * @return a promise callback at the end of the recording with the video data in Blob.
  58672. */
  58673. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  58674. /**
  58675. * Releases internal resources used during the recording.
  58676. */
  58677. dispose(): void;
  58678. private _handleDataAvailable;
  58679. private _handleError;
  58680. private _handleStop;
  58681. }
  58682. }
  58683. declare module "babylonjs/Misc/screenshotTools" {
  58684. import { Camera } from "babylonjs/Cameras/camera";
  58685. import { Engine } from "babylonjs/Engines/engine";
  58686. /**
  58687. * Class containing a set of static utilities functions for screenshots
  58688. */
  58689. export class ScreenshotTools {
  58690. /**
  58691. * Captures a screenshot of the current rendering
  58692. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58693. * @param engine defines the rendering engine
  58694. * @param camera defines the source camera
  58695. * @param size This parameter can be set to a single number or to an object with the
  58696. * following (optional) properties: precision, width, height. If a single number is passed,
  58697. * it will be used for both width and height. If an object is passed, the screenshot size
  58698. * will be derived from the parameters. The precision property is a multiplier allowing
  58699. * rendering at a higher or lower resolution
  58700. * @param successCallback defines the callback receives a single parameter which contains the
  58701. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58702. * src parameter of an <img> to display it
  58703. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  58704. * Check your browser for supported MIME types
  58705. */
  58706. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  58707. /**
  58708. * Generates an image screenshot from the specified camera.
  58709. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58710. * @param engine The engine to use for rendering
  58711. * @param camera The camera to use for rendering
  58712. * @param size This parameter can be set to a single number or to an object with the
  58713. * following (optional) properties: precision, width, height. If a single number is passed,
  58714. * it will be used for both width and height. If an object is passed, the screenshot size
  58715. * will be derived from the parameters. The precision property is a multiplier allowing
  58716. * rendering at a higher or lower resolution
  58717. * @param successCallback The callback receives a single parameter which contains the
  58718. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58719. * src parameter of an <img> to display it
  58720. * @param mimeType The MIME type of the screenshot image (default: image/png).
  58721. * Check your browser for supported MIME types
  58722. * @param samples Texture samples (default: 1)
  58723. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  58724. * @param fileName A name for for the downloaded file.
  58725. */
  58726. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  58727. }
  58728. }
  58729. declare module "babylonjs/Misc/index" {
  58730. export * from "babylonjs/Misc/andOrNotEvaluator";
  58731. export * from "babylonjs/Misc/assetsManager";
  58732. export * from "babylonjs/Misc/dds";
  58733. export * from "babylonjs/Misc/decorators";
  58734. export * from "babylonjs/Misc/deferred";
  58735. export * from "babylonjs/Misc/environmentTextureTools";
  58736. export * from "babylonjs/Misc/meshExploder";
  58737. export * from "babylonjs/Misc/filesInput";
  58738. export * from "babylonjs/Misc/HighDynamicRange/index";
  58739. export * from "babylonjs/Misc/khronosTextureContainer";
  58740. export * from "babylonjs/Misc/observable";
  58741. export * from "babylonjs/Misc/performanceMonitor";
  58742. export * from "babylonjs/Misc/promise";
  58743. export * from "babylonjs/Misc/sceneOptimizer";
  58744. export * from "babylonjs/Misc/sceneSerializer";
  58745. export * from "babylonjs/Misc/smartArray";
  58746. export * from "babylonjs/Misc/stringDictionary";
  58747. export * from "babylonjs/Misc/tags";
  58748. export * from "babylonjs/Misc/textureTools";
  58749. export * from "babylonjs/Misc/tga";
  58750. export * from "babylonjs/Misc/tools";
  58751. export * from "babylonjs/Misc/videoRecorder";
  58752. export * from "babylonjs/Misc/virtualJoystick";
  58753. export * from "babylonjs/Misc/workerPool";
  58754. export * from "babylonjs/Misc/logger";
  58755. export * from "babylonjs/Misc/typeStore";
  58756. export * from "babylonjs/Misc/filesInputStore";
  58757. export * from "babylonjs/Misc/deepCopier";
  58758. export * from "babylonjs/Misc/pivotTools";
  58759. export * from "babylonjs/Misc/precisionDate";
  58760. export * from "babylonjs/Misc/screenshotTools";
  58761. export * from "babylonjs/Misc/typeStore";
  58762. export * from "babylonjs/Misc/webRequest";
  58763. export * from "babylonjs/Misc/iInspectable";
  58764. }
  58765. declare module "babylonjs/index" {
  58766. export * from "babylonjs/abstractScene";
  58767. export * from "babylonjs/Actions/index";
  58768. export * from "babylonjs/Animations/index";
  58769. export * from "babylonjs/assetContainer";
  58770. export * from "babylonjs/Audio/index";
  58771. export * from "babylonjs/Behaviors/index";
  58772. export * from "babylonjs/Bones/index";
  58773. export * from "babylonjs/Cameras/index";
  58774. export * from "babylonjs/Collisions/index";
  58775. export * from "babylonjs/Culling/index";
  58776. export * from "babylonjs/Debug/index";
  58777. export * from "babylonjs/Engines/index";
  58778. export * from "babylonjs/Events/index";
  58779. export * from "babylonjs/Gamepads/index";
  58780. export * from "babylonjs/Gizmos/index";
  58781. export * from "babylonjs/Helpers/index";
  58782. export * from "babylonjs/Instrumentation/index";
  58783. export * from "babylonjs/Layers/index";
  58784. export * from "babylonjs/LensFlares/index";
  58785. export * from "babylonjs/Lights/index";
  58786. export * from "babylonjs/Loading/index";
  58787. export * from "babylonjs/Materials/index";
  58788. export * from "babylonjs/Maths/index";
  58789. export * from "babylonjs/Meshes/index";
  58790. export * from "babylonjs/Morph/index";
  58791. export * from "babylonjs/node";
  58792. export * from "babylonjs/Offline/index";
  58793. export * from "babylonjs/Particles/index";
  58794. export * from "babylonjs/Physics/index";
  58795. export * from "babylonjs/PostProcesses/index";
  58796. export * from "babylonjs/Probes/index";
  58797. export * from "babylonjs/Rendering/index";
  58798. export * from "babylonjs/scene";
  58799. export * from "babylonjs/sceneComponent";
  58800. export * from "babylonjs/Sprites/index";
  58801. export * from "babylonjs/States/index";
  58802. export * from "babylonjs/Misc/index";
  58803. export * from "babylonjs/types";
  58804. }
  58805. declare module "babylonjs/Animations/pathCursor" {
  58806. import { Path2, Vector3 } from "babylonjs/Maths/math";
  58807. /**
  58808. * A cursor which tracks a point on a path
  58809. */
  58810. export class PathCursor {
  58811. private path;
  58812. /**
  58813. * Stores path cursor callbacks for when an onchange event is triggered
  58814. */
  58815. private _onchange;
  58816. /**
  58817. * The value of the path cursor
  58818. */
  58819. value: number;
  58820. /**
  58821. * The animation array of the path cursor
  58822. */
  58823. animations: Animation[];
  58824. /**
  58825. * Initializes the path cursor
  58826. * @param path The path to track
  58827. */
  58828. constructor(path: Path2);
  58829. /**
  58830. * Gets the cursor point on the path
  58831. * @returns A point on the path cursor at the cursor location
  58832. */
  58833. getPoint(): Vector3;
  58834. /**
  58835. * Moves the cursor ahead by the step amount
  58836. * @param step The amount to move the cursor forward
  58837. * @returns This path cursor
  58838. */
  58839. moveAhead(step?: number): PathCursor;
  58840. /**
  58841. * Moves the cursor behind by the step amount
  58842. * @param step The amount to move the cursor back
  58843. * @returns This path cursor
  58844. */
  58845. moveBack(step?: number): PathCursor;
  58846. /**
  58847. * Moves the cursor by the step amount
  58848. * If the step amount is greater than one, an exception is thrown
  58849. * @param step The amount to move the cursor
  58850. * @returns This path cursor
  58851. */
  58852. move(step: number): PathCursor;
  58853. /**
  58854. * Ensures that the value is limited between zero and one
  58855. * @returns This path cursor
  58856. */
  58857. private ensureLimits;
  58858. /**
  58859. * Runs onchange callbacks on change (used by the animation engine)
  58860. * @returns This path cursor
  58861. */
  58862. private raiseOnChange;
  58863. /**
  58864. * Executes a function on change
  58865. * @param f A path cursor onchange callback
  58866. * @returns This path cursor
  58867. */
  58868. onchange(f: (cursor: PathCursor) => void): PathCursor;
  58869. }
  58870. }
  58871. declare module "babylonjs/Legacy/legacy" {
  58872. import * as Babylon from "babylonjs/index";
  58873. export * from "babylonjs/index";
  58874. }
  58875. declare module "babylonjs/Shaders/blur.fragment" {
  58876. /** @hidden */
  58877. export var blurPixelShader: {
  58878. name: string;
  58879. shader: string;
  58880. };
  58881. }
  58882. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  58883. /** @hidden */
  58884. export var bones300Declaration: {
  58885. name: string;
  58886. shader: string;
  58887. };
  58888. }
  58889. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  58890. /** @hidden */
  58891. export var instances300Declaration: {
  58892. name: string;
  58893. shader: string;
  58894. };
  58895. }
  58896. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  58897. /** @hidden */
  58898. export var pointCloudVertexDeclaration: {
  58899. name: string;
  58900. shader: string;
  58901. };
  58902. }
  58903. // Mixins
  58904. interface Window {
  58905. mozIndexedDB: IDBFactory;
  58906. webkitIndexedDB: IDBFactory;
  58907. msIndexedDB: IDBFactory;
  58908. webkitURL: typeof URL;
  58909. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  58910. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  58911. WebGLRenderingContext: WebGLRenderingContext;
  58912. MSGesture: MSGesture;
  58913. CANNON: any;
  58914. AudioContext: AudioContext;
  58915. webkitAudioContext: AudioContext;
  58916. PointerEvent: any;
  58917. Math: Math;
  58918. Uint8Array: Uint8ArrayConstructor;
  58919. Float32Array: Float32ArrayConstructor;
  58920. mozURL: typeof URL;
  58921. msURL: typeof URL;
  58922. VRFrameData: any; // WebVR, from specs 1.1
  58923. DracoDecoderModule: any;
  58924. setImmediate(handler: (...args: any[]) => void): number;
  58925. }
  58926. interface HTMLCanvasElement {
  58927. requestPointerLock(): void;
  58928. msRequestPointerLock?(): void;
  58929. mozRequestPointerLock?(): void;
  58930. webkitRequestPointerLock?(): void;
  58931. /** Track wether a record is in progress */
  58932. isRecording: boolean;
  58933. /** Capture Stream method defined by some browsers */
  58934. captureStream(fps?: number): MediaStream;
  58935. }
  58936. interface CanvasRenderingContext2D {
  58937. msImageSmoothingEnabled: boolean;
  58938. }
  58939. interface MouseEvent {
  58940. mozMovementX: number;
  58941. mozMovementY: number;
  58942. webkitMovementX: number;
  58943. webkitMovementY: number;
  58944. msMovementX: number;
  58945. msMovementY: number;
  58946. }
  58947. interface Navigator {
  58948. mozGetVRDevices: (any: any) => any;
  58949. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58950. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58951. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58952. webkitGetGamepads(): Gamepad[];
  58953. msGetGamepads(): Gamepad[];
  58954. webkitGamepads(): Gamepad[];
  58955. }
  58956. interface HTMLVideoElement {
  58957. mozSrcObject: any;
  58958. }
  58959. interface Math {
  58960. fround(x: number): number;
  58961. imul(a: number, b: number): number;
  58962. }
  58963. interface WebGLProgram {
  58964. context?: WebGLRenderingContext;
  58965. vertexShader?: WebGLShader;
  58966. fragmentShader?: WebGLShader;
  58967. isParallelCompiled: boolean;
  58968. onCompiled?: () => void;
  58969. }
  58970. interface WebGLRenderingContext {
  58971. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  58972. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  58973. vertexAttribDivisor(index: number, divisor: number): void;
  58974. createVertexArray(): any;
  58975. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  58976. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  58977. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  58978. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  58979. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  58980. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  58981. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  58982. // Queries
  58983. createQuery(): WebGLQuery;
  58984. deleteQuery(query: WebGLQuery): void;
  58985. beginQuery(target: number, query: WebGLQuery): void;
  58986. endQuery(target: number): void;
  58987. getQueryParameter(query: WebGLQuery, pname: number): any;
  58988. getQuery(target: number, pname: number): any;
  58989. MAX_SAMPLES: number;
  58990. RGBA8: number;
  58991. READ_FRAMEBUFFER: number;
  58992. DRAW_FRAMEBUFFER: number;
  58993. UNIFORM_BUFFER: number;
  58994. HALF_FLOAT_OES: number;
  58995. RGBA16F: number;
  58996. RGBA32F: number;
  58997. R32F: number;
  58998. RG32F: number;
  58999. RGB32F: number;
  59000. R16F: number;
  59001. RG16F: number;
  59002. RGB16F: number;
  59003. RED: number;
  59004. RG: number;
  59005. R8: number;
  59006. RG8: number;
  59007. UNSIGNED_INT_24_8: number;
  59008. DEPTH24_STENCIL8: number;
  59009. /* Multiple Render Targets */
  59010. drawBuffers(buffers: number[]): void;
  59011. readBuffer(src: number): void;
  59012. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59013. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59014. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59015. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59016. // Occlusion Query
  59017. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59018. ANY_SAMPLES_PASSED: number;
  59019. QUERY_RESULT_AVAILABLE: number;
  59020. QUERY_RESULT: number;
  59021. }
  59022. interface WebGLBuffer {
  59023. references: number;
  59024. capacity: number;
  59025. is32Bits: boolean;
  59026. }
  59027. interface WebGLProgram {
  59028. transformFeedback?: WebGLTransformFeedback | null;
  59029. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59030. }
  59031. interface EXT_disjoint_timer_query {
  59032. QUERY_COUNTER_BITS_EXT: number;
  59033. TIME_ELAPSED_EXT: number;
  59034. TIMESTAMP_EXT: number;
  59035. GPU_DISJOINT_EXT: number;
  59036. QUERY_RESULT_EXT: number;
  59037. QUERY_RESULT_AVAILABLE_EXT: number;
  59038. queryCounterEXT(query: WebGLQuery, target: number): void;
  59039. createQueryEXT(): WebGLQuery;
  59040. beginQueryEXT(target: number, query: WebGLQuery): void;
  59041. endQueryEXT(target: number): void;
  59042. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59043. deleteQueryEXT(query: WebGLQuery): void;
  59044. }
  59045. interface WebGLUniformLocation {
  59046. _currentState: any;
  59047. }
  59048. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59049. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59050. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59051. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59052. interface WebGLRenderingContext {
  59053. readonly RASTERIZER_DISCARD: number;
  59054. readonly DEPTH_COMPONENT24: number;
  59055. readonly TEXTURE_3D: number;
  59056. readonly TEXTURE_2D_ARRAY: number;
  59057. readonly TEXTURE_COMPARE_FUNC: number;
  59058. readonly TEXTURE_COMPARE_MODE: number;
  59059. readonly COMPARE_REF_TO_TEXTURE: number;
  59060. readonly TEXTURE_WRAP_R: number;
  59061. readonly HALF_FLOAT: number;
  59062. readonly RGB8: number;
  59063. readonly RED_INTEGER: number;
  59064. readonly RG_INTEGER: number;
  59065. readonly RGB_INTEGER: number;
  59066. readonly RGBA_INTEGER: number;
  59067. readonly R8_SNORM: number;
  59068. readonly RG8_SNORM: number;
  59069. readonly RGB8_SNORM: number;
  59070. readonly RGBA8_SNORM: number;
  59071. readonly R8I: number;
  59072. readonly RG8I: number;
  59073. readonly RGB8I: number;
  59074. readonly RGBA8I: number;
  59075. readonly R8UI: number;
  59076. readonly RG8UI: number;
  59077. readonly RGB8UI: number;
  59078. readonly RGBA8UI: number;
  59079. readonly R16I: number;
  59080. readonly RG16I: number;
  59081. readonly RGB16I: number;
  59082. readonly RGBA16I: number;
  59083. readonly R16UI: number;
  59084. readonly RG16UI: number;
  59085. readonly RGB16UI: number;
  59086. readonly RGBA16UI: number;
  59087. readonly R32I: number;
  59088. readonly RG32I: number;
  59089. readonly RGB32I: number;
  59090. readonly RGBA32I: number;
  59091. readonly R32UI: number;
  59092. readonly RG32UI: number;
  59093. readonly RGB32UI: number;
  59094. readonly RGBA32UI: number;
  59095. readonly RGB10_A2UI: number;
  59096. readonly R11F_G11F_B10F: number;
  59097. readonly RGB9_E5: number;
  59098. readonly RGB10_A2: number;
  59099. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59100. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59101. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59102. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59103. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59104. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59105. 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;
  59106. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59107. readonly TRANSFORM_FEEDBACK: number;
  59108. readonly INTERLEAVED_ATTRIBS: number;
  59109. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59110. createTransformFeedback(): WebGLTransformFeedback;
  59111. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59112. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59113. beginTransformFeedback(primitiveMode: number): void;
  59114. endTransformFeedback(): void;
  59115. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59116. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59117. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59118. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59119. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59120. }
  59121. interface ImageBitmap {
  59122. readonly width: number;
  59123. readonly height: number;
  59124. close(): void;
  59125. }
  59126. interface WebGLQuery extends WebGLObject {
  59127. }
  59128. declare var WebGLQuery: {
  59129. prototype: WebGLQuery;
  59130. new(): WebGLQuery;
  59131. };
  59132. interface WebGLSampler extends WebGLObject {
  59133. }
  59134. declare var WebGLSampler: {
  59135. prototype: WebGLSampler;
  59136. new(): WebGLSampler;
  59137. };
  59138. interface WebGLSync extends WebGLObject {
  59139. }
  59140. declare var WebGLSync: {
  59141. prototype: WebGLSync;
  59142. new(): WebGLSync;
  59143. };
  59144. interface WebGLTransformFeedback extends WebGLObject {
  59145. }
  59146. declare var WebGLTransformFeedback: {
  59147. prototype: WebGLTransformFeedback;
  59148. new(): WebGLTransformFeedback;
  59149. };
  59150. interface WebGLVertexArrayObject extends WebGLObject {
  59151. }
  59152. declare var WebGLVertexArrayObject: {
  59153. prototype: WebGLVertexArrayObject;
  59154. new(): WebGLVertexArrayObject;
  59155. };
  59156. // Type definitions for WebVR API
  59157. // Project: https://w3c.github.io/webvr/
  59158. // Definitions by: six a <https://github.com/lostfictions>
  59159. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59160. interface VRDisplay extends EventTarget {
  59161. /**
  59162. * Dictionary of capabilities describing the VRDisplay.
  59163. */
  59164. readonly capabilities: VRDisplayCapabilities;
  59165. /**
  59166. * z-depth defining the far plane of the eye view frustum
  59167. * enables mapping of values in the render target depth
  59168. * attachment to scene coordinates. Initially set to 10000.0.
  59169. */
  59170. depthFar: number;
  59171. /**
  59172. * z-depth defining the near plane of the eye view frustum
  59173. * enables mapping of values in the render target depth
  59174. * attachment to scene coordinates. Initially set to 0.01.
  59175. */
  59176. depthNear: number;
  59177. /**
  59178. * An identifier for this distinct VRDisplay. Used as an
  59179. * association point in the Gamepad API.
  59180. */
  59181. readonly displayId: number;
  59182. /**
  59183. * A display name, a user-readable name identifying it.
  59184. */
  59185. readonly displayName: string;
  59186. readonly isConnected: boolean;
  59187. readonly isPresenting: boolean;
  59188. /**
  59189. * If this VRDisplay supports room-scale experiences, the optional
  59190. * stage attribute contains details on the room-scale parameters.
  59191. */
  59192. readonly stageParameters: VRStageParameters | null;
  59193. /**
  59194. * Passing the value returned by `requestAnimationFrame` to
  59195. * `cancelAnimationFrame` will unregister the callback.
  59196. * @param handle Define the hanle of the request to cancel
  59197. */
  59198. cancelAnimationFrame(handle: number): void;
  59199. /**
  59200. * Stops presenting to the VRDisplay.
  59201. * @returns a promise to know when it stopped
  59202. */
  59203. exitPresent(): Promise<void>;
  59204. /**
  59205. * Return the current VREyeParameters for the given eye.
  59206. * @param whichEye Define the eye we want the parameter for
  59207. * @returns the eye parameters
  59208. */
  59209. getEyeParameters(whichEye: string): VREyeParameters;
  59210. /**
  59211. * Populates the passed VRFrameData with the information required to render
  59212. * the current frame.
  59213. * @param frameData Define the data structure to populate
  59214. * @returns true if ok otherwise false
  59215. */
  59216. getFrameData(frameData: VRFrameData): boolean;
  59217. /**
  59218. * Get the layers currently being presented.
  59219. * @returns the list of VR layers
  59220. */
  59221. getLayers(): VRLayer[];
  59222. /**
  59223. * Return a VRPose containing the future predicted pose of the VRDisplay
  59224. * when the current frame will be presented. The value returned will not
  59225. * change until JavaScript has returned control to the browser.
  59226. *
  59227. * The VRPose will contain the position, orientation, velocity,
  59228. * and acceleration of each of these properties.
  59229. * @returns the pose object
  59230. */
  59231. getPose(): VRPose;
  59232. /**
  59233. * Return the current instantaneous pose of the VRDisplay, with no
  59234. * prediction applied.
  59235. * @returns the current instantaneous pose
  59236. */
  59237. getImmediatePose(): VRPose;
  59238. /**
  59239. * The callback passed to `requestAnimationFrame` will be called
  59240. * any time a new frame should be rendered. When the VRDisplay is
  59241. * presenting the callback will be called at the native refresh
  59242. * rate of the HMD. When not presenting this function acts
  59243. * identically to how window.requestAnimationFrame acts. Content should
  59244. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59245. * asynchronously from other displays and at differing refresh rates.
  59246. * @param callback Define the eaction to run next frame
  59247. * @returns the request handle it
  59248. */
  59249. requestAnimationFrame(callback: FrameRequestCallback): number;
  59250. /**
  59251. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59252. * Repeat calls while already presenting will update the VRLayers being displayed.
  59253. * @param layers Define the list of layer to present
  59254. * @returns a promise to know when the request has been fulfilled
  59255. */
  59256. requestPresent(layers: VRLayer[]): Promise<void>;
  59257. /**
  59258. * Reset the pose for this display, treating its current position and
  59259. * orientation as the "origin/zero" values. VRPose.position,
  59260. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59261. * updated when calling resetPose(). This should be called in only
  59262. * sitting-space experiences.
  59263. */
  59264. resetPose(): void;
  59265. /**
  59266. * The VRLayer provided to the VRDisplay will be captured and presented
  59267. * in the HMD. Calling this function has the same effect on the source
  59268. * canvas as any other operation that uses its source image, and canvases
  59269. * created without preserveDrawingBuffer set to true will be cleared.
  59270. * @param pose Define the pose to submit
  59271. */
  59272. submitFrame(pose?: VRPose): void;
  59273. }
  59274. declare var VRDisplay: {
  59275. prototype: VRDisplay;
  59276. new(): VRDisplay;
  59277. };
  59278. interface VRLayer {
  59279. leftBounds?: number[] | Float32Array | null;
  59280. rightBounds?: number[] | Float32Array | null;
  59281. source?: HTMLCanvasElement | null;
  59282. }
  59283. interface VRDisplayCapabilities {
  59284. readonly canPresent: boolean;
  59285. readonly hasExternalDisplay: boolean;
  59286. readonly hasOrientation: boolean;
  59287. readonly hasPosition: boolean;
  59288. readonly maxLayers: number;
  59289. }
  59290. interface VREyeParameters {
  59291. /** @deprecated */
  59292. readonly fieldOfView: VRFieldOfView;
  59293. readonly offset: Float32Array;
  59294. readonly renderHeight: number;
  59295. readonly renderWidth: number;
  59296. }
  59297. interface VRFieldOfView {
  59298. readonly downDegrees: number;
  59299. readonly leftDegrees: number;
  59300. readonly rightDegrees: number;
  59301. readonly upDegrees: number;
  59302. }
  59303. interface VRFrameData {
  59304. readonly leftProjectionMatrix: Float32Array;
  59305. readonly leftViewMatrix: Float32Array;
  59306. readonly pose: VRPose;
  59307. readonly rightProjectionMatrix: Float32Array;
  59308. readonly rightViewMatrix: Float32Array;
  59309. readonly timestamp: number;
  59310. }
  59311. interface VRPose {
  59312. readonly angularAcceleration: Float32Array | null;
  59313. readonly angularVelocity: Float32Array | null;
  59314. readonly linearAcceleration: Float32Array | null;
  59315. readonly linearVelocity: Float32Array | null;
  59316. readonly orientation: Float32Array | null;
  59317. readonly position: Float32Array | null;
  59318. readonly timestamp: number;
  59319. }
  59320. interface VRStageParameters {
  59321. sittingToStandingTransform?: Float32Array;
  59322. sizeX?: number;
  59323. sizeY?: number;
  59324. }
  59325. interface Navigator {
  59326. getVRDisplays(): Promise<VRDisplay[]>;
  59327. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59328. }
  59329. interface Window {
  59330. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59331. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59332. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59333. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59334. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59335. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59336. }
  59337. interface Gamepad {
  59338. readonly displayId: number;
  59339. }
  59340. interface XRDevice {
  59341. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59342. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59343. }
  59344. interface XRSession {
  59345. getInputSources(): Array<any>;
  59346. baseLayer: XRWebGLLayer;
  59347. requestFrameOfReference(type: string): Promise<void>;
  59348. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59349. end(): Promise<void>;
  59350. requestAnimationFrame: Function;
  59351. addEventListener: Function;
  59352. }
  59353. interface XRSessionCreationOptions {
  59354. outputContext?: WebGLRenderingContext | null;
  59355. immersive?: boolean;
  59356. environmentIntegration?: boolean;
  59357. }
  59358. interface XRLayer {
  59359. getViewport: Function;
  59360. framebufferWidth: number;
  59361. framebufferHeight: number;
  59362. }
  59363. interface XRView {
  59364. projectionMatrix: Float32Array;
  59365. }
  59366. interface XRFrame {
  59367. getDevicePose: Function;
  59368. getInputPose: Function;
  59369. views: Array<XRView>;
  59370. baseLayer: XRLayer;
  59371. }
  59372. interface XRFrameOfReference {
  59373. }
  59374. interface XRWebGLLayer extends XRLayer {
  59375. framebuffer: WebGLFramebuffer;
  59376. }
  59377. declare var XRWebGLLayer: {
  59378. prototype: XRWebGLLayer;
  59379. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59380. };
  59381. declare module "babylonjs" {
  59382. export * from "babylonjs/Legacy/legacy";
  59383. }
  59384. declare module BABYLON {
  59385. /** Alias type for value that can be null */
  59386. export type Nullable<T> = T | null;
  59387. /**
  59388. * Alias type for number that are floats
  59389. * @ignorenaming
  59390. */
  59391. export type float = number;
  59392. /**
  59393. * Alias type for number that are doubles.
  59394. * @ignorenaming
  59395. */
  59396. export type double = number;
  59397. /**
  59398. * Alias type for number that are integer
  59399. * @ignorenaming
  59400. */
  59401. export type int = number;
  59402. /** Alias type for number array or Float32Array */
  59403. export type FloatArray = number[] | Float32Array;
  59404. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  59405. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  59406. /**
  59407. * Alias for types that can be used by a Buffer or VertexBuffer.
  59408. */
  59409. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  59410. /**
  59411. * Alias type for primitive types
  59412. * @ignorenaming
  59413. */
  59414. type Primitive = undefined | null | boolean | string | number | Function;
  59415. /**
  59416. * Type modifier to make all the properties of an object Readonly
  59417. */
  59418. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  59419. /**
  59420. * Type modifier to make all the properties of an object Readonly recursively
  59421. */
  59422. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  59423. /** @hidden */
  59424. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  59425. }
  59426. /** @hidden */
  59427. /** @hidden */
  59428. type DeepImmutableObject<T> = {
  59429. readonly [K in keyof T]: DeepImmutable<T[K]>;
  59430. };
  59431. }
  59432. declare module BABYLON {
  59433. /**
  59434. * Class containing a set of static utilities functions for arrays.
  59435. */
  59436. export class ArrayTools {
  59437. /**
  59438. * Returns an array of the given size filled with element built from the given constructor and the paramters
  59439. * @param size the number of element to construct and put in the array
  59440. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  59441. * @returns a new array filled with new objects
  59442. */
  59443. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  59444. }
  59445. }
  59446. declare module BABYLON {
  59447. /**
  59448. * Scalar computation library
  59449. */
  59450. export class Scalar {
  59451. /**
  59452. * Two pi constants convenient for computation.
  59453. */
  59454. static TwoPi: number;
  59455. /**
  59456. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59457. * @param a number
  59458. * @param b number
  59459. * @param epsilon (default = 1.401298E-45)
  59460. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59461. */
  59462. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  59463. /**
  59464. * Returns a string : the upper case translation of the number i to hexadecimal.
  59465. * @param i number
  59466. * @returns the upper case translation of the number i to hexadecimal.
  59467. */
  59468. static ToHex(i: number): string;
  59469. /**
  59470. * Returns -1 if value is negative and +1 is value is positive.
  59471. * @param value the value
  59472. * @returns the value itself if it's equal to zero.
  59473. */
  59474. static Sign(value: number): number;
  59475. /**
  59476. * Returns the value itself if it's between min and max.
  59477. * Returns min if the value is lower than min.
  59478. * Returns max if the value is greater than max.
  59479. * @param value the value to clmap
  59480. * @param min the min value to clamp to (default: 0)
  59481. * @param max the max value to clamp to (default: 1)
  59482. * @returns the clamped value
  59483. */
  59484. static Clamp(value: number, min?: number, max?: number): number;
  59485. /**
  59486. * the log2 of value.
  59487. * @param value the value to compute log2 of
  59488. * @returns the log2 of value.
  59489. */
  59490. static Log2(value: number): number;
  59491. /**
  59492. * Loops the value, so that it is never larger than length and never smaller than 0.
  59493. *
  59494. * This is similar to the modulo operator but it works with floating point numbers.
  59495. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  59496. * With t = 5 and length = 2.5, the result would be 0.0.
  59497. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  59498. * @param value the value
  59499. * @param length the length
  59500. * @returns the looped value
  59501. */
  59502. static Repeat(value: number, length: number): number;
  59503. /**
  59504. * Normalize the value between 0.0 and 1.0 using min and max values
  59505. * @param value value to normalize
  59506. * @param min max to normalize between
  59507. * @param max min to normalize between
  59508. * @returns the normalized value
  59509. */
  59510. static Normalize(value: number, min: number, max: number): number;
  59511. /**
  59512. * Denormalize the value from 0.0 and 1.0 using min and max values
  59513. * @param normalized value to denormalize
  59514. * @param min max to denormalize between
  59515. * @param max min to denormalize between
  59516. * @returns the denormalized value
  59517. */
  59518. static Denormalize(normalized: number, min: number, max: number): number;
  59519. /**
  59520. * Calculates the shortest difference between two given angles given in degrees.
  59521. * @param current current angle in degrees
  59522. * @param target target angle in degrees
  59523. * @returns the delta
  59524. */
  59525. static DeltaAngle(current: number, target: number): number;
  59526. /**
  59527. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  59528. * @param tx value
  59529. * @param length length
  59530. * @returns The returned value will move back and forth between 0 and length
  59531. */
  59532. static PingPong(tx: number, length: number): number;
  59533. /**
  59534. * Interpolates between min and max with smoothing at the limits.
  59535. *
  59536. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  59537. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  59538. * @param from from
  59539. * @param to to
  59540. * @param tx value
  59541. * @returns the smooth stepped value
  59542. */
  59543. static SmoothStep(from: number, to: number, tx: number): number;
  59544. /**
  59545. * Moves a value current towards target.
  59546. *
  59547. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  59548. * Negative values of maxDelta pushes the value away from target.
  59549. * @param current current value
  59550. * @param target target value
  59551. * @param maxDelta max distance to move
  59552. * @returns resulting value
  59553. */
  59554. static MoveTowards(current: number, target: number, maxDelta: number): number;
  59555. /**
  59556. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  59557. *
  59558. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  59559. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  59560. * @param current current value
  59561. * @param target target value
  59562. * @param maxDelta max distance to move
  59563. * @returns resulting angle
  59564. */
  59565. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  59566. /**
  59567. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  59568. * @param start start value
  59569. * @param end target value
  59570. * @param amount amount to lerp between
  59571. * @returns the lerped value
  59572. */
  59573. static Lerp(start: number, end: number, amount: number): number;
  59574. /**
  59575. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  59576. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  59577. * @param start start value
  59578. * @param end target value
  59579. * @param amount amount to lerp between
  59580. * @returns the lerped value
  59581. */
  59582. static LerpAngle(start: number, end: number, amount: number): number;
  59583. /**
  59584. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  59585. * @param a start value
  59586. * @param b target value
  59587. * @param value value between a and b
  59588. * @returns the inverseLerp value
  59589. */
  59590. static InverseLerp(a: number, b: number, value: number): number;
  59591. /**
  59592. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  59593. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  59594. * @param value1 spline value
  59595. * @param tangent1 spline value
  59596. * @param value2 spline value
  59597. * @param tangent2 spline value
  59598. * @param amount input value
  59599. * @returns hermite result
  59600. */
  59601. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  59602. /**
  59603. * Returns a random float number between and min and max values
  59604. * @param min min value of random
  59605. * @param max max value of random
  59606. * @returns random value
  59607. */
  59608. static RandomRange(min: number, max: number): number;
  59609. /**
  59610. * This function returns percentage of a number in a given range.
  59611. *
  59612. * RangeToPercent(40,20,60) will return 0.5 (50%)
  59613. * RangeToPercent(34,0,100) will return 0.34 (34%)
  59614. * @param number to convert to percentage
  59615. * @param min min range
  59616. * @param max max range
  59617. * @returns the percentage
  59618. */
  59619. static RangeToPercent(number: number, min: number, max: number): number;
  59620. /**
  59621. * This function returns number that corresponds to the percentage in a given range.
  59622. *
  59623. * PercentToRange(0.34,0,100) will return 34.
  59624. * @param percent to convert to number
  59625. * @param min min range
  59626. * @param max max range
  59627. * @returns the number
  59628. */
  59629. static PercentToRange(percent: number, min: number, max: number): number;
  59630. /**
  59631. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  59632. * @param angle The angle to normalize in radian.
  59633. * @return The converted angle.
  59634. */
  59635. static NormalizeRadians(angle: number): number;
  59636. }
  59637. }
  59638. declare module BABYLON {
  59639. /**
  59640. * Constant used to convert a value to gamma space
  59641. * @ignorenaming
  59642. */
  59643. export const ToGammaSpace: number;
  59644. /**
  59645. * Constant used to convert a value to linear space
  59646. * @ignorenaming
  59647. */
  59648. export const ToLinearSpace = 2.2;
  59649. /**
  59650. * Constant used to define the minimal number value in Babylon.js
  59651. * @ignorenaming
  59652. */
  59653. let Epsilon: number;
  59654. /**
  59655. * Class used to hold a RBG color
  59656. */
  59657. export class Color3 {
  59658. /**
  59659. * Defines the red component (between 0 and 1, default is 0)
  59660. */
  59661. r: number;
  59662. /**
  59663. * Defines the green component (between 0 and 1, default is 0)
  59664. */
  59665. g: number;
  59666. /**
  59667. * Defines the blue component (between 0 and 1, default is 0)
  59668. */
  59669. b: number;
  59670. /**
  59671. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  59672. * @param r defines the red component (between 0 and 1, default is 0)
  59673. * @param g defines the green component (between 0 and 1, default is 0)
  59674. * @param b defines the blue component (between 0 and 1, default is 0)
  59675. */
  59676. constructor(
  59677. /**
  59678. * Defines the red component (between 0 and 1, default is 0)
  59679. */
  59680. r?: number,
  59681. /**
  59682. * Defines the green component (between 0 and 1, default is 0)
  59683. */
  59684. g?: number,
  59685. /**
  59686. * Defines the blue component (between 0 and 1, default is 0)
  59687. */
  59688. b?: number);
  59689. /**
  59690. * Creates a string with the Color3 current values
  59691. * @returns the string representation of the Color3 object
  59692. */
  59693. toString(): string;
  59694. /**
  59695. * Returns the string "Color3"
  59696. * @returns "Color3"
  59697. */
  59698. getClassName(): string;
  59699. /**
  59700. * Compute the Color3 hash code
  59701. * @returns an unique number that can be used to hash Color3 objects
  59702. */
  59703. getHashCode(): number;
  59704. /**
  59705. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  59706. * @param array defines the array where to store the r,g,b components
  59707. * @param index defines an optional index in the target array to define where to start storing values
  59708. * @returns the current Color3 object
  59709. */
  59710. toArray(array: FloatArray, index?: number): Color3;
  59711. /**
  59712. * Returns a new Color4 object from the current Color3 and the given alpha
  59713. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  59714. * @returns a new Color4 object
  59715. */
  59716. toColor4(alpha?: number): Color4;
  59717. /**
  59718. * Returns a new array populated with 3 numeric elements : red, green and blue values
  59719. * @returns the new array
  59720. */
  59721. asArray(): number[];
  59722. /**
  59723. * Returns the luminance value
  59724. * @returns a float value
  59725. */
  59726. toLuminance(): number;
  59727. /**
  59728. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  59729. * @param otherColor defines the second operand
  59730. * @returns the new Color3 object
  59731. */
  59732. multiply(otherColor: DeepImmutable<Color3>): Color3;
  59733. /**
  59734. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  59735. * @param otherColor defines the second operand
  59736. * @param result defines the Color3 object where to store the result
  59737. * @returns the current Color3
  59738. */
  59739. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59740. /**
  59741. * Determines equality between Color3 objects
  59742. * @param otherColor defines the second operand
  59743. * @returns true if the rgb values are equal to the given ones
  59744. */
  59745. equals(otherColor: DeepImmutable<Color3>): boolean;
  59746. /**
  59747. * Determines equality between the current Color3 object and a set of r,b,g values
  59748. * @param r defines the red component to check
  59749. * @param g defines the green component to check
  59750. * @param b defines the blue component to check
  59751. * @returns true if the rgb values are equal to the given ones
  59752. */
  59753. equalsFloats(r: number, g: number, b: number): boolean;
  59754. /**
  59755. * Multiplies in place each rgb value by scale
  59756. * @param scale defines the scaling factor
  59757. * @returns the updated Color3
  59758. */
  59759. scale(scale: number): Color3;
  59760. /**
  59761. * Multiplies the rgb values by scale and stores the result into "result"
  59762. * @param scale defines the scaling factor
  59763. * @param result defines the Color3 object where to store the result
  59764. * @returns the unmodified current Color3
  59765. */
  59766. scaleToRef(scale: number, result: Color3): Color3;
  59767. /**
  59768. * Scale the current Color3 values by a factor and add the result to a given Color3
  59769. * @param scale defines the scale factor
  59770. * @param result defines color to store the result into
  59771. * @returns the unmodified current Color3
  59772. */
  59773. scaleAndAddToRef(scale: number, result: Color3): Color3;
  59774. /**
  59775. * Clamps the rgb values by the min and max values and stores the result into "result"
  59776. * @param min defines minimum clamping value (default is 0)
  59777. * @param max defines maximum clamping value (default is 1)
  59778. * @param result defines color to store the result into
  59779. * @returns the original Color3
  59780. */
  59781. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  59782. /**
  59783. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  59784. * @param otherColor defines the second operand
  59785. * @returns the new Color3
  59786. */
  59787. add(otherColor: DeepImmutable<Color3>): Color3;
  59788. /**
  59789. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  59790. * @param otherColor defines the second operand
  59791. * @param result defines Color3 object to store the result into
  59792. * @returns the unmodified current Color3
  59793. */
  59794. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59795. /**
  59796. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  59797. * @param otherColor defines the second operand
  59798. * @returns the new Color3
  59799. */
  59800. subtract(otherColor: DeepImmutable<Color3>): Color3;
  59801. /**
  59802. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  59803. * @param otherColor defines the second operand
  59804. * @param result defines Color3 object to store the result into
  59805. * @returns the unmodified current Color3
  59806. */
  59807. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59808. /**
  59809. * Copy the current object
  59810. * @returns a new Color3 copied the current one
  59811. */
  59812. clone(): Color3;
  59813. /**
  59814. * Copies the rgb values from the source in the current Color3
  59815. * @param source defines the source Color3 object
  59816. * @returns the updated Color3 object
  59817. */
  59818. copyFrom(source: DeepImmutable<Color3>): Color3;
  59819. /**
  59820. * Updates the Color3 rgb values from the given floats
  59821. * @param r defines the red component to read from
  59822. * @param g defines the green component to read from
  59823. * @param b defines the blue component to read from
  59824. * @returns the current Color3 object
  59825. */
  59826. copyFromFloats(r: number, g: number, b: number): Color3;
  59827. /**
  59828. * Updates the Color3 rgb values from the given floats
  59829. * @param r defines the red component to read from
  59830. * @param g defines the green component to read from
  59831. * @param b defines the blue component to read from
  59832. * @returns the current Color3 object
  59833. */
  59834. set(r: number, g: number, b: number): Color3;
  59835. /**
  59836. * Compute the Color3 hexadecimal code as a string
  59837. * @returns a string containing the hexadecimal representation of the Color3 object
  59838. */
  59839. toHexString(): string;
  59840. /**
  59841. * Computes a new Color3 converted from the current one to linear space
  59842. * @returns a new Color3 object
  59843. */
  59844. toLinearSpace(): Color3;
  59845. /**
  59846. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  59847. * @param convertedColor defines the Color3 object where to store the linear space version
  59848. * @returns the unmodified Color3
  59849. */
  59850. toLinearSpaceToRef(convertedColor: Color3): Color3;
  59851. /**
  59852. * Computes a new Color3 converted from the current one to gamma space
  59853. * @returns a new Color3 object
  59854. */
  59855. toGammaSpace(): Color3;
  59856. /**
  59857. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  59858. * @param convertedColor defines the Color3 object where to store the gamma space version
  59859. * @returns the unmodified Color3
  59860. */
  59861. toGammaSpaceToRef(convertedColor: Color3): Color3;
  59862. private static _BlackReadOnly;
  59863. /**
  59864. * Creates a new Color3 from the string containing valid hexadecimal values
  59865. * @param hex defines a string containing valid hexadecimal values
  59866. * @returns a new Color3 object
  59867. */
  59868. static FromHexString(hex: string): Color3;
  59869. /**
  59870. * Creates a new Vector3 from the starting index of the given array
  59871. * @param array defines the source array
  59872. * @param offset defines an offset in the source array
  59873. * @returns a new Color3 object
  59874. */
  59875. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  59876. /**
  59877. * Creates a new Color3 from integer values (< 256)
  59878. * @param r defines the red component to read from (value between 0 and 255)
  59879. * @param g defines the green component to read from (value between 0 and 255)
  59880. * @param b defines the blue component to read from (value between 0 and 255)
  59881. * @returns a new Color3 object
  59882. */
  59883. static FromInts(r: number, g: number, b: number): Color3;
  59884. /**
  59885. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59886. * @param start defines the start Color3 value
  59887. * @param end defines the end Color3 value
  59888. * @param amount defines the gradient value between start and end
  59889. * @returns a new Color3 object
  59890. */
  59891. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  59892. /**
  59893. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59894. * @param left defines the start value
  59895. * @param right defines the end value
  59896. * @param amount defines the gradient factor
  59897. * @param result defines the Color3 object where to store the result
  59898. */
  59899. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  59900. /**
  59901. * Returns a Color3 value containing a red color
  59902. * @returns a new Color3 object
  59903. */
  59904. static Red(): Color3;
  59905. /**
  59906. * Returns a Color3 value containing a green color
  59907. * @returns a new Color3 object
  59908. */
  59909. static Green(): Color3;
  59910. /**
  59911. * Returns a Color3 value containing a blue color
  59912. * @returns a new Color3 object
  59913. */
  59914. static Blue(): Color3;
  59915. /**
  59916. * Returns a Color3 value containing a black color
  59917. * @returns a new Color3 object
  59918. */
  59919. static Black(): Color3;
  59920. /**
  59921. * Gets a Color3 value containing a black color that must not be updated
  59922. */
  59923. static readonly BlackReadOnly: DeepImmutable<Color3>;
  59924. /**
  59925. * Returns a Color3 value containing a white color
  59926. * @returns a new Color3 object
  59927. */
  59928. static White(): Color3;
  59929. /**
  59930. * Returns a Color3 value containing a purple color
  59931. * @returns a new Color3 object
  59932. */
  59933. static Purple(): Color3;
  59934. /**
  59935. * Returns a Color3 value containing a magenta color
  59936. * @returns a new Color3 object
  59937. */
  59938. static Magenta(): Color3;
  59939. /**
  59940. * Returns a Color3 value containing a yellow color
  59941. * @returns a new Color3 object
  59942. */
  59943. static Yellow(): Color3;
  59944. /**
  59945. * Returns a Color3 value containing a gray color
  59946. * @returns a new Color3 object
  59947. */
  59948. static Gray(): Color3;
  59949. /**
  59950. * Returns a Color3 value containing a teal color
  59951. * @returns a new Color3 object
  59952. */
  59953. static Teal(): Color3;
  59954. /**
  59955. * Returns a Color3 value containing a random color
  59956. * @returns a new Color3 object
  59957. */
  59958. static Random(): Color3;
  59959. }
  59960. /**
  59961. * Class used to hold a RBGA color
  59962. */
  59963. export class Color4 {
  59964. /**
  59965. * Defines the red component (between 0 and 1, default is 0)
  59966. */
  59967. r: number;
  59968. /**
  59969. * Defines the green component (between 0 and 1, default is 0)
  59970. */
  59971. g: number;
  59972. /**
  59973. * Defines the blue component (between 0 and 1, default is 0)
  59974. */
  59975. b: number;
  59976. /**
  59977. * Defines the alpha component (between 0 and 1, default is 1)
  59978. */
  59979. a: number;
  59980. /**
  59981. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  59982. * @param r defines the red component (between 0 and 1, default is 0)
  59983. * @param g defines the green component (between 0 and 1, default is 0)
  59984. * @param b defines the blue component (between 0 and 1, default is 0)
  59985. * @param a defines the alpha component (between 0 and 1, default is 1)
  59986. */
  59987. constructor(
  59988. /**
  59989. * Defines the red component (between 0 and 1, default is 0)
  59990. */
  59991. r?: number,
  59992. /**
  59993. * Defines the green component (between 0 and 1, default is 0)
  59994. */
  59995. g?: number,
  59996. /**
  59997. * Defines the blue component (between 0 and 1, default is 0)
  59998. */
  59999. b?: number,
  60000. /**
  60001. * Defines the alpha component (between 0 and 1, default is 1)
  60002. */
  60003. a?: number);
  60004. /**
  60005. * Adds in place the given Color4 values to the current Color4 object
  60006. * @param right defines the second operand
  60007. * @returns the current updated Color4 object
  60008. */
  60009. addInPlace(right: DeepImmutable<Color4>): Color4;
  60010. /**
  60011. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  60012. * @returns the new array
  60013. */
  60014. asArray(): number[];
  60015. /**
  60016. * Stores from the starting index in the given array the Color4 successive values
  60017. * @param array defines the array where to store the r,g,b components
  60018. * @param index defines an optional index in the target array to define where to start storing values
  60019. * @returns the current Color4 object
  60020. */
  60021. toArray(array: number[], index?: number): Color4;
  60022. /**
  60023. * Determines equality between Color4 objects
  60024. * @param otherColor defines the second operand
  60025. * @returns true if the rgba values are equal to the given ones
  60026. */
  60027. equals(otherColor: DeepImmutable<Color4>): boolean;
  60028. /**
  60029. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  60030. * @param right defines the second operand
  60031. * @returns a new Color4 object
  60032. */
  60033. add(right: DeepImmutable<Color4>): Color4;
  60034. /**
  60035. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  60036. * @param right defines the second operand
  60037. * @returns a new Color4 object
  60038. */
  60039. subtract(right: DeepImmutable<Color4>): Color4;
  60040. /**
  60041. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  60042. * @param right defines the second operand
  60043. * @param result defines the Color4 object where to store the result
  60044. * @returns the current Color4 object
  60045. */
  60046. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  60047. /**
  60048. * Creates a new Color4 with the current Color4 values multiplied by scale
  60049. * @param scale defines the scaling factor to apply
  60050. * @returns a new Color4 object
  60051. */
  60052. scale(scale: number): Color4;
  60053. /**
  60054. * Multiplies the current Color4 values by scale and stores the result in "result"
  60055. * @param scale defines the scaling factor to apply
  60056. * @param result defines the Color4 object where to store the result
  60057. * @returns the current unmodified Color4
  60058. */
  60059. scaleToRef(scale: number, result: Color4): Color4;
  60060. /**
  60061. * Scale the current Color4 values by a factor and add the result to a given Color4
  60062. * @param scale defines the scale factor
  60063. * @param result defines the Color4 object where to store the result
  60064. * @returns the unmodified current Color4
  60065. */
  60066. scaleAndAddToRef(scale: number, result: Color4): Color4;
  60067. /**
  60068. * Clamps the rgb values by the min and max values and stores the result into "result"
  60069. * @param min defines minimum clamping value (default is 0)
  60070. * @param max defines maximum clamping value (default is 1)
  60071. * @param result defines color to store the result into.
  60072. * @returns the cuurent Color4
  60073. */
  60074. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  60075. /**
  60076. * Multipy an Color4 value by another and return a new Color4 object
  60077. * @param color defines the Color4 value to multiply by
  60078. * @returns a new Color4 object
  60079. */
  60080. multiply(color: Color4): Color4;
  60081. /**
  60082. * Multipy a Color4 value by another and push the result in a reference value
  60083. * @param color defines the Color4 value to multiply by
  60084. * @param result defines the Color4 to fill the result in
  60085. * @returns the result Color4
  60086. */
  60087. multiplyToRef(color: Color4, result: Color4): Color4;
  60088. /**
  60089. * Creates a string with the Color4 current values
  60090. * @returns the string representation of the Color4 object
  60091. */
  60092. toString(): string;
  60093. /**
  60094. * Returns the string "Color4"
  60095. * @returns "Color4"
  60096. */
  60097. getClassName(): string;
  60098. /**
  60099. * Compute the Color4 hash code
  60100. * @returns an unique number that can be used to hash Color4 objects
  60101. */
  60102. getHashCode(): number;
  60103. /**
  60104. * Creates a new Color4 copied from the current one
  60105. * @returns a new Color4 object
  60106. */
  60107. clone(): Color4;
  60108. /**
  60109. * Copies the given Color4 values into the current one
  60110. * @param source defines the source Color4 object
  60111. * @returns the current updated Color4 object
  60112. */
  60113. copyFrom(source: Color4): Color4;
  60114. /**
  60115. * Copies the given float values into the current one
  60116. * @param r defines the red component to read from
  60117. * @param g defines the green component to read from
  60118. * @param b defines the blue component to read from
  60119. * @param a defines the alpha component to read from
  60120. * @returns the current updated Color4 object
  60121. */
  60122. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  60123. /**
  60124. * Copies the given float values into the current one
  60125. * @param r defines the red component to read from
  60126. * @param g defines the green component to read from
  60127. * @param b defines the blue component to read from
  60128. * @param a defines the alpha component to read from
  60129. * @returns the current updated Color4 object
  60130. */
  60131. set(r: number, g: number, b: number, a: number): Color4;
  60132. /**
  60133. * Compute the Color4 hexadecimal code as a string
  60134. * @returns a string containing the hexadecimal representation of the Color4 object
  60135. */
  60136. toHexString(): string;
  60137. /**
  60138. * Computes a new Color4 converted from the current one to linear space
  60139. * @returns a new Color4 object
  60140. */
  60141. toLinearSpace(): Color4;
  60142. /**
  60143. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  60144. * @param convertedColor defines the Color4 object where to store the linear space version
  60145. * @returns the unmodified Color4
  60146. */
  60147. toLinearSpaceToRef(convertedColor: Color4): Color4;
  60148. /**
  60149. * Computes a new Color4 converted from the current one to gamma space
  60150. * @returns a new Color4 object
  60151. */
  60152. toGammaSpace(): Color4;
  60153. /**
  60154. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  60155. * @param convertedColor defines the Color4 object where to store the gamma space version
  60156. * @returns the unmodified Color4
  60157. */
  60158. toGammaSpaceToRef(convertedColor: Color4): Color4;
  60159. /**
  60160. * Creates a new Color4 from the string containing valid hexadecimal values
  60161. * @param hex defines a string containing valid hexadecimal values
  60162. * @returns a new Color4 object
  60163. */
  60164. static FromHexString(hex: string): Color4;
  60165. /**
  60166. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60167. * @param left defines the start value
  60168. * @param right defines the end value
  60169. * @param amount defines the gradient factor
  60170. * @returns a new Color4 object
  60171. */
  60172. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  60173. /**
  60174. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60175. * @param left defines the start value
  60176. * @param right defines the end value
  60177. * @param amount defines the gradient factor
  60178. * @param result defines the Color4 object where to store data
  60179. */
  60180. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  60181. /**
  60182. * Creates a new Color4 from a Color3 and an alpha value
  60183. * @param color3 defines the source Color3 to read from
  60184. * @param alpha defines the alpha component (1.0 by default)
  60185. * @returns a new Color4 object
  60186. */
  60187. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  60188. /**
  60189. * Creates a new Color4 from the starting index element of the given array
  60190. * @param array defines the source array to read from
  60191. * @param offset defines the offset in the source array
  60192. * @returns a new Color4 object
  60193. */
  60194. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  60195. /**
  60196. * Creates a new Color3 from integer values (< 256)
  60197. * @param r defines the red component to read from (value between 0 and 255)
  60198. * @param g defines the green component to read from (value between 0 and 255)
  60199. * @param b defines the blue component to read from (value between 0 and 255)
  60200. * @param a defines the alpha component to read from (value between 0 and 255)
  60201. * @returns a new Color3 object
  60202. */
  60203. static FromInts(r: number, g: number, b: number, a: number): Color4;
  60204. /**
  60205. * Check the content of a given array and convert it to an array containing RGBA data
  60206. * If the original array was already containing count * 4 values then it is returned directly
  60207. * @param colors defines the array to check
  60208. * @param count defines the number of RGBA data to expect
  60209. * @returns an array containing count * 4 values (RGBA)
  60210. */
  60211. static CheckColors4(colors: number[], count: number): number[];
  60212. }
  60213. /**
  60214. * Class representing a vector containing 2 coordinates
  60215. */
  60216. export class Vector2 {
  60217. /** defines the first coordinate */
  60218. x: number;
  60219. /** defines the second coordinate */
  60220. y: number;
  60221. /**
  60222. * Creates a new Vector2 from the given x and y coordinates
  60223. * @param x defines the first coordinate
  60224. * @param y defines the second coordinate
  60225. */
  60226. constructor(
  60227. /** defines the first coordinate */
  60228. x?: number,
  60229. /** defines the second coordinate */
  60230. y?: number);
  60231. /**
  60232. * Gets a string with the Vector2 coordinates
  60233. * @returns a string with the Vector2 coordinates
  60234. */
  60235. toString(): string;
  60236. /**
  60237. * Gets class name
  60238. * @returns the string "Vector2"
  60239. */
  60240. getClassName(): string;
  60241. /**
  60242. * Gets current vector hash code
  60243. * @returns the Vector2 hash code as a number
  60244. */
  60245. getHashCode(): number;
  60246. /**
  60247. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  60248. * @param array defines the source array
  60249. * @param index defines the offset in source array
  60250. * @returns the current Vector2
  60251. */
  60252. toArray(array: FloatArray, index?: number): Vector2;
  60253. /**
  60254. * Copy the current vector to an array
  60255. * @returns a new array with 2 elements: the Vector2 coordinates.
  60256. */
  60257. asArray(): number[];
  60258. /**
  60259. * Sets the Vector2 coordinates with the given Vector2 coordinates
  60260. * @param source defines the source Vector2
  60261. * @returns the current updated Vector2
  60262. */
  60263. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  60264. /**
  60265. * Sets the Vector2 coordinates with the given floats
  60266. * @param x defines the first coordinate
  60267. * @param y defines the second coordinate
  60268. * @returns the current updated Vector2
  60269. */
  60270. copyFromFloats(x: number, y: number): Vector2;
  60271. /**
  60272. * Sets the Vector2 coordinates with the given floats
  60273. * @param x defines the first coordinate
  60274. * @param y defines the second coordinate
  60275. * @returns the current updated Vector2
  60276. */
  60277. set(x: number, y: number): Vector2;
  60278. /**
  60279. * Add another vector with the current one
  60280. * @param otherVector defines the other vector
  60281. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  60282. */
  60283. add(otherVector: DeepImmutable<Vector2>): Vector2;
  60284. /**
  60285. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  60286. * @param otherVector defines the other vector
  60287. * @param result defines the target vector
  60288. * @returns the unmodified current Vector2
  60289. */
  60290. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60291. /**
  60292. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  60293. * @param otherVector defines the other vector
  60294. * @returns the current updated Vector2
  60295. */
  60296. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60297. /**
  60298. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  60299. * @param otherVector defines the other vector
  60300. * @returns a new Vector2
  60301. */
  60302. addVector3(otherVector: Vector3): Vector2;
  60303. /**
  60304. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  60305. * @param otherVector defines the other vector
  60306. * @returns a new Vector2
  60307. */
  60308. subtract(otherVector: Vector2): Vector2;
  60309. /**
  60310. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  60311. * @param otherVector defines the other vector
  60312. * @param result defines the target vector
  60313. * @returns the unmodified current Vector2
  60314. */
  60315. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60316. /**
  60317. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  60318. * @param otherVector defines the other vector
  60319. * @returns the current updated Vector2
  60320. */
  60321. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60322. /**
  60323. * Multiplies in place the current Vector2 coordinates by the given ones
  60324. * @param otherVector defines the other vector
  60325. * @returns the current updated Vector2
  60326. */
  60327. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60328. /**
  60329. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  60330. * @param otherVector defines the other vector
  60331. * @returns a new Vector2
  60332. */
  60333. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  60334. /**
  60335. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  60336. * @param otherVector defines the other vector
  60337. * @param result defines the target vector
  60338. * @returns the unmodified current Vector2
  60339. */
  60340. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60341. /**
  60342. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  60343. * @param x defines the first coordinate
  60344. * @param y defines the second coordinate
  60345. * @returns a new Vector2
  60346. */
  60347. multiplyByFloats(x: number, y: number): Vector2;
  60348. /**
  60349. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  60350. * @param otherVector defines the other vector
  60351. * @returns a new Vector2
  60352. */
  60353. divide(otherVector: Vector2): Vector2;
  60354. /**
  60355. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  60356. * @param otherVector defines the other vector
  60357. * @param result defines the target vector
  60358. * @returns the unmodified current Vector2
  60359. */
  60360. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60361. /**
  60362. * Divides the current Vector2 coordinates by the given ones
  60363. * @param otherVector defines the other vector
  60364. * @returns the current updated Vector2
  60365. */
  60366. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60367. /**
  60368. * Gets a new Vector2 with current Vector2 negated coordinates
  60369. * @returns a new Vector2
  60370. */
  60371. negate(): Vector2;
  60372. /**
  60373. * Multiply the Vector2 coordinates by scale
  60374. * @param scale defines the scaling factor
  60375. * @returns the current updated Vector2
  60376. */
  60377. scaleInPlace(scale: number): Vector2;
  60378. /**
  60379. * Returns a new Vector2 scaled by "scale" from the current Vector2
  60380. * @param scale defines the scaling factor
  60381. * @returns a new Vector2
  60382. */
  60383. scale(scale: number): Vector2;
  60384. /**
  60385. * Scale the current Vector2 values by a factor to a given Vector2
  60386. * @param scale defines the scale factor
  60387. * @param result defines the Vector2 object where to store the result
  60388. * @returns the unmodified current Vector2
  60389. */
  60390. scaleToRef(scale: number, result: Vector2): Vector2;
  60391. /**
  60392. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  60393. * @param scale defines the scale factor
  60394. * @param result defines the Vector2 object where to store the result
  60395. * @returns the unmodified current Vector2
  60396. */
  60397. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  60398. /**
  60399. * Gets a boolean if two vectors are equals
  60400. * @param otherVector defines the other vector
  60401. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  60402. */
  60403. equals(otherVector: DeepImmutable<Vector2>): boolean;
  60404. /**
  60405. * Gets a boolean if two vectors are equals (using an epsilon value)
  60406. * @param otherVector defines the other vector
  60407. * @param epsilon defines the minimal distance to consider equality
  60408. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  60409. */
  60410. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  60411. /**
  60412. * Gets a new Vector2 from current Vector2 floored values
  60413. * @returns a new Vector2
  60414. */
  60415. floor(): Vector2;
  60416. /**
  60417. * Gets a new Vector2 from current Vector2 floored values
  60418. * @returns a new Vector2
  60419. */
  60420. fract(): Vector2;
  60421. /**
  60422. * Gets the length of the vector
  60423. * @returns the vector length (float)
  60424. */
  60425. length(): number;
  60426. /**
  60427. * Gets the vector squared length
  60428. * @returns the vector squared length (float)
  60429. */
  60430. lengthSquared(): number;
  60431. /**
  60432. * Normalize the vector
  60433. * @returns the current updated Vector2
  60434. */
  60435. normalize(): Vector2;
  60436. /**
  60437. * Gets a new Vector2 copied from the Vector2
  60438. * @returns a new Vector2
  60439. */
  60440. clone(): Vector2;
  60441. /**
  60442. * Gets a new Vector2(0, 0)
  60443. * @returns a new Vector2
  60444. */
  60445. static Zero(): Vector2;
  60446. /**
  60447. * Gets a new Vector2(1, 1)
  60448. * @returns a new Vector2
  60449. */
  60450. static One(): Vector2;
  60451. /**
  60452. * Gets a new Vector2 set from the given index element of the given array
  60453. * @param array defines the data source
  60454. * @param offset defines the offset in the data source
  60455. * @returns a new Vector2
  60456. */
  60457. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  60458. /**
  60459. * Sets "result" from the given index element of the given array
  60460. * @param array defines the data source
  60461. * @param offset defines the offset in the data source
  60462. * @param result defines the target vector
  60463. */
  60464. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  60465. /**
  60466. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  60467. * @param value1 defines 1st point of control
  60468. * @param value2 defines 2nd point of control
  60469. * @param value3 defines 3rd point of control
  60470. * @param value4 defines 4th point of control
  60471. * @param amount defines the interpolation factor
  60472. * @returns a new Vector2
  60473. */
  60474. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  60475. /**
  60476. * 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".
  60477. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  60478. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  60479. * @param value defines the value to clamp
  60480. * @param min defines the lower limit
  60481. * @param max defines the upper limit
  60482. * @returns a new Vector2
  60483. */
  60484. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  60485. /**
  60486. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  60487. * @param value1 defines the 1st control point
  60488. * @param tangent1 defines the outgoing tangent
  60489. * @param value2 defines the 2nd control point
  60490. * @param tangent2 defines the incoming tangent
  60491. * @param amount defines the interpolation factor
  60492. * @returns a new Vector2
  60493. */
  60494. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  60495. /**
  60496. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  60497. * @param start defines the start vector
  60498. * @param end defines the end vector
  60499. * @param amount defines the interpolation factor
  60500. * @returns a new Vector2
  60501. */
  60502. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  60503. /**
  60504. * Gets the dot product of the vector "left" and the vector "right"
  60505. * @param left defines first vector
  60506. * @param right defines second vector
  60507. * @returns the dot product (float)
  60508. */
  60509. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  60510. /**
  60511. * Returns a new Vector2 equal to the normalized given vector
  60512. * @param vector defines the vector to normalize
  60513. * @returns a new Vector2
  60514. */
  60515. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  60516. /**
  60517. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  60518. * @param left defines 1st vector
  60519. * @param right defines 2nd vector
  60520. * @returns a new Vector2
  60521. */
  60522. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  60523. /**
  60524. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  60525. * @param left defines 1st vector
  60526. * @param right defines 2nd vector
  60527. * @returns a new Vector2
  60528. */
  60529. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  60530. /**
  60531. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  60532. * @param vector defines the vector to transform
  60533. * @param transformation defines the matrix to apply
  60534. * @returns a new Vector2
  60535. */
  60536. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  60537. /**
  60538. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  60539. * @param vector defines the vector to transform
  60540. * @param transformation defines the matrix to apply
  60541. * @param result defines the target vector
  60542. */
  60543. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  60544. /**
  60545. * Determines if a given vector is included in a triangle
  60546. * @param p defines the vector to test
  60547. * @param p0 defines 1st triangle point
  60548. * @param p1 defines 2nd triangle point
  60549. * @param p2 defines 3rd triangle point
  60550. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  60551. */
  60552. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  60553. /**
  60554. * Gets the distance between the vectors "value1" and "value2"
  60555. * @param value1 defines first vector
  60556. * @param value2 defines second vector
  60557. * @returns the distance between vectors
  60558. */
  60559. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  60560. /**
  60561. * Returns the squared distance between the vectors "value1" and "value2"
  60562. * @param value1 defines first vector
  60563. * @param value2 defines second vector
  60564. * @returns the squared distance between vectors
  60565. */
  60566. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  60567. /**
  60568. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  60569. * @param value1 defines first vector
  60570. * @param value2 defines second vector
  60571. * @returns a new Vector2
  60572. */
  60573. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  60574. /**
  60575. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  60576. * @param p defines the middle point
  60577. * @param segA defines one point of the segment
  60578. * @param segB defines the other point of the segment
  60579. * @returns the shortest distance
  60580. */
  60581. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  60582. }
  60583. /**
  60584. * Classed used to store (x,y,z) vector representation
  60585. * A Vector3 is the main object used in 3D geometry
  60586. * It can represent etiher the coordinates of a point the space, either a direction
  60587. * Reminder: js uses a left handed forward facing system
  60588. */
  60589. export class Vector3 {
  60590. /**
  60591. * Defines the first coordinates (on X axis)
  60592. */
  60593. x: number;
  60594. /**
  60595. * Defines the second coordinates (on Y axis)
  60596. */
  60597. y: number;
  60598. /**
  60599. * Defines the third coordinates (on Z axis)
  60600. */
  60601. z: number;
  60602. private static _UpReadOnly;
  60603. /**
  60604. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  60605. * @param x defines the first coordinates (on X axis)
  60606. * @param y defines the second coordinates (on Y axis)
  60607. * @param z defines the third coordinates (on Z axis)
  60608. */
  60609. constructor(
  60610. /**
  60611. * Defines the first coordinates (on X axis)
  60612. */
  60613. x?: number,
  60614. /**
  60615. * Defines the second coordinates (on Y axis)
  60616. */
  60617. y?: number,
  60618. /**
  60619. * Defines the third coordinates (on Z axis)
  60620. */
  60621. z?: number);
  60622. /**
  60623. * Creates a string representation of the Vector3
  60624. * @returns a string with the Vector3 coordinates.
  60625. */
  60626. toString(): string;
  60627. /**
  60628. * Gets the class name
  60629. * @returns the string "Vector3"
  60630. */
  60631. getClassName(): string;
  60632. /**
  60633. * Creates the Vector3 hash code
  60634. * @returns a number which tends to be unique between Vector3 instances
  60635. */
  60636. getHashCode(): number;
  60637. /**
  60638. * Creates an array containing three elements : the coordinates of the Vector3
  60639. * @returns a new array of numbers
  60640. */
  60641. asArray(): number[];
  60642. /**
  60643. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  60644. * @param array defines the destination array
  60645. * @param index defines the offset in the destination array
  60646. * @returns the current Vector3
  60647. */
  60648. toArray(array: FloatArray, index?: number): Vector3;
  60649. /**
  60650. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  60651. * @returns a new Quaternion object, computed from the Vector3 coordinates
  60652. */
  60653. toQuaternion(): Quaternion;
  60654. /**
  60655. * Adds the given vector to the current Vector3
  60656. * @param otherVector defines the second operand
  60657. * @returns the current updated Vector3
  60658. */
  60659. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60660. /**
  60661. * Adds the given coordinates to the current Vector3
  60662. * @param x defines the x coordinate of the operand
  60663. * @param y defines the y coordinate of the operand
  60664. * @param z defines the z coordinate of the operand
  60665. * @returns the current updated Vector3
  60666. */
  60667. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60668. /**
  60669. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  60670. * @param otherVector defines the second operand
  60671. * @returns the resulting Vector3
  60672. */
  60673. add(otherVector: DeepImmutable<Vector3>): Vector3;
  60674. /**
  60675. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  60676. * @param otherVector defines the second operand
  60677. * @param result defines the Vector3 object where to store the result
  60678. * @returns the current Vector3
  60679. */
  60680. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60681. /**
  60682. * Subtract the given vector from the current Vector3
  60683. * @param otherVector defines the second operand
  60684. * @returns the current updated Vector3
  60685. */
  60686. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60687. /**
  60688. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  60689. * @param otherVector defines the second operand
  60690. * @returns the resulting Vector3
  60691. */
  60692. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  60693. /**
  60694. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  60695. * @param otherVector defines the second operand
  60696. * @param result defines the Vector3 object where to store the result
  60697. * @returns the current Vector3
  60698. */
  60699. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60700. /**
  60701. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  60702. * @param x defines the x coordinate of the operand
  60703. * @param y defines the y coordinate of the operand
  60704. * @param z defines the z coordinate of the operand
  60705. * @returns the resulting Vector3
  60706. */
  60707. subtractFromFloats(x: number, y: number, z: number): Vector3;
  60708. /**
  60709. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  60710. * @param x defines the x coordinate of the operand
  60711. * @param y defines the y coordinate of the operand
  60712. * @param z defines the z coordinate of the operand
  60713. * @param result defines the Vector3 object where to store the result
  60714. * @returns the current Vector3
  60715. */
  60716. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  60717. /**
  60718. * Gets a new Vector3 set with the current Vector3 negated coordinates
  60719. * @returns a new Vector3
  60720. */
  60721. negate(): Vector3;
  60722. /**
  60723. * Multiplies the Vector3 coordinates by the float "scale"
  60724. * @param scale defines the multiplier factor
  60725. * @returns the current updated Vector3
  60726. */
  60727. scaleInPlace(scale: number): Vector3;
  60728. /**
  60729. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  60730. * @param scale defines the multiplier factor
  60731. * @returns a new Vector3
  60732. */
  60733. scale(scale: number): Vector3;
  60734. /**
  60735. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  60736. * @param scale defines the multiplier factor
  60737. * @param result defines the Vector3 object where to store the result
  60738. * @returns the current Vector3
  60739. */
  60740. scaleToRef(scale: number, result: Vector3): Vector3;
  60741. /**
  60742. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  60743. * @param scale defines the scale factor
  60744. * @param result defines the Vector3 object where to store the result
  60745. * @returns the unmodified current Vector3
  60746. */
  60747. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  60748. /**
  60749. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  60750. * @param otherVector defines the second operand
  60751. * @returns true if both vectors are equals
  60752. */
  60753. equals(otherVector: DeepImmutable<Vector3>): boolean;
  60754. /**
  60755. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  60756. * @param otherVector defines the second operand
  60757. * @param epsilon defines the minimal distance to define values as equals
  60758. * @returns true if both vectors are distant less than epsilon
  60759. */
  60760. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  60761. /**
  60762. * Returns true if the current Vector3 coordinates equals the given floats
  60763. * @param x defines the x coordinate of the operand
  60764. * @param y defines the y coordinate of the operand
  60765. * @param z defines the z coordinate of the operand
  60766. * @returns true if both vectors are equals
  60767. */
  60768. equalsToFloats(x: number, y: number, z: number): boolean;
  60769. /**
  60770. * Multiplies the current Vector3 coordinates by the given ones
  60771. * @param otherVector defines the second operand
  60772. * @returns the current updated Vector3
  60773. */
  60774. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60775. /**
  60776. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  60777. * @param otherVector defines the second operand
  60778. * @returns the new Vector3
  60779. */
  60780. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  60781. /**
  60782. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  60783. * @param otherVector defines the second operand
  60784. * @param result defines the Vector3 object where to store the result
  60785. * @returns the current Vector3
  60786. */
  60787. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60788. /**
  60789. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  60790. * @param x defines the x coordinate of the operand
  60791. * @param y defines the y coordinate of the operand
  60792. * @param z defines the z coordinate of the operand
  60793. * @returns the new Vector3
  60794. */
  60795. multiplyByFloats(x: number, y: number, z: number): Vector3;
  60796. /**
  60797. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  60798. * @param otherVector defines the second operand
  60799. * @returns the new Vector3
  60800. */
  60801. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  60802. /**
  60803. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  60804. * @param otherVector defines the second operand
  60805. * @param result defines the Vector3 object where to store the result
  60806. * @returns the current Vector3
  60807. */
  60808. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60809. /**
  60810. * Divides the current Vector3 coordinates by the given ones.
  60811. * @param otherVector defines the second operand
  60812. * @returns the current updated Vector3
  60813. */
  60814. divideInPlace(otherVector: Vector3): Vector3;
  60815. /**
  60816. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  60817. * @param other defines the second operand
  60818. * @returns the current updated Vector3
  60819. */
  60820. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  60821. /**
  60822. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  60823. * @param other defines the second operand
  60824. * @returns the current updated Vector3
  60825. */
  60826. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  60827. /**
  60828. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  60829. * @param x defines the x coordinate of the operand
  60830. * @param y defines the y coordinate of the operand
  60831. * @param z defines the z coordinate of the operand
  60832. * @returns the current updated Vector3
  60833. */
  60834. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60835. /**
  60836. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  60837. * @param x defines the x coordinate of the operand
  60838. * @param y defines the y coordinate of the operand
  60839. * @param z defines the z coordinate of the operand
  60840. * @returns the current updated Vector3
  60841. */
  60842. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60843. /**
  60844. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  60845. * Check if is non uniform within a certain amount of decimal places to account for this
  60846. * @param epsilon the amount the values can differ
  60847. * @returns if the the vector is non uniform to a certain number of decimal places
  60848. */
  60849. isNonUniformWithinEpsilon(epsilon: number): boolean;
  60850. /**
  60851. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  60852. */
  60853. readonly isNonUniform: boolean;
  60854. /**
  60855. * Gets a new Vector3 from current Vector3 floored values
  60856. * @returns a new Vector3
  60857. */
  60858. floor(): Vector3;
  60859. /**
  60860. * Gets a new Vector3 from current Vector3 floored values
  60861. * @returns a new Vector3
  60862. */
  60863. fract(): Vector3;
  60864. /**
  60865. * Gets the length of the Vector3
  60866. * @returns the length of the Vecto3
  60867. */
  60868. length(): number;
  60869. /**
  60870. * Gets the squared length of the Vector3
  60871. * @returns squared length of the Vector3
  60872. */
  60873. lengthSquared(): number;
  60874. /**
  60875. * Normalize the current Vector3.
  60876. * Please note that this is an in place operation.
  60877. * @returns the current updated Vector3
  60878. */
  60879. normalize(): Vector3;
  60880. /**
  60881. * Reorders the x y z properties of the vector in place
  60882. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  60883. * @returns the current updated vector
  60884. */
  60885. reorderInPlace(order: string): this;
  60886. /**
  60887. * Rotates the vector around 0,0,0 by a quaternion
  60888. * @param quaternion the rotation quaternion
  60889. * @param result vector to store the result
  60890. * @returns the resulting vector
  60891. */
  60892. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  60893. /**
  60894. * Rotates a vector around a given point
  60895. * @param quaternion the rotation quaternion
  60896. * @param point the point to rotate around
  60897. * @param result vector to store the result
  60898. * @returns the resulting vector
  60899. */
  60900. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  60901. /**
  60902. * Normalize the current Vector3 with the given input length.
  60903. * Please note that this is an in place operation.
  60904. * @param len the length of the vector
  60905. * @returns the current updated Vector3
  60906. */
  60907. normalizeFromLength(len: number): Vector3;
  60908. /**
  60909. * Normalize the current Vector3 to a new vector
  60910. * @returns the new Vector3
  60911. */
  60912. normalizeToNew(): Vector3;
  60913. /**
  60914. * Normalize the current Vector3 to the reference
  60915. * @param reference define the Vector3 to update
  60916. * @returns the updated Vector3
  60917. */
  60918. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  60919. /**
  60920. * Creates a new Vector3 copied from the current Vector3
  60921. * @returns the new Vector3
  60922. */
  60923. clone(): Vector3;
  60924. /**
  60925. * Copies the given vector coordinates to the current Vector3 ones
  60926. * @param source defines the source Vector3
  60927. * @returns the current updated Vector3
  60928. */
  60929. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  60930. /**
  60931. * Copies the given floats to the current Vector3 coordinates
  60932. * @param x defines the x coordinate of the operand
  60933. * @param y defines the y coordinate of the operand
  60934. * @param z defines the z coordinate of the operand
  60935. * @returns the current updated Vector3
  60936. */
  60937. copyFromFloats(x: number, y: number, z: number): Vector3;
  60938. /**
  60939. * Copies the given floats to the current Vector3 coordinates
  60940. * @param x defines the x coordinate of the operand
  60941. * @param y defines the y coordinate of the operand
  60942. * @param z defines the z coordinate of the operand
  60943. * @returns the current updated Vector3
  60944. */
  60945. set(x: number, y: number, z: number): Vector3;
  60946. /**
  60947. * Copies the given float to the current Vector3 coordinates
  60948. * @param v defines the x, y and z coordinates of the operand
  60949. * @returns the current updated Vector3
  60950. */
  60951. setAll(v: number): Vector3;
  60952. /**
  60953. * Get the clip factor between two vectors
  60954. * @param vector0 defines the first operand
  60955. * @param vector1 defines the second operand
  60956. * @param axis defines the axis to use
  60957. * @param size defines the size along the axis
  60958. * @returns the clip factor
  60959. */
  60960. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  60961. /**
  60962. * Get angle between two vectors
  60963. * @param vector0 angle between vector0 and vector1
  60964. * @param vector1 angle between vector0 and vector1
  60965. * @param normal direction of the normal
  60966. * @return the angle between vector0 and vector1
  60967. */
  60968. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  60969. /**
  60970. * Returns a new Vector3 set from the index "offset" of the given array
  60971. * @param array defines the source array
  60972. * @param offset defines the offset in the source array
  60973. * @returns the new Vector3
  60974. */
  60975. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  60976. /**
  60977. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  60978. * This function is deprecated. Use FromArray instead
  60979. * @param array defines the source array
  60980. * @param offset defines the offset in the source array
  60981. * @returns the new Vector3
  60982. */
  60983. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  60984. /**
  60985. * Sets the given vector "result" with the element values from the index "offset" of the given array
  60986. * @param array defines the source array
  60987. * @param offset defines the offset in the source array
  60988. * @param result defines the Vector3 where to store the result
  60989. */
  60990. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  60991. /**
  60992. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  60993. * This function is deprecated. Use FromArrayToRef instead.
  60994. * @param array defines the source array
  60995. * @param offset defines the offset in the source array
  60996. * @param result defines the Vector3 where to store the result
  60997. */
  60998. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  60999. /**
  61000. * Sets the given vector "result" with the given floats.
  61001. * @param x defines the x coordinate of the source
  61002. * @param y defines the y coordinate of the source
  61003. * @param z defines the z coordinate of the source
  61004. * @param result defines the Vector3 where to store the result
  61005. */
  61006. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  61007. /**
  61008. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  61009. * @returns a new empty Vector3
  61010. */
  61011. static Zero(): Vector3;
  61012. /**
  61013. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  61014. * @returns a new unit Vector3
  61015. */
  61016. static One(): Vector3;
  61017. /**
  61018. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  61019. * @returns a new up Vector3
  61020. */
  61021. static Up(): Vector3;
  61022. /**
  61023. * Gets a up Vector3 that must not be updated
  61024. */
  61025. static readonly UpReadOnly: DeepImmutable<Vector3>;
  61026. /**
  61027. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  61028. * @returns a new down Vector3
  61029. */
  61030. static Down(): Vector3;
  61031. /**
  61032. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  61033. * @returns a new forward Vector3
  61034. */
  61035. static Forward(): Vector3;
  61036. /**
  61037. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  61038. * @returns a new forward Vector3
  61039. */
  61040. static Backward(): Vector3;
  61041. /**
  61042. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  61043. * @returns a new right Vector3
  61044. */
  61045. static Right(): Vector3;
  61046. /**
  61047. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  61048. * @returns a new left Vector3
  61049. */
  61050. static Left(): Vector3;
  61051. /**
  61052. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  61053. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61054. * @param vector defines the Vector3 to transform
  61055. * @param transformation defines the transformation matrix
  61056. * @returns the transformed Vector3
  61057. */
  61058. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61059. /**
  61060. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  61061. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61062. * @param vector defines the Vector3 to transform
  61063. * @param transformation defines the transformation matrix
  61064. * @param result defines the Vector3 where to store the result
  61065. */
  61066. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61067. /**
  61068. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  61069. * This method computes tranformed coordinates only, not transformed direction vectors
  61070. * @param x define the x coordinate of the source vector
  61071. * @param y define the y coordinate of the source vector
  61072. * @param z define the z coordinate of the source vector
  61073. * @param transformation defines the transformation matrix
  61074. * @param result defines the Vector3 where to store the result
  61075. */
  61076. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61077. /**
  61078. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  61079. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61080. * @param vector defines the Vector3 to transform
  61081. * @param transformation defines the transformation matrix
  61082. * @returns the new Vector3
  61083. */
  61084. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61085. /**
  61086. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  61087. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61088. * @param vector defines the Vector3 to transform
  61089. * @param transformation defines the transformation matrix
  61090. * @param result defines the Vector3 where to store the result
  61091. */
  61092. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61093. /**
  61094. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  61095. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61096. * @param x define the x coordinate of the source vector
  61097. * @param y define the y coordinate of the source vector
  61098. * @param z define the z coordinate of the source vector
  61099. * @param transformation defines the transformation matrix
  61100. * @param result defines the Vector3 where to store the result
  61101. */
  61102. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61103. /**
  61104. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  61105. * @param value1 defines the first control point
  61106. * @param value2 defines the second control point
  61107. * @param value3 defines the third control point
  61108. * @param value4 defines the fourth control point
  61109. * @param amount defines the amount on the spline to use
  61110. * @returns the new Vector3
  61111. */
  61112. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  61113. /**
  61114. * 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"
  61115. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61116. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61117. * @param value defines the current value
  61118. * @param min defines the lower range value
  61119. * @param max defines the upper range value
  61120. * @returns the new Vector3
  61121. */
  61122. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  61123. /**
  61124. * 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"
  61125. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61126. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61127. * @param value defines the current value
  61128. * @param min defines the lower range value
  61129. * @param max defines the upper range value
  61130. * @param result defines the Vector3 where to store the result
  61131. */
  61132. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  61133. /**
  61134. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  61135. * @param value1 defines the first control point
  61136. * @param tangent1 defines the first tangent vector
  61137. * @param value2 defines the second control point
  61138. * @param tangent2 defines the second tangent vector
  61139. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  61140. * @returns the new Vector3
  61141. */
  61142. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  61143. /**
  61144. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  61145. * @param start defines the start value
  61146. * @param end defines the end value
  61147. * @param amount max defines amount between both (between 0 and 1)
  61148. * @returns the new Vector3
  61149. */
  61150. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  61151. /**
  61152. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  61153. * @param start defines the start value
  61154. * @param end defines the end value
  61155. * @param amount max defines amount between both (between 0 and 1)
  61156. * @param result defines the Vector3 where to store the result
  61157. */
  61158. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  61159. /**
  61160. * Returns the dot product (float) between the vectors "left" and "right"
  61161. * @param left defines the left operand
  61162. * @param right defines the right operand
  61163. * @returns the dot product
  61164. */
  61165. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  61166. /**
  61167. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  61168. * The cross product is then orthogonal to both "left" and "right"
  61169. * @param left defines the left operand
  61170. * @param right defines the right operand
  61171. * @returns the cross product
  61172. */
  61173. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61174. /**
  61175. * Sets the given vector "result" with the cross product of "left" and "right"
  61176. * The cross product is then orthogonal to both "left" and "right"
  61177. * @param left defines the left operand
  61178. * @param right defines the right operand
  61179. * @param result defines the Vector3 where to store the result
  61180. */
  61181. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  61182. /**
  61183. * Returns a new Vector3 as the normalization of the given vector
  61184. * @param vector defines the Vector3 to normalize
  61185. * @returns the new Vector3
  61186. */
  61187. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  61188. /**
  61189. * Sets the given vector "result" with the normalization of the given first vector
  61190. * @param vector defines the Vector3 to normalize
  61191. * @param result defines the Vector3 where to store the result
  61192. */
  61193. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  61194. /**
  61195. * Project a Vector3 onto screen space
  61196. * @param vector defines the Vector3 to project
  61197. * @param world defines the world matrix to use
  61198. * @param transform defines the transform (view x projection) matrix to use
  61199. * @param viewport defines the screen viewport to use
  61200. * @returns the new Vector3
  61201. */
  61202. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  61203. /** @hidden */
  61204. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  61205. /**
  61206. * Unproject from screen space to object space
  61207. * @param source defines the screen space Vector3 to use
  61208. * @param viewportWidth defines the current width of the viewport
  61209. * @param viewportHeight defines the current height of the viewport
  61210. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61211. * @param transform defines the transform (view x projection) matrix to use
  61212. * @returns the new Vector3
  61213. */
  61214. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  61215. /**
  61216. * Unproject from screen space to object space
  61217. * @param source defines the screen space Vector3 to use
  61218. * @param viewportWidth defines the current width of the viewport
  61219. * @param viewportHeight defines the current height of the viewport
  61220. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61221. * @param view defines the view matrix to use
  61222. * @param projection defines the projection matrix to use
  61223. * @returns the new Vector3
  61224. */
  61225. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  61226. /**
  61227. * Unproject from screen space to object space
  61228. * @param source defines the screen space Vector3 to use
  61229. * @param viewportWidth defines the current width of the viewport
  61230. * @param viewportHeight defines the current height of the viewport
  61231. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61232. * @param view defines the view matrix to use
  61233. * @param projection defines the projection matrix to use
  61234. * @param result defines the Vector3 where to store the result
  61235. */
  61236. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61237. /**
  61238. * Unproject from screen space to object space
  61239. * @param sourceX defines the screen space x coordinate to use
  61240. * @param sourceY defines the screen space y coordinate to use
  61241. * @param sourceZ defines the screen space z coordinate to use
  61242. * @param viewportWidth defines the current width of the viewport
  61243. * @param viewportHeight defines the current height of the viewport
  61244. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61245. * @param view defines the view matrix to use
  61246. * @param projection defines the projection matrix to use
  61247. * @param result defines the Vector3 where to store the result
  61248. */
  61249. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61250. /**
  61251. * Gets the minimal coordinate values between two Vector3
  61252. * @param left defines the first operand
  61253. * @param right defines the second operand
  61254. * @returns the new Vector3
  61255. */
  61256. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61257. /**
  61258. * Gets the maximal coordinate values between two Vector3
  61259. * @param left defines the first operand
  61260. * @param right defines the second operand
  61261. * @returns the new Vector3
  61262. */
  61263. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61264. /**
  61265. * Returns the distance between the vectors "value1" and "value2"
  61266. * @param value1 defines the first operand
  61267. * @param value2 defines the second operand
  61268. * @returns the distance
  61269. */
  61270. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61271. /**
  61272. * Returns the squared distance between the vectors "value1" and "value2"
  61273. * @param value1 defines the first operand
  61274. * @param value2 defines the second operand
  61275. * @returns the squared distance
  61276. */
  61277. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61278. /**
  61279. * Returns a new Vector3 located at the center between "value1" and "value2"
  61280. * @param value1 defines the first operand
  61281. * @param value2 defines the second operand
  61282. * @returns the new Vector3
  61283. */
  61284. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  61285. /**
  61286. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  61287. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  61288. * to something in order to rotate it from its local system to the given target system
  61289. * Note: axis1, axis2 and axis3 are normalized during this operation
  61290. * @param axis1 defines the first axis
  61291. * @param axis2 defines the second axis
  61292. * @param axis3 defines the third axis
  61293. * @returns a new Vector3
  61294. */
  61295. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  61296. /**
  61297. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  61298. * @param axis1 defines the first axis
  61299. * @param axis2 defines the second axis
  61300. * @param axis3 defines the third axis
  61301. * @param ref defines the Vector3 where to store the result
  61302. */
  61303. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  61304. }
  61305. /**
  61306. * Vector4 class created for EulerAngle class conversion to Quaternion
  61307. */
  61308. export class Vector4 {
  61309. /** x value of the vector */
  61310. x: number;
  61311. /** y value of the vector */
  61312. y: number;
  61313. /** z value of the vector */
  61314. z: number;
  61315. /** w value of the vector */
  61316. w: number;
  61317. /**
  61318. * Creates a Vector4 object from the given floats.
  61319. * @param x x value of the vector
  61320. * @param y y value of the vector
  61321. * @param z z value of the vector
  61322. * @param w w value of the vector
  61323. */
  61324. constructor(
  61325. /** x value of the vector */
  61326. x: number,
  61327. /** y value of the vector */
  61328. y: number,
  61329. /** z value of the vector */
  61330. z: number,
  61331. /** w value of the vector */
  61332. w: number);
  61333. /**
  61334. * Returns the string with the Vector4 coordinates.
  61335. * @returns a string containing all the vector values
  61336. */
  61337. toString(): string;
  61338. /**
  61339. * Returns the string "Vector4".
  61340. * @returns "Vector4"
  61341. */
  61342. getClassName(): string;
  61343. /**
  61344. * Returns the Vector4 hash code.
  61345. * @returns a unique hash code
  61346. */
  61347. getHashCode(): number;
  61348. /**
  61349. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  61350. * @returns the resulting array
  61351. */
  61352. asArray(): number[];
  61353. /**
  61354. * Populates the given array from the given index with the Vector4 coordinates.
  61355. * @param array array to populate
  61356. * @param index index of the array to start at (default: 0)
  61357. * @returns the Vector4.
  61358. */
  61359. toArray(array: FloatArray, index?: number): Vector4;
  61360. /**
  61361. * Adds the given vector to the current Vector4.
  61362. * @param otherVector the vector to add
  61363. * @returns the updated Vector4.
  61364. */
  61365. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61366. /**
  61367. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  61368. * @param otherVector the vector to add
  61369. * @returns the resulting vector
  61370. */
  61371. add(otherVector: DeepImmutable<Vector4>): Vector4;
  61372. /**
  61373. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  61374. * @param otherVector the vector to add
  61375. * @param result the vector to store the result
  61376. * @returns the current Vector4.
  61377. */
  61378. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61379. /**
  61380. * Subtract in place the given vector from the current Vector4.
  61381. * @param otherVector the vector to subtract
  61382. * @returns the updated Vector4.
  61383. */
  61384. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61385. /**
  61386. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  61387. * @param otherVector the vector to add
  61388. * @returns the new vector with the result
  61389. */
  61390. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  61391. /**
  61392. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  61393. * @param otherVector the vector to subtract
  61394. * @param result the vector to store the result
  61395. * @returns the current Vector4.
  61396. */
  61397. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61398. /**
  61399. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61400. */
  61401. /**
  61402. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61403. * @param x value to subtract
  61404. * @param y value to subtract
  61405. * @param z value to subtract
  61406. * @param w value to subtract
  61407. * @returns new vector containing the result
  61408. */
  61409. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61410. /**
  61411. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61412. * @param x value to subtract
  61413. * @param y value to subtract
  61414. * @param z value to subtract
  61415. * @param w value to subtract
  61416. * @param result the vector to store the result in
  61417. * @returns the current Vector4.
  61418. */
  61419. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  61420. /**
  61421. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  61422. * @returns a new vector with the negated values
  61423. */
  61424. negate(): Vector4;
  61425. /**
  61426. * Multiplies the current Vector4 coordinates by scale (float).
  61427. * @param scale the number to scale with
  61428. * @returns the updated Vector4.
  61429. */
  61430. scaleInPlace(scale: number): Vector4;
  61431. /**
  61432. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  61433. * @param scale the number to scale with
  61434. * @returns a new vector with the result
  61435. */
  61436. scale(scale: number): Vector4;
  61437. /**
  61438. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  61439. * @param scale the number to scale with
  61440. * @param result a vector to store the result in
  61441. * @returns the current Vector4.
  61442. */
  61443. scaleToRef(scale: number, result: Vector4): Vector4;
  61444. /**
  61445. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  61446. * @param scale defines the scale factor
  61447. * @param result defines the Vector4 object where to store the result
  61448. * @returns the unmodified current Vector4
  61449. */
  61450. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  61451. /**
  61452. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  61453. * @param otherVector the vector to compare against
  61454. * @returns true if they are equal
  61455. */
  61456. equals(otherVector: DeepImmutable<Vector4>): boolean;
  61457. /**
  61458. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  61459. * @param otherVector vector to compare against
  61460. * @param epsilon (Default: very small number)
  61461. * @returns true if they are equal
  61462. */
  61463. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  61464. /**
  61465. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  61466. * @param x x value to compare against
  61467. * @param y y value to compare against
  61468. * @param z z value to compare against
  61469. * @param w w value to compare against
  61470. * @returns true if equal
  61471. */
  61472. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  61473. /**
  61474. * Multiplies in place the current Vector4 by the given one.
  61475. * @param otherVector vector to multiple with
  61476. * @returns the updated Vector4.
  61477. */
  61478. multiplyInPlace(otherVector: Vector4): Vector4;
  61479. /**
  61480. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  61481. * @param otherVector vector to multiple with
  61482. * @returns resulting new vector
  61483. */
  61484. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  61485. /**
  61486. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  61487. * @param otherVector vector to multiple with
  61488. * @param result vector to store the result
  61489. * @returns the current Vector4.
  61490. */
  61491. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61492. /**
  61493. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  61494. * @param x x value multiply with
  61495. * @param y y value multiply with
  61496. * @param z z value multiply with
  61497. * @param w w value multiply with
  61498. * @returns resulting new vector
  61499. */
  61500. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  61501. /**
  61502. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  61503. * @param otherVector vector to devide with
  61504. * @returns resulting new vector
  61505. */
  61506. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  61507. /**
  61508. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  61509. * @param otherVector vector to devide with
  61510. * @param result vector to store the result
  61511. * @returns the current Vector4.
  61512. */
  61513. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61514. /**
  61515. * Divides the current Vector3 coordinates by the given ones.
  61516. * @param otherVector vector to devide with
  61517. * @returns the updated Vector3.
  61518. */
  61519. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61520. /**
  61521. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  61522. * @param other defines the second operand
  61523. * @returns the current updated Vector4
  61524. */
  61525. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  61526. /**
  61527. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  61528. * @param other defines the second operand
  61529. * @returns the current updated Vector4
  61530. */
  61531. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  61532. /**
  61533. * Gets a new Vector4 from current Vector4 floored values
  61534. * @returns a new Vector4
  61535. */
  61536. floor(): Vector4;
  61537. /**
  61538. * Gets a new Vector4 from current Vector3 floored values
  61539. * @returns a new Vector4
  61540. */
  61541. fract(): Vector4;
  61542. /**
  61543. * Returns the Vector4 length (float).
  61544. * @returns the length
  61545. */
  61546. length(): number;
  61547. /**
  61548. * Returns the Vector4 squared length (float).
  61549. * @returns the length squared
  61550. */
  61551. lengthSquared(): number;
  61552. /**
  61553. * Normalizes in place the Vector4.
  61554. * @returns the updated Vector4.
  61555. */
  61556. normalize(): Vector4;
  61557. /**
  61558. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  61559. * @returns this converted to a new vector3
  61560. */
  61561. toVector3(): Vector3;
  61562. /**
  61563. * Returns a new Vector4 copied from the current one.
  61564. * @returns the new cloned vector
  61565. */
  61566. clone(): Vector4;
  61567. /**
  61568. * Updates the current Vector4 with the given one coordinates.
  61569. * @param source the source vector to copy from
  61570. * @returns the updated Vector4.
  61571. */
  61572. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  61573. /**
  61574. * Updates the current Vector4 coordinates with the given floats.
  61575. * @param x float to copy from
  61576. * @param y float to copy from
  61577. * @param z float to copy from
  61578. * @param w float to copy from
  61579. * @returns the updated Vector4.
  61580. */
  61581. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61582. /**
  61583. * Updates the current Vector4 coordinates with the given floats.
  61584. * @param x float to set from
  61585. * @param y float to set from
  61586. * @param z float to set from
  61587. * @param w float to set from
  61588. * @returns the updated Vector4.
  61589. */
  61590. set(x: number, y: number, z: number, w: number): Vector4;
  61591. /**
  61592. * Copies the given float to the current Vector3 coordinates
  61593. * @param v defines the x, y, z and w coordinates of the operand
  61594. * @returns the current updated Vector3
  61595. */
  61596. setAll(v: number): Vector4;
  61597. /**
  61598. * Returns a new Vector4 set from the starting index of the given array.
  61599. * @param array the array to pull values from
  61600. * @param offset the offset into the array to start at
  61601. * @returns the new vector
  61602. */
  61603. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  61604. /**
  61605. * Updates the given vector "result" from the starting index of the given array.
  61606. * @param array the array to pull values from
  61607. * @param offset the offset into the array to start at
  61608. * @param result the vector to store the result in
  61609. */
  61610. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  61611. /**
  61612. * Updates the given vector "result" from the starting index of the given Float32Array.
  61613. * @param array the array to pull values from
  61614. * @param offset the offset into the array to start at
  61615. * @param result the vector to store the result in
  61616. */
  61617. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  61618. /**
  61619. * Updates the given vector "result" coordinates from the given floats.
  61620. * @param x float to set from
  61621. * @param y float to set from
  61622. * @param z float to set from
  61623. * @param w float to set from
  61624. * @param result the vector to the floats in
  61625. */
  61626. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  61627. /**
  61628. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  61629. * @returns the new vector
  61630. */
  61631. static Zero(): Vector4;
  61632. /**
  61633. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  61634. * @returns the new vector
  61635. */
  61636. static One(): Vector4;
  61637. /**
  61638. * Returns a new normalized Vector4 from the given one.
  61639. * @param vector the vector to normalize
  61640. * @returns the vector
  61641. */
  61642. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  61643. /**
  61644. * Updates the given vector "result" from the normalization of the given one.
  61645. * @param vector the vector to normalize
  61646. * @param result the vector to store the result in
  61647. */
  61648. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  61649. /**
  61650. * Returns a vector with the minimum values from the left and right vectors
  61651. * @param left left vector to minimize
  61652. * @param right right vector to minimize
  61653. * @returns a new vector with the minimum of the left and right vector values
  61654. */
  61655. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  61656. /**
  61657. * Returns a vector with the maximum values from the left and right vectors
  61658. * @param left left vector to maximize
  61659. * @param right right vector to maximize
  61660. * @returns a new vector with the maximum of the left and right vector values
  61661. */
  61662. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  61663. /**
  61664. * Returns the distance (float) between the vectors "value1" and "value2".
  61665. * @param value1 value to calulate the distance between
  61666. * @param value2 value to calulate the distance between
  61667. * @return the distance between the two vectors
  61668. */
  61669. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  61670. /**
  61671. * Returns the squared distance (float) between the vectors "value1" and "value2".
  61672. * @param value1 value to calulate the distance between
  61673. * @param value2 value to calulate the distance between
  61674. * @return the distance between the two vectors squared
  61675. */
  61676. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  61677. /**
  61678. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  61679. * @param value1 value to calulate the center between
  61680. * @param value2 value to calulate the center between
  61681. * @return the center between the two vectors
  61682. */
  61683. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  61684. /**
  61685. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  61686. * This methods computes transformed normalized direction vectors only.
  61687. * @param vector the vector to transform
  61688. * @param transformation the transformation matrix to apply
  61689. * @returns the new vector
  61690. */
  61691. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  61692. /**
  61693. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  61694. * This methods computes transformed normalized direction vectors only.
  61695. * @param vector the vector to transform
  61696. * @param transformation the transformation matrix to apply
  61697. * @param result the vector to store the result in
  61698. */
  61699. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  61700. /**
  61701. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  61702. * This methods computes transformed normalized direction vectors only.
  61703. * @param x value to transform
  61704. * @param y value to transform
  61705. * @param z value to transform
  61706. * @param w value to transform
  61707. * @param transformation the transformation matrix to apply
  61708. * @param result the vector to store the results in
  61709. */
  61710. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  61711. /**
  61712. * Creates a new Vector4 from a Vector3
  61713. * @param source defines the source data
  61714. * @param w defines the 4th component (default is 0)
  61715. * @returns a new Vector4
  61716. */
  61717. static FromVector3(source: Vector3, w?: number): Vector4;
  61718. }
  61719. /**
  61720. * Interface for the size containing width and height
  61721. */
  61722. export interface ISize {
  61723. /**
  61724. * Width
  61725. */
  61726. width: number;
  61727. /**
  61728. * Heighht
  61729. */
  61730. height: number;
  61731. }
  61732. /**
  61733. * Size containing widht and height
  61734. */
  61735. export class Size implements ISize {
  61736. /**
  61737. * Width
  61738. */
  61739. width: number;
  61740. /**
  61741. * Height
  61742. */
  61743. height: number;
  61744. /**
  61745. * Creates a Size object from the given width and height (floats).
  61746. * @param width width of the new size
  61747. * @param height height of the new size
  61748. */
  61749. constructor(width: number, height: number);
  61750. /**
  61751. * Returns a string with the Size width and height
  61752. * @returns a string with the Size width and height
  61753. */
  61754. toString(): string;
  61755. /**
  61756. * "Size"
  61757. * @returns the string "Size"
  61758. */
  61759. getClassName(): string;
  61760. /**
  61761. * Returns the Size hash code.
  61762. * @returns a hash code for a unique width and height
  61763. */
  61764. getHashCode(): number;
  61765. /**
  61766. * Updates the current size from the given one.
  61767. * @param src the given size
  61768. */
  61769. copyFrom(src: Size): void;
  61770. /**
  61771. * Updates in place the current Size from the given floats.
  61772. * @param width width of the new size
  61773. * @param height height of the new size
  61774. * @returns the updated Size.
  61775. */
  61776. copyFromFloats(width: number, height: number): Size;
  61777. /**
  61778. * Updates in place the current Size from the given floats.
  61779. * @param width width to set
  61780. * @param height height to set
  61781. * @returns the updated Size.
  61782. */
  61783. set(width: number, height: number): Size;
  61784. /**
  61785. * Multiplies the width and height by numbers
  61786. * @param w factor to multiple the width by
  61787. * @param h factor to multiple the height by
  61788. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  61789. */
  61790. multiplyByFloats(w: number, h: number): Size;
  61791. /**
  61792. * Clones the size
  61793. * @returns a new Size copied from the given one.
  61794. */
  61795. clone(): Size;
  61796. /**
  61797. * True if the current Size and the given one width and height are strictly equal.
  61798. * @param other the other size to compare against
  61799. * @returns True if the current Size and the given one width and height are strictly equal.
  61800. */
  61801. equals(other: Size): boolean;
  61802. /**
  61803. * The surface of the Size : width * height (float).
  61804. */
  61805. readonly surface: number;
  61806. /**
  61807. * Create a new size of zero
  61808. * @returns a new Size set to (0.0, 0.0)
  61809. */
  61810. static Zero(): Size;
  61811. /**
  61812. * Sums the width and height of two sizes
  61813. * @param otherSize size to add to this size
  61814. * @returns a new Size set as the addition result of the current Size and the given one.
  61815. */
  61816. add(otherSize: Size): Size;
  61817. /**
  61818. * Subtracts the width and height of two
  61819. * @param otherSize size to subtract to this size
  61820. * @returns a new Size set as the subtraction result of the given one from the current Size.
  61821. */
  61822. subtract(otherSize: Size): Size;
  61823. /**
  61824. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  61825. * @param start starting size to lerp between
  61826. * @param end end size to lerp between
  61827. * @param amount amount to lerp between the start and end values
  61828. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  61829. */
  61830. static Lerp(start: Size, end: Size, amount: number): Size;
  61831. }
  61832. /**
  61833. * Class used to store quaternion data
  61834. * @see https://en.wikipedia.org/wiki/Quaternion
  61835. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  61836. */
  61837. export class Quaternion {
  61838. /** defines the first component (0 by default) */
  61839. x: number;
  61840. /** defines the second component (0 by default) */
  61841. y: number;
  61842. /** defines the third component (0 by default) */
  61843. z: number;
  61844. /** defines the fourth component (1.0 by default) */
  61845. w: number;
  61846. /**
  61847. * Creates a new Quaternion from the given floats
  61848. * @param x defines the first component (0 by default)
  61849. * @param y defines the second component (0 by default)
  61850. * @param z defines the third component (0 by default)
  61851. * @param w defines the fourth component (1.0 by default)
  61852. */
  61853. constructor(
  61854. /** defines the first component (0 by default) */
  61855. x?: number,
  61856. /** defines the second component (0 by default) */
  61857. y?: number,
  61858. /** defines the third component (0 by default) */
  61859. z?: number,
  61860. /** defines the fourth component (1.0 by default) */
  61861. w?: number);
  61862. /**
  61863. * Gets a string representation for the current quaternion
  61864. * @returns a string with the Quaternion coordinates
  61865. */
  61866. toString(): string;
  61867. /**
  61868. * Gets the class name of the quaternion
  61869. * @returns the string "Quaternion"
  61870. */
  61871. getClassName(): string;
  61872. /**
  61873. * Gets a hash code for this quaternion
  61874. * @returns the quaternion hash code
  61875. */
  61876. getHashCode(): number;
  61877. /**
  61878. * Copy the quaternion to an array
  61879. * @returns a new array populated with 4 elements from the quaternion coordinates
  61880. */
  61881. asArray(): number[];
  61882. /**
  61883. * Check if two quaternions are equals
  61884. * @param otherQuaternion defines the second operand
  61885. * @return true if the current quaternion and the given one coordinates are strictly equals
  61886. */
  61887. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  61888. /**
  61889. * Clone the current quaternion
  61890. * @returns a new quaternion copied from the current one
  61891. */
  61892. clone(): Quaternion;
  61893. /**
  61894. * Copy a quaternion to the current one
  61895. * @param other defines the other quaternion
  61896. * @returns the updated current quaternion
  61897. */
  61898. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  61899. /**
  61900. * Updates the current quaternion with the given float coordinates
  61901. * @param x defines the x coordinate
  61902. * @param y defines the y coordinate
  61903. * @param z defines the z coordinate
  61904. * @param w defines the w coordinate
  61905. * @returns the updated current quaternion
  61906. */
  61907. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  61908. /**
  61909. * Updates the current quaternion from the given float coordinates
  61910. * @param x defines the x coordinate
  61911. * @param y defines the y coordinate
  61912. * @param z defines the z coordinate
  61913. * @param w defines the w coordinate
  61914. * @returns the updated current quaternion
  61915. */
  61916. set(x: number, y: number, z: number, w: number): Quaternion;
  61917. /**
  61918. * Adds two quaternions
  61919. * @param other defines the second operand
  61920. * @returns a new quaternion as the addition result of the given one and the current quaternion
  61921. */
  61922. add(other: DeepImmutable<Quaternion>): Quaternion;
  61923. /**
  61924. * Add a quaternion to the current one
  61925. * @param other defines the quaternion to add
  61926. * @returns the current quaternion
  61927. */
  61928. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  61929. /**
  61930. * Subtract two quaternions
  61931. * @param other defines the second operand
  61932. * @returns a new quaternion as the subtraction result of the given one from the current one
  61933. */
  61934. subtract(other: Quaternion): Quaternion;
  61935. /**
  61936. * Multiplies the current quaternion by a scale factor
  61937. * @param value defines the scale factor
  61938. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  61939. */
  61940. scale(value: number): Quaternion;
  61941. /**
  61942. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  61943. * @param scale defines the scale factor
  61944. * @param result defines the Quaternion object where to store the result
  61945. * @returns the unmodified current quaternion
  61946. */
  61947. scaleToRef(scale: number, result: Quaternion): Quaternion;
  61948. /**
  61949. * Multiplies in place the current quaternion by a scale factor
  61950. * @param value defines the scale factor
  61951. * @returns the current modified quaternion
  61952. */
  61953. scaleInPlace(value: number): Quaternion;
  61954. /**
  61955. * Scale the current quaternion values by a factor and add the result to a given quaternion
  61956. * @param scale defines the scale factor
  61957. * @param result defines the Quaternion object where to store the result
  61958. * @returns the unmodified current quaternion
  61959. */
  61960. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  61961. /**
  61962. * Multiplies two quaternions
  61963. * @param q1 defines the second operand
  61964. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  61965. */
  61966. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  61967. /**
  61968. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  61969. * @param q1 defines the second operand
  61970. * @param result defines the target quaternion
  61971. * @returns the current quaternion
  61972. */
  61973. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  61974. /**
  61975. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  61976. * @param q1 defines the second operand
  61977. * @returns the currentupdated quaternion
  61978. */
  61979. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  61980. /**
  61981. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  61982. * @param ref defines the target quaternion
  61983. * @returns the current quaternion
  61984. */
  61985. conjugateToRef(ref: Quaternion): Quaternion;
  61986. /**
  61987. * Conjugates in place (1-q) the current quaternion
  61988. * @returns the current updated quaternion
  61989. */
  61990. conjugateInPlace(): Quaternion;
  61991. /**
  61992. * Conjugates in place (1-q) the current quaternion
  61993. * @returns a new quaternion
  61994. */
  61995. conjugate(): Quaternion;
  61996. /**
  61997. * Gets length of current quaternion
  61998. * @returns the quaternion length (float)
  61999. */
  62000. length(): number;
  62001. /**
  62002. * Normalize in place the current quaternion
  62003. * @returns the current updated quaternion
  62004. */
  62005. normalize(): Quaternion;
  62006. /**
  62007. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  62008. * @param order is a reserved parameter and is ignore for now
  62009. * @returns a new Vector3 containing the Euler angles
  62010. */
  62011. toEulerAngles(order?: string): Vector3;
  62012. /**
  62013. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  62014. * @param result defines the vector which will be filled with the Euler angles
  62015. * @param order is a reserved parameter and is ignore for now
  62016. * @returns the current unchanged quaternion
  62017. */
  62018. toEulerAnglesToRef(result: Vector3): Quaternion;
  62019. /**
  62020. * Updates the given rotation matrix with the current quaternion values
  62021. * @param result defines the target matrix
  62022. * @returns the current unchanged quaternion
  62023. */
  62024. toRotationMatrix(result: Matrix): Quaternion;
  62025. /**
  62026. * Updates the current quaternion from the given rotation matrix values
  62027. * @param matrix defines the source matrix
  62028. * @returns the current updated quaternion
  62029. */
  62030. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62031. /**
  62032. * Creates a new quaternion from a rotation matrix
  62033. * @param matrix defines the source matrix
  62034. * @returns a new quaternion created from the given rotation matrix values
  62035. */
  62036. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62037. /**
  62038. * Updates the given quaternion with the given rotation matrix values
  62039. * @param matrix defines the source matrix
  62040. * @param result defines the target quaternion
  62041. */
  62042. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  62043. /**
  62044. * Returns the dot product (float) between the quaternions "left" and "right"
  62045. * @param left defines the left operand
  62046. * @param right defines the right operand
  62047. * @returns the dot product
  62048. */
  62049. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  62050. /**
  62051. * Checks if the two quaternions are close to each other
  62052. * @param quat0 defines the first quaternion to check
  62053. * @param quat1 defines the second quaternion to check
  62054. * @returns true if the two quaternions are close to each other
  62055. */
  62056. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  62057. /**
  62058. * Creates an empty quaternion
  62059. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  62060. */
  62061. static Zero(): Quaternion;
  62062. /**
  62063. * Inverse a given quaternion
  62064. * @param q defines the source quaternion
  62065. * @returns a new quaternion as the inverted current quaternion
  62066. */
  62067. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  62068. /**
  62069. * Inverse a given quaternion
  62070. * @param q defines the source quaternion
  62071. * @param result the quaternion the result will be stored in
  62072. * @returns the result quaternion
  62073. */
  62074. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  62075. /**
  62076. * Creates an identity quaternion
  62077. * @returns the identity quaternion
  62078. */
  62079. static Identity(): Quaternion;
  62080. /**
  62081. * Gets a boolean indicating if the given quaternion is identity
  62082. * @param quaternion defines the quaternion to check
  62083. * @returns true if the quaternion is identity
  62084. */
  62085. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  62086. /**
  62087. * Creates a quaternion from a rotation around an axis
  62088. * @param axis defines the axis to use
  62089. * @param angle defines the angle to use
  62090. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  62091. */
  62092. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  62093. /**
  62094. * Creates a rotation around an axis and stores it into the given quaternion
  62095. * @param axis defines the axis to use
  62096. * @param angle defines the angle to use
  62097. * @param result defines the target quaternion
  62098. * @returns the target quaternion
  62099. */
  62100. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  62101. /**
  62102. * Creates a new quaternion from data stored into an array
  62103. * @param array defines the data source
  62104. * @param offset defines the offset in the source array where the data starts
  62105. * @returns a new quaternion
  62106. */
  62107. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  62108. /**
  62109. * Create a quaternion from Euler rotation angles
  62110. * @param x Pitch
  62111. * @param y Yaw
  62112. * @param z Roll
  62113. * @returns the new Quaternion
  62114. */
  62115. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  62116. /**
  62117. * Updates a quaternion from Euler rotation angles
  62118. * @param x Pitch
  62119. * @param y Yaw
  62120. * @param z Roll
  62121. * @param result the quaternion to store the result
  62122. * @returns the updated quaternion
  62123. */
  62124. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  62125. /**
  62126. * Create a quaternion from Euler rotation vector
  62127. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62128. * @returns the new Quaternion
  62129. */
  62130. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  62131. /**
  62132. * Updates a quaternion from Euler rotation vector
  62133. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62134. * @param result the quaternion to store the result
  62135. * @returns the updated quaternion
  62136. */
  62137. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  62138. /**
  62139. * Creates a new quaternion from the given Euler float angles (y, x, z)
  62140. * @param yaw defines the rotation around Y axis
  62141. * @param pitch defines the rotation around X axis
  62142. * @param roll defines the rotation around Z axis
  62143. * @returns the new quaternion
  62144. */
  62145. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  62146. /**
  62147. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  62148. * @param yaw defines the rotation around Y axis
  62149. * @param pitch defines the rotation around X axis
  62150. * @param roll defines the rotation around Z axis
  62151. * @param result defines the target quaternion
  62152. */
  62153. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  62154. /**
  62155. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  62156. * @param alpha defines the rotation around first axis
  62157. * @param beta defines the rotation around second axis
  62158. * @param gamma defines the rotation around third axis
  62159. * @returns the new quaternion
  62160. */
  62161. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  62162. /**
  62163. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  62164. * @param alpha defines the rotation around first axis
  62165. * @param beta defines the rotation around second axis
  62166. * @param gamma defines the rotation around third axis
  62167. * @param result defines the target quaternion
  62168. */
  62169. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  62170. /**
  62171. * 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)
  62172. * @param axis1 defines the first axis
  62173. * @param axis2 defines the second axis
  62174. * @param axis3 defines the third axis
  62175. * @returns the new quaternion
  62176. */
  62177. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  62178. /**
  62179. * 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
  62180. * @param axis1 defines the first axis
  62181. * @param axis2 defines the second axis
  62182. * @param axis3 defines the third axis
  62183. * @param ref defines the target quaternion
  62184. */
  62185. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  62186. /**
  62187. * Interpolates between two quaternions
  62188. * @param left defines first quaternion
  62189. * @param right defines second quaternion
  62190. * @param amount defines the gradient to use
  62191. * @returns the new interpolated quaternion
  62192. */
  62193. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62194. /**
  62195. * Interpolates between two quaternions and stores it into a target quaternion
  62196. * @param left defines first quaternion
  62197. * @param right defines second quaternion
  62198. * @param amount defines the gradient to use
  62199. * @param result defines the target quaternion
  62200. */
  62201. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  62202. /**
  62203. * Interpolate between two quaternions using Hermite interpolation
  62204. * @param value1 defines first quaternion
  62205. * @param tangent1 defines the incoming tangent
  62206. * @param value2 defines second quaternion
  62207. * @param tangent2 defines the outgoing tangent
  62208. * @param amount defines the target quaternion
  62209. * @returns the new interpolated quaternion
  62210. */
  62211. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62212. }
  62213. /**
  62214. * Class used to store matrix data (4x4)
  62215. */
  62216. export class Matrix {
  62217. private static _updateFlagSeed;
  62218. private static _identityReadOnly;
  62219. private _isIdentity;
  62220. private _isIdentityDirty;
  62221. private _isIdentity3x2;
  62222. private _isIdentity3x2Dirty;
  62223. /**
  62224. * Gets the update flag of the matrix which is an unique number for the matrix.
  62225. * It will be incremented every time the matrix data change.
  62226. * You can use it to speed the comparison between two versions of the same matrix.
  62227. */
  62228. updateFlag: number;
  62229. private readonly _m;
  62230. /**
  62231. * Gets the internal data of the matrix
  62232. */
  62233. readonly m: DeepImmutable<Float32Array>;
  62234. /** @hidden */
  62235. _markAsUpdated(): void;
  62236. /** @hidden */
  62237. private _updateIdentityStatus;
  62238. /**
  62239. * Creates an empty matrix (filled with zeros)
  62240. */
  62241. constructor();
  62242. /**
  62243. * Check if the current matrix is identity
  62244. * @returns true is the matrix is the identity matrix
  62245. */
  62246. isIdentity(): boolean;
  62247. /**
  62248. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  62249. * @returns true is the matrix is the identity matrix
  62250. */
  62251. isIdentityAs3x2(): boolean;
  62252. /**
  62253. * Gets the determinant of the matrix
  62254. * @returns the matrix determinant
  62255. */
  62256. determinant(): number;
  62257. /**
  62258. * Returns the matrix as a Float32Array
  62259. * @returns the matrix underlying array
  62260. */
  62261. toArray(): DeepImmutable<Float32Array>;
  62262. /**
  62263. * Returns the matrix as a Float32Array
  62264. * @returns the matrix underlying array.
  62265. */
  62266. asArray(): DeepImmutable<Float32Array>;
  62267. /**
  62268. * Inverts the current matrix in place
  62269. * @returns the current inverted matrix
  62270. */
  62271. invert(): Matrix;
  62272. /**
  62273. * Sets all the matrix elements to zero
  62274. * @returns the current matrix
  62275. */
  62276. reset(): Matrix;
  62277. /**
  62278. * Adds the current matrix with a second one
  62279. * @param other defines the matrix to add
  62280. * @returns a new matrix as the addition of the current matrix and the given one
  62281. */
  62282. add(other: DeepImmutable<Matrix>): Matrix;
  62283. /**
  62284. * Sets the given matrix "result" to the addition of the current matrix and the given one
  62285. * @param other defines the matrix to add
  62286. * @param result defines the target matrix
  62287. * @returns the current matrix
  62288. */
  62289. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62290. /**
  62291. * Adds in place the given matrix to the current matrix
  62292. * @param other defines the second operand
  62293. * @returns the current updated matrix
  62294. */
  62295. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  62296. /**
  62297. * Sets the given matrix to the current inverted Matrix
  62298. * @param other defines the target matrix
  62299. * @returns the unmodified current matrix
  62300. */
  62301. invertToRef(other: Matrix): Matrix;
  62302. /**
  62303. * add a value at the specified position in the current Matrix
  62304. * @param index the index of the value within the matrix. between 0 and 15.
  62305. * @param value the value to be added
  62306. * @returns the current updated matrix
  62307. */
  62308. addAtIndex(index: number, value: number): Matrix;
  62309. /**
  62310. * mutiply the specified position in the current Matrix by a value
  62311. * @param index the index of the value within the matrix. between 0 and 15.
  62312. * @param value the value to be added
  62313. * @returns the current updated matrix
  62314. */
  62315. multiplyAtIndex(index: number, value: number): Matrix;
  62316. /**
  62317. * Inserts the translation vector (using 3 floats) in the current matrix
  62318. * @param x defines the 1st component of the translation
  62319. * @param y defines the 2nd component of the translation
  62320. * @param z defines the 3rd component of the translation
  62321. * @returns the current updated matrix
  62322. */
  62323. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62324. /**
  62325. * Adds the translation vector (using 3 floats) in the current matrix
  62326. * @param x defines the 1st component of the translation
  62327. * @param y defines the 2nd component of the translation
  62328. * @param z defines the 3rd component of the translation
  62329. * @returns the current updated matrix
  62330. */
  62331. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62332. /**
  62333. * Inserts the translation vector in the current matrix
  62334. * @param vector3 defines the translation to insert
  62335. * @returns the current updated matrix
  62336. */
  62337. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  62338. /**
  62339. * Gets the translation value of the current matrix
  62340. * @returns a new Vector3 as the extracted translation from the matrix
  62341. */
  62342. getTranslation(): Vector3;
  62343. /**
  62344. * Fill a Vector3 with the extracted translation from the matrix
  62345. * @param result defines the Vector3 where to store the translation
  62346. * @returns the current matrix
  62347. */
  62348. getTranslationToRef(result: Vector3): Matrix;
  62349. /**
  62350. * Remove rotation and scaling part from the matrix
  62351. * @returns the updated matrix
  62352. */
  62353. removeRotationAndScaling(): Matrix;
  62354. /**
  62355. * Multiply two matrices
  62356. * @param other defines the second operand
  62357. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  62358. */
  62359. multiply(other: DeepImmutable<Matrix>): Matrix;
  62360. /**
  62361. * Copy the current matrix from the given one
  62362. * @param other defines the source matrix
  62363. * @returns the current updated matrix
  62364. */
  62365. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  62366. /**
  62367. * Populates the given array from the starting index with the current matrix values
  62368. * @param array defines the target array
  62369. * @param offset defines the offset in the target array where to start storing values
  62370. * @returns the current matrix
  62371. */
  62372. copyToArray(array: Float32Array, offset?: number): Matrix;
  62373. /**
  62374. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  62375. * @param other defines the second operand
  62376. * @param result defines the matrix where to store the multiplication
  62377. * @returns the current matrix
  62378. */
  62379. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62380. /**
  62381. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  62382. * @param other defines the second operand
  62383. * @param result defines the array where to store the multiplication
  62384. * @param offset defines the offset in the target array where to start storing values
  62385. * @returns the current matrix
  62386. */
  62387. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  62388. /**
  62389. * Check equality between this matrix and a second one
  62390. * @param value defines the second matrix to compare
  62391. * @returns true is the current matrix and the given one values are strictly equal
  62392. */
  62393. equals(value: DeepImmutable<Matrix>): boolean;
  62394. /**
  62395. * Clone the current matrix
  62396. * @returns a new matrix from the current matrix
  62397. */
  62398. clone(): Matrix;
  62399. /**
  62400. * Returns the name of the current matrix class
  62401. * @returns the string "Matrix"
  62402. */
  62403. getClassName(): string;
  62404. /**
  62405. * Gets the hash code of the current matrix
  62406. * @returns the hash code
  62407. */
  62408. getHashCode(): number;
  62409. /**
  62410. * Decomposes the current Matrix into a translation, rotation and scaling components
  62411. * @param scale defines the scale vector3 given as a reference to update
  62412. * @param rotation defines the rotation quaternion given as a reference to update
  62413. * @param translation defines the translation vector3 given as a reference to update
  62414. * @returns true if operation was successful
  62415. */
  62416. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  62417. /**
  62418. * Gets specific row of the matrix
  62419. * @param index defines the number of the row to get
  62420. * @returns the index-th row of the current matrix as a new Vector4
  62421. */
  62422. getRow(index: number): Nullable<Vector4>;
  62423. /**
  62424. * Sets the index-th row of the current matrix to the vector4 values
  62425. * @param index defines the number of the row to set
  62426. * @param row defines the target vector4
  62427. * @returns the updated current matrix
  62428. */
  62429. setRow(index: number, row: Vector4): Matrix;
  62430. /**
  62431. * Compute the transpose of the matrix
  62432. * @returns the new transposed matrix
  62433. */
  62434. transpose(): Matrix;
  62435. /**
  62436. * Compute the transpose of the matrix and store it in a given matrix
  62437. * @param result defines the target matrix
  62438. * @returns the current matrix
  62439. */
  62440. transposeToRef(result: Matrix): Matrix;
  62441. /**
  62442. * Sets the index-th row of the current matrix with the given 4 x float values
  62443. * @param index defines the row index
  62444. * @param x defines the x component to set
  62445. * @param y defines the y component to set
  62446. * @param z defines the z component to set
  62447. * @param w defines the w component to set
  62448. * @returns the updated current matrix
  62449. */
  62450. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  62451. /**
  62452. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  62453. * @param scale defines the scale factor
  62454. * @returns a new matrix
  62455. */
  62456. scale(scale: number): Matrix;
  62457. /**
  62458. * Scale the current matrix values by a factor to a given result matrix
  62459. * @param scale defines the scale factor
  62460. * @param result defines the matrix to store the result
  62461. * @returns the current matrix
  62462. */
  62463. scaleToRef(scale: number, result: Matrix): Matrix;
  62464. /**
  62465. * Scale the current matrix values by a factor and add the result to a given matrix
  62466. * @param scale defines the scale factor
  62467. * @param result defines the Matrix to store the result
  62468. * @returns the current matrix
  62469. */
  62470. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  62471. /**
  62472. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  62473. * @param ref matrix to store the result
  62474. */
  62475. toNormalMatrix(ref: Matrix): void;
  62476. /**
  62477. * Gets only rotation part of the current matrix
  62478. * @returns a new matrix sets to the extracted rotation matrix from the current one
  62479. */
  62480. getRotationMatrix(): Matrix;
  62481. /**
  62482. * Extracts the rotation matrix from the current one and sets it as the given "result"
  62483. * @param result defines the target matrix to store data to
  62484. * @returns the current matrix
  62485. */
  62486. getRotationMatrixToRef(result: Matrix): Matrix;
  62487. /**
  62488. * Toggles model matrix from being right handed to left handed in place and vice versa
  62489. */
  62490. toggleModelMatrixHandInPlace(): void;
  62491. /**
  62492. * Toggles projection matrix from being right handed to left handed in place and vice versa
  62493. */
  62494. toggleProjectionMatrixHandInPlace(): void;
  62495. /**
  62496. * Creates a matrix from an array
  62497. * @param array defines the source array
  62498. * @param offset defines an offset in the source array
  62499. * @returns a new Matrix set from the starting index of the given array
  62500. */
  62501. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  62502. /**
  62503. * Copy the content of an array into a given matrix
  62504. * @param array defines the source array
  62505. * @param offset defines an offset in the source array
  62506. * @param result defines the target matrix
  62507. */
  62508. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  62509. /**
  62510. * Stores an array into a matrix after having multiplied each component by a given factor
  62511. * @param array defines the source array
  62512. * @param offset defines the offset in the source array
  62513. * @param scale defines the scaling factor
  62514. * @param result defines the target matrix
  62515. */
  62516. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  62517. /**
  62518. * Gets an identity matrix that must not be updated
  62519. */
  62520. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  62521. /**
  62522. * Stores a list of values (16) inside a given matrix
  62523. * @param initialM11 defines 1st value of 1st row
  62524. * @param initialM12 defines 2nd value of 1st row
  62525. * @param initialM13 defines 3rd value of 1st row
  62526. * @param initialM14 defines 4th value of 1st row
  62527. * @param initialM21 defines 1st value of 2nd row
  62528. * @param initialM22 defines 2nd value of 2nd row
  62529. * @param initialM23 defines 3rd value of 2nd row
  62530. * @param initialM24 defines 4th value of 2nd row
  62531. * @param initialM31 defines 1st value of 3rd row
  62532. * @param initialM32 defines 2nd value of 3rd row
  62533. * @param initialM33 defines 3rd value of 3rd row
  62534. * @param initialM34 defines 4th value of 3rd row
  62535. * @param initialM41 defines 1st value of 4th row
  62536. * @param initialM42 defines 2nd value of 4th row
  62537. * @param initialM43 defines 3rd value of 4th row
  62538. * @param initialM44 defines 4th value of 4th row
  62539. * @param result defines the target matrix
  62540. */
  62541. 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;
  62542. /**
  62543. * Creates new matrix from a list of values (16)
  62544. * @param initialM11 defines 1st value of 1st row
  62545. * @param initialM12 defines 2nd value of 1st row
  62546. * @param initialM13 defines 3rd value of 1st row
  62547. * @param initialM14 defines 4th value of 1st row
  62548. * @param initialM21 defines 1st value of 2nd row
  62549. * @param initialM22 defines 2nd value of 2nd row
  62550. * @param initialM23 defines 3rd value of 2nd row
  62551. * @param initialM24 defines 4th value of 2nd row
  62552. * @param initialM31 defines 1st value of 3rd row
  62553. * @param initialM32 defines 2nd value of 3rd row
  62554. * @param initialM33 defines 3rd value of 3rd row
  62555. * @param initialM34 defines 4th value of 3rd row
  62556. * @param initialM41 defines 1st value of 4th row
  62557. * @param initialM42 defines 2nd value of 4th row
  62558. * @param initialM43 defines 3rd value of 4th row
  62559. * @param initialM44 defines 4th value of 4th row
  62560. * @returns the new matrix
  62561. */
  62562. 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;
  62563. /**
  62564. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  62565. * @param scale defines the scale vector3
  62566. * @param rotation defines the rotation quaternion
  62567. * @param translation defines the translation vector3
  62568. * @returns a new matrix
  62569. */
  62570. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  62571. /**
  62572. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  62573. * @param scale defines the scale vector3
  62574. * @param rotation defines the rotation quaternion
  62575. * @param translation defines the translation vector3
  62576. * @param result defines the target matrix
  62577. */
  62578. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  62579. /**
  62580. * Creates a new identity matrix
  62581. * @returns a new identity matrix
  62582. */
  62583. static Identity(): Matrix;
  62584. /**
  62585. * Creates a new identity matrix and stores the result in a given matrix
  62586. * @param result defines the target matrix
  62587. */
  62588. static IdentityToRef(result: Matrix): void;
  62589. /**
  62590. * Creates a new zero matrix
  62591. * @returns a new zero matrix
  62592. */
  62593. static Zero(): Matrix;
  62594. /**
  62595. * Creates a new rotation matrix for "angle" radians around the X axis
  62596. * @param angle defines the angle (in radians) to use
  62597. * @return the new matrix
  62598. */
  62599. static RotationX(angle: number): Matrix;
  62600. /**
  62601. * Creates a new matrix as the invert of a given matrix
  62602. * @param source defines the source matrix
  62603. * @returns the new matrix
  62604. */
  62605. static Invert(source: DeepImmutable<Matrix>): Matrix;
  62606. /**
  62607. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  62608. * @param angle defines the angle (in radians) to use
  62609. * @param result defines the target matrix
  62610. */
  62611. static RotationXToRef(angle: number, result: Matrix): void;
  62612. /**
  62613. * Creates a new rotation matrix for "angle" radians around the Y axis
  62614. * @param angle defines the angle (in radians) to use
  62615. * @return the new matrix
  62616. */
  62617. static RotationY(angle: number): Matrix;
  62618. /**
  62619. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  62620. * @param angle defines the angle (in radians) to use
  62621. * @param result defines the target matrix
  62622. */
  62623. static RotationYToRef(angle: number, result: Matrix): void;
  62624. /**
  62625. * Creates a new rotation matrix for "angle" radians around the Z axis
  62626. * @param angle defines the angle (in radians) to use
  62627. * @return the new matrix
  62628. */
  62629. static RotationZ(angle: number): Matrix;
  62630. /**
  62631. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  62632. * @param angle defines the angle (in radians) to use
  62633. * @param result defines the target matrix
  62634. */
  62635. static RotationZToRef(angle: number, result: Matrix): void;
  62636. /**
  62637. * Creates a new rotation matrix for "angle" radians around the given axis
  62638. * @param axis defines the axis to use
  62639. * @param angle defines the angle (in radians) to use
  62640. * @return the new matrix
  62641. */
  62642. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  62643. /**
  62644. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  62645. * @param axis defines the axis to use
  62646. * @param angle defines the angle (in radians) to use
  62647. * @param result defines the target matrix
  62648. */
  62649. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  62650. /**
  62651. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  62652. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  62653. * @param from defines the vector to align
  62654. * @param to defines the vector to align to
  62655. * @param result defines the target matrix
  62656. */
  62657. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  62658. /**
  62659. * Creates a rotation matrix
  62660. * @param yaw defines the yaw angle in radians (Y axis)
  62661. * @param pitch defines the pitch angle in radians (X axis)
  62662. * @param roll defines the roll angle in radians (X axis)
  62663. * @returns the new rotation matrix
  62664. */
  62665. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  62666. /**
  62667. * Creates a rotation matrix and stores it in a given matrix
  62668. * @param yaw defines the yaw angle in radians (Y axis)
  62669. * @param pitch defines the pitch angle in radians (X axis)
  62670. * @param roll defines the roll angle in radians (X axis)
  62671. * @param result defines the target matrix
  62672. */
  62673. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  62674. /**
  62675. * Creates a scaling matrix
  62676. * @param x defines the scale factor on X axis
  62677. * @param y defines the scale factor on Y axis
  62678. * @param z defines the scale factor on Z axis
  62679. * @returns the new matrix
  62680. */
  62681. static Scaling(x: number, y: number, z: number): Matrix;
  62682. /**
  62683. * Creates a scaling matrix and stores it in a given matrix
  62684. * @param x defines the scale factor on X axis
  62685. * @param y defines the scale factor on Y axis
  62686. * @param z defines the scale factor on Z axis
  62687. * @param result defines the target matrix
  62688. */
  62689. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  62690. /**
  62691. * Creates a translation matrix
  62692. * @param x defines the translation on X axis
  62693. * @param y defines the translation on Y axis
  62694. * @param z defines the translationon Z axis
  62695. * @returns the new matrix
  62696. */
  62697. static Translation(x: number, y: number, z: number): Matrix;
  62698. /**
  62699. * Creates a translation matrix and stores it in a given matrix
  62700. * @param x defines the translation on X axis
  62701. * @param y defines the translation on Y axis
  62702. * @param z defines the translationon Z axis
  62703. * @param result defines the target matrix
  62704. */
  62705. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  62706. /**
  62707. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  62708. * @param startValue defines the start value
  62709. * @param endValue defines the end value
  62710. * @param gradient defines the gradient factor
  62711. * @returns the new matrix
  62712. */
  62713. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  62714. /**
  62715. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  62716. * @param startValue defines the start value
  62717. * @param endValue defines the end value
  62718. * @param gradient defines the gradient factor
  62719. * @param result defines the Matrix object where to store data
  62720. */
  62721. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  62722. /**
  62723. * Builds a new matrix whose values are computed by:
  62724. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  62725. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  62726. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  62727. * @param startValue defines the first matrix
  62728. * @param endValue defines the second matrix
  62729. * @param gradient defines the gradient between the two matrices
  62730. * @returns the new matrix
  62731. */
  62732. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  62733. /**
  62734. * Update a matrix to values which are computed by:
  62735. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  62736. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  62737. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  62738. * @param startValue defines the first matrix
  62739. * @param endValue defines the second matrix
  62740. * @param gradient defines the gradient between the two matrices
  62741. * @param result defines the target matrix
  62742. */
  62743. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  62744. /**
  62745. * 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"
  62746. * This function works in left handed mode
  62747. * @param eye defines the final position of the entity
  62748. * @param target defines where the entity should look at
  62749. * @param up defines the up vector for the entity
  62750. * @returns the new matrix
  62751. */
  62752. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  62753. /**
  62754. * 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".
  62755. * This function works in left handed mode
  62756. * @param eye defines the final position of the entity
  62757. * @param target defines where the entity should look at
  62758. * @param up defines the up vector for the entity
  62759. * @param result defines the target matrix
  62760. */
  62761. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  62762. /**
  62763. * 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"
  62764. * This function works in right handed mode
  62765. * @param eye defines the final position of the entity
  62766. * @param target defines where the entity should look at
  62767. * @param up defines the up vector for the entity
  62768. * @returns the new matrix
  62769. */
  62770. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  62771. /**
  62772. * 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".
  62773. * This function works in right handed mode
  62774. * @param eye defines the final position of the entity
  62775. * @param target defines where the entity should look at
  62776. * @param up defines the up vector for the entity
  62777. * @param result defines the target matrix
  62778. */
  62779. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  62780. /**
  62781. * Create a left-handed orthographic projection matrix
  62782. * @param width defines the viewport width
  62783. * @param height defines the viewport height
  62784. * @param znear defines the near clip plane
  62785. * @param zfar defines the far clip plane
  62786. * @returns a new matrix as a left-handed orthographic projection matrix
  62787. */
  62788. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  62789. /**
  62790. * Store a left-handed orthographic projection to a given matrix
  62791. * @param width defines the viewport width
  62792. * @param height defines the viewport height
  62793. * @param znear defines the near clip plane
  62794. * @param zfar defines the far clip plane
  62795. * @param result defines the target matrix
  62796. */
  62797. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  62798. /**
  62799. * Create a left-handed orthographic projection matrix
  62800. * @param left defines the viewport left coordinate
  62801. * @param right defines the viewport right coordinate
  62802. * @param bottom defines the viewport bottom coordinate
  62803. * @param top defines the viewport top coordinate
  62804. * @param znear defines the near clip plane
  62805. * @param zfar defines the far clip plane
  62806. * @returns a new matrix as a left-handed orthographic projection matrix
  62807. */
  62808. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  62809. /**
  62810. * Stores a left-handed orthographic projection into a given matrix
  62811. * @param left defines the viewport left coordinate
  62812. * @param right defines the viewport right coordinate
  62813. * @param bottom defines the viewport bottom coordinate
  62814. * @param top defines the viewport top coordinate
  62815. * @param znear defines the near clip plane
  62816. * @param zfar defines the far clip plane
  62817. * @param result defines the target matrix
  62818. */
  62819. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  62820. /**
  62821. * Creates a right-handed orthographic projection matrix
  62822. * @param left defines the viewport left coordinate
  62823. * @param right defines the viewport right coordinate
  62824. * @param bottom defines the viewport bottom coordinate
  62825. * @param top defines the viewport top coordinate
  62826. * @param znear defines the near clip plane
  62827. * @param zfar defines the far clip plane
  62828. * @returns a new matrix as a right-handed orthographic projection matrix
  62829. */
  62830. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  62831. /**
  62832. * Stores a right-handed orthographic projection into a given matrix
  62833. * @param left defines the viewport left coordinate
  62834. * @param right defines the viewport right coordinate
  62835. * @param bottom defines the viewport bottom coordinate
  62836. * @param top defines the viewport top coordinate
  62837. * @param znear defines the near clip plane
  62838. * @param zfar defines the far clip plane
  62839. * @param result defines the target matrix
  62840. */
  62841. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  62842. /**
  62843. * Creates a left-handed perspective projection matrix
  62844. * @param width defines the viewport width
  62845. * @param height defines the viewport height
  62846. * @param znear defines the near clip plane
  62847. * @param zfar defines the far clip plane
  62848. * @returns a new matrix as a left-handed perspective projection matrix
  62849. */
  62850. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  62851. /**
  62852. * Creates a left-handed perspective projection matrix
  62853. * @param fov defines the horizontal field of view
  62854. * @param aspect defines the aspect ratio
  62855. * @param znear defines the near clip plane
  62856. * @param zfar defines the far clip plane
  62857. * @returns a new matrix as a left-handed perspective projection matrix
  62858. */
  62859. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  62860. /**
  62861. * Stores a left-handed perspective projection into a given matrix
  62862. * @param fov defines the horizontal field of view
  62863. * @param aspect defines the aspect ratio
  62864. * @param znear defines the near clip plane
  62865. * @param zfar defines the far clip plane
  62866. * @param result defines the target matrix
  62867. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  62868. */
  62869. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  62870. /**
  62871. * Creates a right-handed perspective projection matrix
  62872. * @param fov defines the horizontal field of view
  62873. * @param aspect defines the aspect ratio
  62874. * @param znear defines the near clip plane
  62875. * @param zfar defines the far clip plane
  62876. * @returns a new matrix as a right-handed perspective projection matrix
  62877. */
  62878. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  62879. /**
  62880. * Stores a right-handed perspective projection into a given matrix
  62881. * @param fov defines the horizontal field of view
  62882. * @param aspect defines the aspect ratio
  62883. * @param znear defines the near clip plane
  62884. * @param zfar defines the far clip plane
  62885. * @param result defines the target matrix
  62886. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  62887. */
  62888. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  62889. /**
  62890. * Stores a perspective projection for WebVR info a given matrix
  62891. * @param fov defines the field of view
  62892. * @param znear defines the near clip plane
  62893. * @param zfar defines the far clip plane
  62894. * @param result defines the target matrix
  62895. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  62896. */
  62897. static PerspectiveFovWebVRToRef(fov: {
  62898. upDegrees: number;
  62899. downDegrees: number;
  62900. leftDegrees: number;
  62901. rightDegrees: number;
  62902. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  62903. /**
  62904. * Computes a complete transformation matrix
  62905. * @param viewport defines the viewport to use
  62906. * @param world defines the world matrix
  62907. * @param view defines the view matrix
  62908. * @param projection defines the projection matrix
  62909. * @param zmin defines the near clip plane
  62910. * @param zmax defines the far clip plane
  62911. * @returns the transformation matrix
  62912. */
  62913. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  62914. /**
  62915. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  62916. * @param matrix defines the matrix to use
  62917. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  62918. */
  62919. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  62920. /**
  62921. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  62922. * @param matrix defines the matrix to use
  62923. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  62924. */
  62925. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  62926. /**
  62927. * Compute the transpose of a given matrix
  62928. * @param matrix defines the matrix to transpose
  62929. * @returns the new matrix
  62930. */
  62931. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  62932. /**
  62933. * Compute the transpose of a matrix and store it in a target matrix
  62934. * @param matrix defines the matrix to transpose
  62935. * @param result defines the target matrix
  62936. */
  62937. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  62938. /**
  62939. * Computes a reflection matrix from a plane
  62940. * @param plane defines the reflection plane
  62941. * @returns a new matrix
  62942. */
  62943. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  62944. /**
  62945. * Computes a reflection matrix from a plane
  62946. * @param plane defines the reflection plane
  62947. * @param result defines the target matrix
  62948. */
  62949. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  62950. /**
  62951. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  62952. * @param xaxis defines the value of the 1st axis
  62953. * @param yaxis defines the value of the 2nd axis
  62954. * @param zaxis defines the value of the 3rd axis
  62955. * @param result defines the target matrix
  62956. */
  62957. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  62958. /**
  62959. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  62960. * @param quat defines the quaternion to use
  62961. * @param result defines the target matrix
  62962. */
  62963. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  62964. }
  62965. /**
  62966. * Represens a plane by the equation ax + by + cz + d = 0
  62967. */
  62968. export class Plane {
  62969. /**
  62970. * Normal of the plane (a,b,c)
  62971. */
  62972. normal: Vector3;
  62973. /**
  62974. * d component of the plane
  62975. */
  62976. d: number;
  62977. /**
  62978. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  62979. * @param a a component of the plane
  62980. * @param b b component of the plane
  62981. * @param c c component of the plane
  62982. * @param d d component of the plane
  62983. */
  62984. constructor(a: number, b: number, c: number, d: number);
  62985. /**
  62986. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  62987. */
  62988. asArray(): number[];
  62989. /**
  62990. * @returns a new plane copied from the current Plane.
  62991. */
  62992. clone(): Plane;
  62993. /**
  62994. * @returns the string "Plane".
  62995. */
  62996. getClassName(): string;
  62997. /**
  62998. * @returns the Plane hash code.
  62999. */
  63000. getHashCode(): number;
  63001. /**
  63002. * Normalize the current Plane in place.
  63003. * @returns the updated Plane.
  63004. */
  63005. normalize(): Plane;
  63006. /**
  63007. * Applies a transformation the plane and returns the result
  63008. * @param transformation the transformation matrix to be applied to the plane
  63009. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  63010. */
  63011. transform(transformation: DeepImmutable<Matrix>): Plane;
  63012. /**
  63013. * Calcualtte the dot product between the point and the plane normal
  63014. * @param point point to calculate the dot product with
  63015. * @returns the dot product (float) of the point coordinates and the plane normal.
  63016. */
  63017. dotCoordinate(point: DeepImmutable<Vector3>): number;
  63018. /**
  63019. * Updates the current Plane from the plane defined by the three given points.
  63020. * @param point1 one of the points used to contruct the plane
  63021. * @param point2 one of the points used to contruct the plane
  63022. * @param point3 one of the points used to contruct the plane
  63023. * @returns the updated Plane.
  63024. */
  63025. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63026. /**
  63027. * Checks if the plane is facing a given direction
  63028. * @param direction the direction to check if the plane is facing
  63029. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  63030. * @returns True is the vector "direction" is the same side than the plane normal.
  63031. */
  63032. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  63033. /**
  63034. * Calculates the distance to a point
  63035. * @param point point to calculate distance to
  63036. * @returns the signed distance (float) from the given point to the Plane.
  63037. */
  63038. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  63039. /**
  63040. * Creates a plane from an array
  63041. * @param array the array to create a plane from
  63042. * @returns a new Plane from the given array.
  63043. */
  63044. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  63045. /**
  63046. * Creates a plane from three points
  63047. * @param point1 point used to create the plane
  63048. * @param point2 point used to create the plane
  63049. * @param point3 point used to create the plane
  63050. * @returns a new Plane defined by the three given points.
  63051. */
  63052. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63053. /**
  63054. * Creates a plane from an origin point and a normal
  63055. * @param origin origin of the plane to be constructed
  63056. * @param normal normal of the plane to be constructed
  63057. * @returns a new Plane the normal vector to this plane at the given origin point.
  63058. * Note : the vector "normal" is updated because normalized.
  63059. */
  63060. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  63061. /**
  63062. * Calculates the distance from a plane and a point
  63063. * @param origin origin of the plane to be constructed
  63064. * @param normal normal of the plane to be constructed
  63065. * @param point point to calculate distance to
  63066. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  63067. */
  63068. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  63069. }
  63070. /**
  63071. * Class used to represent a viewport on screen
  63072. */
  63073. export class Viewport {
  63074. /** viewport left coordinate */
  63075. x: number;
  63076. /** viewport top coordinate */
  63077. y: number;
  63078. /**viewport width */
  63079. width: number;
  63080. /** viewport height */
  63081. height: number;
  63082. /**
  63083. * Creates a Viewport object located at (x, y) and sized (width, height)
  63084. * @param x defines viewport left coordinate
  63085. * @param y defines viewport top coordinate
  63086. * @param width defines the viewport width
  63087. * @param height defines the viewport height
  63088. */
  63089. constructor(
  63090. /** viewport left coordinate */
  63091. x: number,
  63092. /** viewport top coordinate */
  63093. y: number,
  63094. /**viewport width */
  63095. width: number,
  63096. /** viewport height */
  63097. height: number);
  63098. /**
  63099. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  63100. * @param renderWidth defines the rendering width
  63101. * @param renderHeight defines the rendering height
  63102. * @returns a new Viewport
  63103. */
  63104. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  63105. /**
  63106. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  63107. * @param renderWidth defines the rendering width
  63108. * @param renderHeight defines the rendering height
  63109. * @param ref defines the target viewport
  63110. * @returns the current viewport
  63111. */
  63112. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  63113. /**
  63114. * Returns a new Viewport copied from the current one
  63115. * @returns a new Viewport
  63116. */
  63117. clone(): Viewport;
  63118. }
  63119. /**
  63120. * Reprasents a camera frustum
  63121. */
  63122. export class Frustum {
  63123. /**
  63124. * Gets the planes representing the frustum
  63125. * @param transform matrix to be applied to the returned planes
  63126. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  63127. */
  63128. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  63129. /**
  63130. * Gets the near frustum plane transformed by the transform matrix
  63131. * @param transform transformation matrix to be applied to the resulting frustum plane
  63132. * @param frustumPlane the resuling frustum plane
  63133. */
  63134. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63135. /**
  63136. * Gets the far frustum plane transformed by the transform matrix
  63137. * @param transform transformation matrix to be applied to the resulting frustum plane
  63138. * @param frustumPlane the resuling frustum plane
  63139. */
  63140. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63141. /**
  63142. * Gets the left frustum plane transformed by the transform matrix
  63143. * @param transform transformation matrix to be applied to the resulting frustum plane
  63144. * @param frustumPlane the resuling frustum plane
  63145. */
  63146. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63147. /**
  63148. * Gets the right frustum plane transformed by the transform matrix
  63149. * @param transform transformation matrix to be applied to the resulting frustum plane
  63150. * @param frustumPlane the resuling frustum plane
  63151. */
  63152. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63153. /**
  63154. * Gets the top frustum plane transformed by the transform matrix
  63155. * @param transform transformation matrix to be applied to the resulting frustum plane
  63156. * @param frustumPlane the resuling frustum plane
  63157. */
  63158. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63159. /**
  63160. * Gets the bottom frustum plane transformed by the transform matrix
  63161. * @param transform transformation matrix to be applied to the resulting frustum plane
  63162. * @param frustumPlane the resuling frustum plane
  63163. */
  63164. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63165. /**
  63166. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  63167. * @param transform transformation matrix to be applied to the resulting frustum planes
  63168. * @param frustumPlanes the resuling frustum planes
  63169. */
  63170. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  63171. }
  63172. /** Defines supported spaces */
  63173. export enum Space {
  63174. /** Local (object) space */
  63175. LOCAL = 0,
  63176. /** World space */
  63177. WORLD = 1,
  63178. /** Bone space */
  63179. BONE = 2
  63180. }
  63181. /** Defines the 3 main axes */
  63182. export class Axis {
  63183. /** X axis */
  63184. static X: Vector3;
  63185. /** Y axis */
  63186. static Y: Vector3;
  63187. /** Z axis */
  63188. static Z: Vector3;
  63189. }
  63190. /** Class used to represent a Bezier curve */
  63191. export class BezierCurve {
  63192. /**
  63193. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  63194. * @param t defines the time
  63195. * @param x1 defines the left coordinate on X axis
  63196. * @param y1 defines the left coordinate on Y axis
  63197. * @param x2 defines the right coordinate on X axis
  63198. * @param y2 defines the right coordinate on Y axis
  63199. * @returns the interpolated value
  63200. */
  63201. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  63202. }
  63203. /**
  63204. * Defines potential orientation for back face culling
  63205. */
  63206. export enum Orientation {
  63207. /**
  63208. * Clockwise
  63209. */
  63210. CW = 0,
  63211. /** Counter clockwise */
  63212. CCW = 1
  63213. }
  63214. /**
  63215. * Defines angle representation
  63216. */
  63217. export class Angle {
  63218. private _radians;
  63219. /**
  63220. * Creates an Angle object of "radians" radians (float).
  63221. * @param radians the angle in radians
  63222. */
  63223. constructor(radians: number);
  63224. /**
  63225. * Get value in degrees
  63226. * @returns the Angle value in degrees (float)
  63227. */
  63228. degrees(): number;
  63229. /**
  63230. * Get value in radians
  63231. * @returns the Angle value in radians (float)
  63232. */
  63233. radians(): number;
  63234. /**
  63235. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  63236. * @param a defines first vector
  63237. * @param b defines second vector
  63238. * @returns a new Angle
  63239. */
  63240. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  63241. /**
  63242. * Gets a new Angle object from the given float in radians
  63243. * @param radians defines the angle value in radians
  63244. * @returns a new Angle
  63245. */
  63246. static FromRadians(radians: number): Angle;
  63247. /**
  63248. * Gets a new Angle object from the given float in degrees
  63249. * @param degrees defines the angle value in degrees
  63250. * @returns a new Angle
  63251. */
  63252. static FromDegrees(degrees: number): Angle;
  63253. }
  63254. /**
  63255. * This represents an arc in a 2d space.
  63256. */
  63257. export class Arc2 {
  63258. /** Defines the start point of the arc */
  63259. startPoint: Vector2;
  63260. /** Defines the mid point of the arc */
  63261. midPoint: Vector2;
  63262. /** Defines the end point of the arc */
  63263. endPoint: Vector2;
  63264. /**
  63265. * Defines the center point of the arc.
  63266. */
  63267. centerPoint: Vector2;
  63268. /**
  63269. * Defines the radius of the arc.
  63270. */
  63271. radius: number;
  63272. /**
  63273. * Defines the angle of the arc (from mid point to end point).
  63274. */
  63275. angle: Angle;
  63276. /**
  63277. * Defines the start angle of the arc (from start point to middle point).
  63278. */
  63279. startAngle: Angle;
  63280. /**
  63281. * Defines the orientation of the arc (clock wise/counter clock wise).
  63282. */
  63283. orientation: Orientation;
  63284. /**
  63285. * Creates an Arc object from the three given points : start, middle and end.
  63286. * @param startPoint Defines the start point of the arc
  63287. * @param midPoint Defines the midlle point of the arc
  63288. * @param endPoint Defines the end point of the arc
  63289. */
  63290. constructor(
  63291. /** Defines the start point of the arc */
  63292. startPoint: Vector2,
  63293. /** Defines the mid point of the arc */
  63294. midPoint: Vector2,
  63295. /** Defines the end point of the arc */
  63296. endPoint: Vector2);
  63297. }
  63298. /**
  63299. * Represents a 2D path made up of multiple 2D points
  63300. */
  63301. export class Path2 {
  63302. private _points;
  63303. private _length;
  63304. /**
  63305. * If the path start and end point are the same
  63306. */
  63307. closed: boolean;
  63308. /**
  63309. * Creates a Path2 object from the starting 2D coordinates x and y.
  63310. * @param x the starting points x value
  63311. * @param y the starting points y value
  63312. */
  63313. constructor(x: number, y: number);
  63314. /**
  63315. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  63316. * @param x the added points x value
  63317. * @param y the added points y value
  63318. * @returns the updated Path2.
  63319. */
  63320. addLineTo(x: number, y: number): Path2;
  63321. /**
  63322. * 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.
  63323. * @param midX middle point x value
  63324. * @param midY middle point y value
  63325. * @param endX end point x value
  63326. * @param endY end point y value
  63327. * @param numberOfSegments (default: 36)
  63328. * @returns the updated Path2.
  63329. */
  63330. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  63331. /**
  63332. * Closes the Path2.
  63333. * @returns the Path2.
  63334. */
  63335. close(): Path2;
  63336. /**
  63337. * Gets the sum of the distance between each sequential point in the path
  63338. * @returns the Path2 total length (float).
  63339. */
  63340. length(): number;
  63341. /**
  63342. * Gets the points which construct the path
  63343. * @returns the Path2 internal array of points.
  63344. */
  63345. getPoints(): Vector2[];
  63346. /**
  63347. * Retreives the point at the distance aways from the starting point
  63348. * @param normalizedLengthPosition the length along the path to retreive the point from
  63349. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  63350. */
  63351. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  63352. /**
  63353. * Creates a new path starting from an x and y position
  63354. * @param x starting x value
  63355. * @param y starting y value
  63356. * @returns a new Path2 starting at the coordinates (x, y).
  63357. */
  63358. static StartingAt(x: number, y: number): Path2;
  63359. }
  63360. /**
  63361. * Represents a 3D path made up of multiple 3D points
  63362. */
  63363. export class Path3D {
  63364. /**
  63365. * an array of Vector3, the curve axis of the Path3D
  63366. */
  63367. path: Vector3[];
  63368. private _curve;
  63369. private _distances;
  63370. private _tangents;
  63371. private _normals;
  63372. private _binormals;
  63373. private _raw;
  63374. /**
  63375. * new Path3D(path, normal, raw)
  63376. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  63377. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  63378. * @param path an array of Vector3, the curve axis of the Path3D
  63379. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  63380. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  63381. */
  63382. constructor(
  63383. /**
  63384. * an array of Vector3, the curve axis of the Path3D
  63385. */
  63386. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  63387. /**
  63388. * Returns the Path3D array of successive Vector3 designing its curve.
  63389. * @returns the Path3D array of successive Vector3 designing its curve.
  63390. */
  63391. getCurve(): Vector3[];
  63392. /**
  63393. * Returns an array populated with tangent vectors on each Path3D curve point.
  63394. * @returns an array populated with tangent vectors on each Path3D curve point.
  63395. */
  63396. getTangents(): Vector3[];
  63397. /**
  63398. * Returns an array populated with normal vectors on each Path3D curve point.
  63399. * @returns an array populated with normal vectors on each Path3D curve point.
  63400. */
  63401. getNormals(): Vector3[];
  63402. /**
  63403. * Returns an array populated with binormal vectors on each Path3D curve point.
  63404. * @returns an array populated with binormal vectors on each Path3D curve point.
  63405. */
  63406. getBinormals(): Vector3[];
  63407. /**
  63408. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  63409. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  63410. */
  63411. getDistances(): number[];
  63412. /**
  63413. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  63414. * @param path path which all values are copied into the curves points
  63415. * @param firstNormal which should be projected onto the curve
  63416. * @returns the same object updated.
  63417. */
  63418. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  63419. private _compute;
  63420. private _getFirstNonNullVector;
  63421. private _getLastNonNullVector;
  63422. private _normalVector;
  63423. }
  63424. /**
  63425. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63426. * A Curve3 is designed from a series of successive Vector3.
  63427. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  63428. */
  63429. export class Curve3 {
  63430. private _points;
  63431. private _length;
  63432. /**
  63433. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  63434. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  63435. * @param v1 (Vector3) the control point
  63436. * @param v2 (Vector3) the end point of the Quadratic Bezier
  63437. * @param nbPoints (integer) the wanted number of points in the curve
  63438. * @returns the created Curve3
  63439. */
  63440. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63441. /**
  63442. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  63443. * @param v0 (Vector3) the origin point of the Cubic Bezier
  63444. * @param v1 (Vector3) the first control point
  63445. * @param v2 (Vector3) the second control point
  63446. * @param v3 (Vector3) the end point of the Cubic Bezier
  63447. * @param nbPoints (integer) the wanted number of points in the curve
  63448. * @returns the created Curve3
  63449. */
  63450. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63451. /**
  63452. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  63453. * @param p1 (Vector3) the origin point of the Hermite Spline
  63454. * @param t1 (Vector3) the tangent vector at the origin point
  63455. * @param p2 (Vector3) the end point of the Hermite Spline
  63456. * @param t2 (Vector3) the tangent vector at the end point
  63457. * @param nbPoints (integer) the wanted number of points in the curve
  63458. * @returns the created Curve3
  63459. */
  63460. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63461. /**
  63462. * Returns a Curve3 object along a CatmullRom Spline curve :
  63463. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  63464. * @param nbPoints (integer) the wanted number of points between each curve control points
  63465. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  63466. * @returns the created Curve3
  63467. */
  63468. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  63469. /**
  63470. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63471. * A Curve3 is designed from a series of successive Vector3.
  63472. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  63473. * @param points points which make up the curve
  63474. */
  63475. constructor(points: Vector3[]);
  63476. /**
  63477. * @returns the Curve3 stored array of successive Vector3
  63478. */
  63479. getPoints(): Vector3[];
  63480. /**
  63481. * @returns the computed length (float) of the curve.
  63482. */
  63483. length(): number;
  63484. /**
  63485. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  63486. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  63487. * curveA and curveB keep unchanged.
  63488. * @param curve the curve to continue from this curve
  63489. * @returns the newly constructed curve
  63490. */
  63491. continue(curve: DeepImmutable<Curve3>): Curve3;
  63492. private _computeLength;
  63493. }
  63494. /**
  63495. * Contains position and normal vectors for a vertex
  63496. */
  63497. export class PositionNormalVertex {
  63498. /** the position of the vertex (defaut: 0,0,0) */
  63499. position: Vector3;
  63500. /** the normal of the vertex (defaut: 0,1,0) */
  63501. normal: Vector3;
  63502. /**
  63503. * Creates a PositionNormalVertex
  63504. * @param position the position of the vertex (defaut: 0,0,0)
  63505. * @param normal the normal of the vertex (defaut: 0,1,0)
  63506. */
  63507. constructor(
  63508. /** the position of the vertex (defaut: 0,0,0) */
  63509. position?: Vector3,
  63510. /** the normal of the vertex (defaut: 0,1,0) */
  63511. normal?: Vector3);
  63512. /**
  63513. * Clones the PositionNormalVertex
  63514. * @returns the cloned PositionNormalVertex
  63515. */
  63516. clone(): PositionNormalVertex;
  63517. }
  63518. /**
  63519. * Contains position, normal and uv vectors for a vertex
  63520. */
  63521. export class PositionNormalTextureVertex {
  63522. /** the position of the vertex (defaut: 0,0,0) */
  63523. position: Vector3;
  63524. /** the normal of the vertex (defaut: 0,1,0) */
  63525. normal: Vector3;
  63526. /** the uv of the vertex (default: 0,0) */
  63527. uv: Vector2;
  63528. /**
  63529. * Creates a PositionNormalTextureVertex
  63530. * @param position the position of the vertex (defaut: 0,0,0)
  63531. * @param normal the normal of the vertex (defaut: 0,1,0)
  63532. * @param uv the uv of the vertex (default: 0,0)
  63533. */
  63534. constructor(
  63535. /** the position of the vertex (defaut: 0,0,0) */
  63536. position?: Vector3,
  63537. /** the normal of the vertex (defaut: 0,1,0) */
  63538. normal?: Vector3,
  63539. /** the uv of the vertex (default: 0,0) */
  63540. uv?: Vector2);
  63541. /**
  63542. * Clones the PositionNormalTextureVertex
  63543. * @returns the cloned PositionNormalTextureVertex
  63544. */
  63545. clone(): PositionNormalTextureVertex;
  63546. }
  63547. /**
  63548. * @hidden
  63549. */
  63550. export class Tmp {
  63551. static Color3: Color3[];
  63552. static Color4: Color4[];
  63553. static Vector2: Vector2[];
  63554. static Vector3: Vector3[];
  63555. static Vector4: Vector4[];
  63556. static Quaternion: Quaternion[];
  63557. static Matrix: Matrix[];
  63558. }
  63559. }
  63560. declare module BABYLON {
  63561. /**
  63562. * Class used to enable access to offline support
  63563. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63564. */
  63565. export interface IOfflineProvider {
  63566. /**
  63567. * Gets a boolean indicating if scene must be saved in the database
  63568. */
  63569. enableSceneOffline: boolean;
  63570. /**
  63571. * Gets a boolean indicating if textures must be saved in the database
  63572. */
  63573. enableTexturesOffline: boolean;
  63574. /**
  63575. * Open the offline support and make it available
  63576. * @param successCallback defines the callback to call on success
  63577. * @param errorCallback defines the callback to call on error
  63578. */
  63579. open(successCallback: () => void, errorCallback: () => void): void;
  63580. /**
  63581. * Loads an image from the offline support
  63582. * @param url defines the url to load from
  63583. * @param image defines the target DOM image
  63584. */
  63585. loadImage(url: string, image: HTMLImageElement): void;
  63586. /**
  63587. * Loads a file from offline support
  63588. * @param url defines the URL to load from
  63589. * @param sceneLoaded defines a callback to call on success
  63590. * @param progressCallBack defines a callback to call when progress changed
  63591. * @param errorCallback defines a callback to call on error
  63592. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63593. */
  63594. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63595. }
  63596. }
  63597. declare module BABYLON {
  63598. /**
  63599. * A class serves as a medium between the observable and its observers
  63600. */
  63601. export class EventState {
  63602. /**
  63603. * Create a new EventState
  63604. * @param mask defines the mask associated with this state
  63605. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63606. * @param target defines the original target of the state
  63607. * @param currentTarget defines the current target of the state
  63608. */
  63609. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63610. /**
  63611. * Initialize the current event state
  63612. * @param mask defines the mask associated with this state
  63613. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63614. * @param target defines the original target of the state
  63615. * @param currentTarget defines the current target of the state
  63616. * @returns the current event state
  63617. */
  63618. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  63619. /**
  63620. * An Observer can set this property to true to prevent subsequent observers of being notified
  63621. */
  63622. skipNextObservers: boolean;
  63623. /**
  63624. * Get the mask value that were used to trigger the event corresponding to this EventState object
  63625. */
  63626. mask: number;
  63627. /**
  63628. * The object that originally notified the event
  63629. */
  63630. target?: any;
  63631. /**
  63632. * The current object in the bubbling phase
  63633. */
  63634. currentTarget?: any;
  63635. /**
  63636. * This will be populated with the return value of the last function that was executed.
  63637. * If it is the first function in the callback chain it will be the event data.
  63638. */
  63639. lastReturnValue?: any;
  63640. }
  63641. /**
  63642. * Represent an Observer registered to a given Observable object.
  63643. */
  63644. export class Observer<T> {
  63645. /**
  63646. * Defines the callback to call when the observer is notified
  63647. */
  63648. callback: (eventData: T, eventState: EventState) => void;
  63649. /**
  63650. * Defines the mask of the observer (used to filter notifications)
  63651. */
  63652. mask: number;
  63653. /**
  63654. * Defines the current scope used to restore the JS context
  63655. */
  63656. scope: any;
  63657. /** @hidden */
  63658. _willBeUnregistered: boolean;
  63659. /**
  63660. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  63661. */
  63662. unregisterOnNextCall: boolean;
  63663. /**
  63664. * Creates a new observer
  63665. * @param callback defines the callback to call when the observer is notified
  63666. * @param mask defines the mask of the observer (used to filter notifications)
  63667. * @param scope defines the current scope used to restore the JS context
  63668. */
  63669. constructor(
  63670. /**
  63671. * Defines the callback to call when the observer is notified
  63672. */
  63673. callback: (eventData: T, eventState: EventState) => void,
  63674. /**
  63675. * Defines the mask of the observer (used to filter notifications)
  63676. */
  63677. mask: number,
  63678. /**
  63679. * Defines the current scope used to restore the JS context
  63680. */
  63681. scope?: any);
  63682. }
  63683. /**
  63684. * Represent a list of observers registered to multiple Observables object.
  63685. */
  63686. export class MultiObserver<T> {
  63687. private _observers;
  63688. private _observables;
  63689. /**
  63690. * Release associated resources
  63691. */
  63692. dispose(): void;
  63693. /**
  63694. * Raise a callback when one of the observable will notify
  63695. * @param observables defines a list of observables to watch
  63696. * @param callback defines the callback to call on notification
  63697. * @param mask defines the mask used to filter notifications
  63698. * @param scope defines the current scope used to restore the JS context
  63699. * @returns the new MultiObserver
  63700. */
  63701. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  63702. }
  63703. /**
  63704. * The Observable class is a simple implementation of the Observable pattern.
  63705. *
  63706. * 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.
  63707. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  63708. * 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).
  63709. * 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.
  63710. */
  63711. export class Observable<T> {
  63712. private _observers;
  63713. private _eventState;
  63714. private _onObserverAdded;
  63715. /**
  63716. * Creates a new observable
  63717. * @param onObserverAdded defines a callback to call when a new observer is added
  63718. */
  63719. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  63720. /**
  63721. * Create a new Observer with the specified callback
  63722. * @param callback the callback that will be executed for that Observer
  63723. * @param mask the mask used to filter observers
  63724. * @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.
  63725. * @param scope optional scope for the callback to be called from
  63726. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  63727. * @returns the new observer created for the callback
  63728. */
  63729. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  63730. /**
  63731. * Create a new Observer with the specified callback and unregisters after the next notification
  63732. * @param callback the callback that will be executed for that Observer
  63733. * @returns the new observer created for the callback
  63734. */
  63735. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  63736. /**
  63737. * Remove an Observer from the Observable object
  63738. * @param observer the instance of the Observer to remove
  63739. * @returns false if it doesn't belong to this Observable
  63740. */
  63741. remove(observer: Nullable<Observer<T>>): boolean;
  63742. /**
  63743. * Remove a callback from the Observable object
  63744. * @param callback the callback to remove
  63745. * @param scope optional scope. If used only the callbacks with this scope will be removed
  63746. * @returns false if it doesn't belong to this Observable
  63747. */
  63748. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  63749. private _deferUnregister;
  63750. private _remove;
  63751. /**
  63752. * Moves the observable to the top of the observer list making it get called first when notified
  63753. * @param observer the observer to move
  63754. */
  63755. makeObserverTopPriority(observer: Observer<T>): void;
  63756. /**
  63757. * Moves the observable to the bottom of the observer list making it get called last when notified
  63758. * @param observer the observer to move
  63759. */
  63760. makeObserverBottomPriority(observer: Observer<T>): void;
  63761. /**
  63762. * Notify all Observers by calling their respective callback with the given data
  63763. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  63764. * @param eventData defines the data to send to all observers
  63765. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  63766. * @param target defines the original target of the state
  63767. * @param currentTarget defines the current target of the state
  63768. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  63769. */
  63770. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  63771. /**
  63772. * Calling this will execute each callback, expecting it to be a promise or return a value.
  63773. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  63774. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  63775. * and it is crucial that all callbacks will be executed.
  63776. * The order of the callbacks is kept, callbacks are not executed parallel.
  63777. *
  63778. * @param eventData The data to be sent to each callback
  63779. * @param mask is used to filter observers defaults to -1
  63780. * @param target defines the callback target (see EventState)
  63781. * @param currentTarget defines he current object in the bubbling phase
  63782. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  63783. */
  63784. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  63785. /**
  63786. * Notify a specific observer
  63787. * @param observer defines the observer to notify
  63788. * @param eventData defines the data to be sent to each callback
  63789. * @param mask is used to filter observers defaults to -1
  63790. */
  63791. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  63792. /**
  63793. * Gets a boolean indicating if the observable has at least one observer
  63794. * @returns true is the Observable has at least one Observer registered
  63795. */
  63796. hasObservers(): boolean;
  63797. /**
  63798. * Clear the list of observers
  63799. */
  63800. clear(): void;
  63801. /**
  63802. * Clone the current observable
  63803. * @returns a new observable
  63804. */
  63805. clone(): Observable<T>;
  63806. /**
  63807. * Does this observable handles observer registered with a given mask
  63808. * @param mask defines the mask to be tested
  63809. * @return whether or not one observer registered with the given mask is handeled
  63810. **/
  63811. hasSpecificMask(mask?: number): boolean;
  63812. }
  63813. }
  63814. declare module BABYLON {
  63815. /**
  63816. * Class used to help managing file picking and drag'n'drop
  63817. * File Storage
  63818. */
  63819. export class FilesInputStore {
  63820. /**
  63821. * List of files ready to be loaded
  63822. */
  63823. static FilesToLoad: {
  63824. [key: string]: File;
  63825. };
  63826. }
  63827. }
  63828. declare module BABYLON {
  63829. /** Defines the cross module used constants to avoid circular dependncies */
  63830. export class Constants {
  63831. /** Defines that alpha blending is disabled */
  63832. static readonly ALPHA_DISABLE: number;
  63833. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  63834. static readonly ALPHA_ADD: number;
  63835. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  63836. static readonly ALPHA_COMBINE: number;
  63837. /** Defines that alpha blending to DEST - SRC * DEST */
  63838. static readonly ALPHA_SUBTRACT: number;
  63839. /** Defines that alpha blending to SRC * DEST */
  63840. static readonly ALPHA_MULTIPLY: number;
  63841. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  63842. static readonly ALPHA_MAXIMIZED: number;
  63843. /** Defines that alpha blending to SRC + DEST */
  63844. static readonly ALPHA_ONEONE: number;
  63845. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  63846. static readonly ALPHA_PREMULTIPLIED: number;
  63847. /**
  63848. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  63849. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  63850. */
  63851. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  63852. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  63853. static readonly ALPHA_INTERPOLATE: number;
  63854. /**
  63855. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  63856. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  63857. */
  63858. static readonly ALPHA_SCREENMODE: number;
  63859. /** Defines that the ressource is not delayed*/
  63860. static readonly DELAYLOADSTATE_NONE: number;
  63861. /** Defines that the ressource was successfully delay loaded */
  63862. static readonly DELAYLOADSTATE_LOADED: number;
  63863. /** Defines that the ressource is currently delay loading */
  63864. static readonly DELAYLOADSTATE_LOADING: number;
  63865. /** Defines that the ressource is delayed and has not started loading */
  63866. static readonly DELAYLOADSTATE_NOTLOADED: number;
  63867. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  63868. static readonly NEVER: number;
  63869. /** 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 */
  63870. static readonly ALWAYS: number;
  63871. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  63872. static readonly LESS: number;
  63873. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  63874. static readonly EQUAL: number;
  63875. /** 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 */
  63876. static readonly LEQUAL: number;
  63877. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  63878. static readonly GREATER: number;
  63879. /** 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 */
  63880. static readonly GEQUAL: number;
  63881. /** 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 */
  63882. static readonly NOTEQUAL: number;
  63883. /** Passed to stencilOperation to specify that stencil value must be kept */
  63884. static readonly KEEP: number;
  63885. /** Passed to stencilOperation to specify that stencil value must be replaced */
  63886. static readonly REPLACE: number;
  63887. /** Passed to stencilOperation to specify that stencil value must be incremented */
  63888. static readonly INCR: number;
  63889. /** Passed to stencilOperation to specify that stencil value must be decremented */
  63890. static readonly DECR: number;
  63891. /** Passed to stencilOperation to specify that stencil value must be inverted */
  63892. static readonly INVERT: number;
  63893. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  63894. static readonly INCR_WRAP: number;
  63895. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  63896. static readonly DECR_WRAP: number;
  63897. /** Texture is not repeating outside of 0..1 UVs */
  63898. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  63899. /** Texture is repeating outside of 0..1 UVs */
  63900. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  63901. /** Texture is repeating and mirrored */
  63902. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  63903. /** ALPHA */
  63904. static readonly TEXTUREFORMAT_ALPHA: number;
  63905. /** LUMINANCE */
  63906. static readonly TEXTUREFORMAT_LUMINANCE: number;
  63907. /** LUMINANCE_ALPHA */
  63908. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  63909. /** RGB */
  63910. static readonly TEXTUREFORMAT_RGB: number;
  63911. /** RGBA */
  63912. static readonly TEXTUREFORMAT_RGBA: number;
  63913. /** RED */
  63914. static readonly TEXTUREFORMAT_RED: number;
  63915. /** RED (2nd reference) */
  63916. static readonly TEXTUREFORMAT_R: number;
  63917. /** RG */
  63918. static readonly TEXTUREFORMAT_RG: number;
  63919. /** RED_INTEGER */
  63920. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  63921. /** RED_INTEGER (2nd reference) */
  63922. static readonly TEXTUREFORMAT_R_INTEGER: number;
  63923. /** RG_INTEGER */
  63924. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  63925. /** RGB_INTEGER */
  63926. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  63927. /** RGBA_INTEGER */
  63928. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  63929. /** UNSIGNED_BYTE */
  63930. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  63931. /** UNSIGNED_BYTE (2nd reference) */
  63932. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  63933. /** FLOAT */
  63934. static readonly TEXTURETYPE_FLOAT: number;
  63935. /** HALF_FLOAT */
  63936. static readonly TEXTURETYPE_HALF_FLOAT: number;
  63937. /** BYTE */
  63938. static readonly TEXTURETYPE_BYTE: number;
  63939. /** SHORT */
  63940. static readonly TEXTURETYPE_SHORT: number;
  63941. /** UNSIGNED_SHORT */
  63942. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  63943. /** INT */
  63944. static readonly TEXTURETYPE_INT: number;
  63945. /** UNSIGNED_INT */
  63946. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  63947. /** UNSIGNED_SHORT_4_4_4_4 */
  63948. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  63949. /** UNSIGNED_SHORT_5_5_5_1 */
  63950. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  63951. /** UNSIGNED_SHORT_5_6_5 */
  63952. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  63953. /** UNSIGNED_INT_2_10_10_10_REV */
  63954. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  63955. /** UNSIGNED_INT_24_8 */
  63956. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  63957. /** UNSIGNED_INT_10F_11F_11F_REV */
  63958. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  63959. /** UNSIGNED_INT_5_9_9_9_REV */
  63960. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  63961. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  63962. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63963. /** nearest is mag = nearest and min = nearest and mip = linear */
  63964. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  63965. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63966. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  63967. /** Trilinear is mag = linear and min = linear and mip = linear */
  63968. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  63969. /** nearest is mag = nearest and min = nearest and mip = linear */
  63970. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  63971. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63972. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  63973. /** Trilinear is mag = linear and min = linear and mip = linear */
  63974. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  63975. /** mag = nearest and min = nearest and mip = nearest */
  63976. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  63977. /** mag = nearest and min = linear and mip = nearest */
  63978. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  63979. /** mag = nearest and min = linear and mip = linear */
  63980. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  63981. /** mag = nearest and min = linear and mip = none */
  63982. static readonly TEXTURE_NEAREST_LINEAR: number;
  63983. /** mag = nearest and min = nearest and mip = none */
  63984. static readonly TEXTURE_NEAREST_NEAREST: number;
  63985. /** mag = linear and min = nearest and mip = nearest */
  63986. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  63987. /** mag = linear and min = nearest and mip = linear */
  63988. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  63989. /** mag = linear and min = linear and mip = none */
  63990. static readonly TEXTURE_LINEAR_LINEAR: number;
  63991. /** mag = linear and min = nearest and mip = none */
  63992. static readonly TEXTURE_LINEAR_NEAREST: number;
  63993. /** Explicit coordinates mode */
  63994. static readonly TEXTURE_EXPLICIT_MODE: number;
  63995. /** Spherical coordinates mode */
  63996. static readonly TEXTURE_SPHERICAL_MODE: number;
  63997. /** Planar coordinates mode */
  63998. static readonly TEXTURE_PLANAR_MODE: number;
  63999. /** Cubic coordinates mode */
  64000. static readonly TEXTURE_CUBIC_MODE: number;
  64001. /** Projection coordinates mode */
  64002. static readonly TEXTURE_PROJECTION_MODE: number;
  64003. /** Skybox coordinates mode */
  64004. static readonly TEXTURE_SKYBOX_MODE: number;
  64005. /** Inverse Cubic coordinates mode */
  64006. static readonly TEXTURE_INVCUBIC_MODE: number;
  64007. /** Equirectangular coordinates mode */
  64008. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  64009. /** Equirectangular Fixed coordinates mode */
  64010. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  64011. /** Equirectangular Fixed Mirrored coordinates mode */
  64012. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  64013. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  64014. static readonly SCALEMODE_FLOOR: number;
  64015. /** Defines that texture rescaling will look for the nearest power of 2 size */
  64016. static readonly SCALEMODE_NEAREST: number;
  64017. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  64018. static readonly SCALEMODE_CEILING: number;
  64019. /**
  64020. * The dirty texture flag value
  64021. */
  64022. static readonly MATERIAL_TextureDirtyFlag: number;
  64023. /**
  64024. * The dirty light flag value
  64025. */
  64026. static readonly MATERIAL_LightDirtyFlag: number;
  64027. /**
  64028. * The dirty fresnel flag value
  64029. */
  64030. static readonly MATERIAL_FresnelDirtyFlag: number;
  64031. /**
  64032. * The dirty attribute flag value
  64033. */
  64034. static readonly MATERIAL_AttributesDirtyFlag: number;
  64035. /**
  64036. * The dirty misc flag value
  64037. */
  64038. static readonly MATERIAL_MiscDirtyFlag: number;
  64039. /**
  64040. * The all dirty flag value
  64041. */
  64042. static readonly MATERIAL_AllDirtyFlag: number;
  64043. /**
  64044. * Returns the triangle fill mode
  64045. */
  64046. static readonly MATERIAL_TriangleFillMode: number;
  64047. /**
  64048. * Returns the wireframe mode
  64049. */
  64050. static readonly MATERIAL_WireFrameFillMode: number;
  64051. /**
  64052. * Returns the point fill mode
  64053. */
  64054. static readonly MATERIAL_PointFillMode: number;
  64055. /**
  64056. * Returns the point list draw mode
  64057. */
  64058. static readonly MATERIAL_PointListDrawMode: number;
  64059. /**
  64060. * Returns the line list draw mode
  64061. */
  64062. static readonly MATERIAL_LineListDrawMode: number;
  64063. /**
  64064. * Returns the line loop draw mode
  64065. */
  64066. static readonly MATERIAL_LineLoopDrawMode: number;
  64067. /**
  64068. * Returns the line strip draw mode
  64069. */
  64070. static readonly MATERIAL_LineStripDrawMode: number;
  64071. /**
  64072. * Returns the triangle strip draw mode
  64073. */
  64074. static readonly MATERIAL_TriangleStripDrawMode: number;
  64075. /**
  64076. * Returns the triangle fan draw mode
  64077. */
  64078. static readonly MATERIAL_TriangleFanDrawMode: number;
  64079. /**
  64080. * Stores the clock-wise side orientation
  64081. */
  64082. static readonly MATERIAL_ClockWiseSideOrientation: number;
  64083. /**
  64084. * Stores the counter clock-wise side orientation
  64085. */
  64086. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  64087. /**
  64088. * Nothing
  64089. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64090. */
  64091. static readonly ACTION_NothingTrigger: number;
  64092. /**
  64093. * On pick
  64094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64095. */
  64096. static readonly ACTION_OnPickTrigger: number;
  64097. /**
  64098. * On left pick
  64099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64100. */
  64101. static readonly ACTION_OnLeftPickTrigger: number;
  64102. /**
  64103. * On right pick
  64104. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64105. */
  64106. static readonly ACTION_OnRightPickTrigger: number;
  64107. /**
  64108. * On center pick
  64109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64110. */
  64111. static readonly ACTION_OnCenterPickTrigger: number;
  64112. /**
  64113. * On pick down
  64114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64115. */
  64116. static readonly ACTION_OnPickDownTrigger: number;
  64117. /**
  64118. * On double pick
  64119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64120. */
  64121. static readonly ACTION_OnDoublePickTrigger: number;
  64122. /**
  64123. * On pick up
  64124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64125. */
  64126. static readonly ACTION_OnPickUpTrigger: number;
  64127. /**
  64128. * On pick out.
  64129. * This trigger will only be raised if you also declared a OnPickDown
  64130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64131. */
  64132. static readonly ACTION_OnPickOutTrigger: number;
  64133. /**
  64134. * On long press
  64135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64136. */
  64137. static readonly ACTION_OnLongPressTrigger: number;
  64138. /**
  64139. * On pointer over
  64140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64141. */
  64142. static readonly ACTION_OnPointerOverTrigger: number;
  64143. /**
  64144. * On pointer out
  64145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64146. */
  64147. static readonly ACTION_OnPointerOutTrigger: number;
  64148. /**
  64149. * On every frame
  64150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64151. */
  64152. static readonly ACTION_OnEveryFrameTrigger: number;
  64153. /**
  64154. * On intersection enter
  64155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64156. */
  64157. static readonly ACTION_OnIntersectionEnterTrigger: number;
  64158. /**
  64159. * On intersection exit
  64160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64161. */
  64162. static readonly ACTION_OnIntersectionExitTrigger: number;
  64163. /**
  64164. * On key down
  64165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64166. */
  64167. static readonly ACTION_OnKeyDownTrigger: number;
  64168. /**
  64169. * On key up
  64170. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64171. */
  64172. static readonly ACTION_OnKeyUpTrigger: number;
  64173. /**
  64174. * Billboard mode will only apply to Y axis
  64175. */
  64176. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  64177. /**
  64178. * Billboard mode will apply to all axes
  64179. */
  64180. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  64181. /**
  64182. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  64183. */
  64184. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  64185. /**
  64186. * Gets or sets base Assets URL
  64187. */
  64188. static readonly PARTICLES_BaseAssetsUrl: string;
  64189. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  64190. * Test order :
  64191. * Is the bounding sphere outside the frustum ?
  64192. * If not, are the bounding box vertices outside the frustum ?
  64193. * It not, then the cullable object is in the frustum.
  64194. */
  64195. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  64196. /** Culling strategy : Bounding Sphere Only.
  64197. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  64198. * It's also less accurate than the standard because some not visible objects can still be selected.
  64199. * Test : is the bounding sphere outside the frustum ?
  64200. * If not, then the cullable object is in the frustum.
  64201. */
  64202. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  64203. /** Culling strategy : Optimistic Inclusion.
  64204. * This in an inclusion test first, then the standard exclusion test.
  64205. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  64206. * 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.
  64207. * Anyway, it's as accurate as the standard strategy.
  64208. * Test :
  64209. * Is the cullable object bounding sphere center in the frustum ?
  64210. * If not, apply the default culling strategy.
  64211. */
  64212. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  64213. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  64214. * This in an inclusion test first, then the bounding sphere only exclusion test.
  64215. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  64216. * 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.
  64217. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  64218. * Test :
  64219. * Is the cullable object bounding sphere center in the frustum ?
  64220. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  64221. */
  64222. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  64223. /**
  64224. * No logging while loading
  64225. */
  64226. static readonly SCENELOADER_NO_LOGGING: number;
  64227. /**
  64228. * Minimal logging while loading
  64229. */
  64230. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  64231. /**
  64232. * Summary logging while loading
  64233. */
  64234. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  64235. /**
  64236. * Detailled logging while loading
  64237. */
  64238. static readonly SCENELOADER_DETAILED_LOGGING: number;
  64239. }
  64240. }
  64241. declare module BABYLON {
  64242. /**
  64243. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64244. * Babylon.js
  64245. */
  64246. export class DomManagement {
  64247. /**
  64248. * Checks if the window object exists
  64249. * @returns true if the window object exists
  64250. */
  64251. static IsWindowObjectExist(): boolean;
  64252. /**
  64253. * Extracts text content from a DOM element hierarchy
  64254. * @param element defines the root element
  64255. * @returns a string
  64256. */
  64257. static GetDOMTextContent(element: HTMLElement): string;
  64258. }
  64259. }
  64260. declare module BABYLON {
  64261. /**
  64262. * Logger used througouht the application to allow configuration of
  64263. * the log level required for the messages.
  64264. */
  64265. export class Logger {
  64266. /**
  64267. * No log
  64268. */
  64269. static readonly NoneLogLevel: number;
  64270. /**
  64271. * Only message logs
  64272. */
  64273. static readonly MessageLogLevel: number;
  64274. /**
  64275. * Only warning logs
  64276. */
  64277. static readonly WarningLogLevel: number;
  64278. /**
  64279. * Only error logs
  64280. */
  64281. static readonly ErrorLogLevel: number;
  64282. /**
  64283. * All logs
  64284. */
  64285. static readonly AllLogLevel: number;
  64286. private static _LogCache;
  64287. /**
  64288. * Gets a value indicating the number of loading errors
  64289. * @ignorenaming
  64290. */
  64291. static errorsCount: number;
  64292. /**
  64293. * Callback called when a new log is added
  64294. */
  64295. static OnNewCacheEntry: (entry: string) => void;
  64296. private static _AddLogEntry;
  64297. private static _FormatMessage;
  64298. private static _LogDisabled;
  64299. private static _LogEnabled;
  64300. private static _WarnDisabled;
  64301. private static _WarnEnabled;
  64302. private static _ErrorDisabled;
  64303. private static _ErrorEnabled;
  64304. /**
  64305. * Log a message to the console
  64306. */
  64307. static Log: (message: string) => void;
  64308. /**
  64309. * Write a warning message to the console
  64310. */
  64311. static Warn: (message: string) => void;
  64312. /**
  64313. * Write an error message to the console
  64314. */
  64315. static Error: (message: string) => void;
  64316. /**
  64317. * Gets current log cache (list of logs)
  64318. */
  64319. static readonly LogCache: string;
  64320. /**
  64321. * Clears the log cache
  64322. */
  64323. static ClearLogCache(): void;
  64324. /**
  64325. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64326. */
  64327. static LogLevels: number;
  64328. }
  64329. }
  64330. declare module BABYLON {
  64331. /** @hidden */
  64332. export class _TypeStore {
  64333. /** @hidden */
  64334. static RegisteredTypes: {
  64335. [key: string]: Object;
  64336. };
  64337. /** @hidden */
  64338. static GetClass(fqdn: string): any;
  64339. }
  64340. }
  64341. declare module BABYLON {
  64342. /**
  64343. * Class containing a set of static utilities functions for deep copy.
  64344. */
  64345. export class DeepCopier {
  64346. /**
  64347. * Tries to copy an object by duplicating every property
  64348. * @param source defines the source object
  64349. * @param destination defines the target object
  64350. * @param doNotCopyList defines a list of properties to avoid
  64351. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64352. */
  64353. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64354. }
  64355. }
  64356. declare module BABYLON {
  64357. /**
  64358. * Class containing a set of static utilities functions for precision date
  64359. */
  64360. export class PrecisionDate {
  64361. /**
  64362. * Gets either window.performance.now() if supported or Date.now() else
  64363. */
  64364. static readonly Now: number;
  64365. }
  64366. }
  64367. declare module BABYLON {
  64368. /** @hidden */
  64369. export class _DevTools {
  64370. static WarnImport(name: string): string;
  64371. }
  64372. }
  64373. declare module BABYLON {
  64374. /**
  64375. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64376. */
  64377. export class WebRequest {
  64378. private _xhr;
  64379. /**
  64380. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64381. * i.e. when loading files, where the server/service expects an Authorization header
  64382. */
  64383. static CustomRequestHeaders: {
  64384. [key: string]: string;
  64385. };
  64386. /**
  64387. * Add callback functions in this array to update all the requests before they get sent to the network
  64388. */
  64389. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  64390. private _injectCustomRequestHeaders;
  64391. /**
  64392. * Gets or sets a function to be called when loading progress changes
  64393. */
  64394. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64395. /**
  64396. * Returns client's state
  64397. */
  64398. readonly readyState: number;
  64399. /**
  64400. * Returns client's status
  64401. */
  64402. readonly status: number;
  64403. /**
  64404. * Returns client's status as a text
  64405. */
  64406. readonly statusText: string;
  64407. /**
  64408. * Returns client's response
  64409. */
  64410. readonly response: any;
  64411. /**
  64412. * Returns client's response url
  64413. */
  64414. readonly responseURL: string;
  64415. /**
  64416. * Returns client's response as text
  64417. */
  64418. readonly responseText: string;
  64419. /**
  64420. * Gets or sets the expected response type
  64421. */
  64422. responseType: XMLHttpRequestResponseType;
  64423. /** @hidden */
  64424. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64425. /** @hidden */
  64426. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64427. /**
  64428. * Cancels any network activity
  64429. */
  64430. abort(): void;
  64431. /**
  64432. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64433. * @param body defines an optional request body
  64434. */
  64435. send(body?: Document | BodyInit | null): void;
  64436. /**
  64437. * Sets the request method, request URL
  64438. * @param method defines the method to use (GET, POST, etc..)
  64439. * @param url defines the url to connect with
  64440. */
  64441. open(method: string, url: string): void;
  64442. }
  64443. }
  64444. declare module BABYLON {
  64445. /**
  64446. * Class used to evalaute queries containing `and` and `or` operators
  64447. */
  64448. export class AndOrNotEvaluator {
  64449. /**
  64450. * Evaluate a query
  64451. * @param query defines the query to evaluate
  64452. * @param evaluateCallback defines the callback used to filter result
  64453. * @returns true if the query matches
  64454. */
  64455. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  64456. private static _HandleParenthesisContent;
  64457. private static _SimplifyNegation;
  64458. }
  64459. }
  64460. declare module BABYLON {
  64461. /**
  64462. * Class used to store custom tags
  64463. */
  64464. export class Tags {
  64465. /**
  64466. * Adds support for tags on the given object
  64467. * @param obj defines the object to use
  64468. */
  64469. static EnableFor(obj: any): void;
  64470. /**
  64471. * Removes tags support
  64472. * @param obj defines the object to use
  64473. */
  64474. static DisableFor(obj: any): void;
  64475. /**
  64476. * Gets a boolean indicating if the given object has tags
  64477. * @param obj defines the object to use
  64478. * @returns a boolean
  64479. */
  64480. static HasTags(obj: any): boolean;
  64481. /**
  64482. * Gets the tags available on a given object
  64483. * @param obj defines the object to use
  64484. * @param asString defines if the tags must be returned as a string instead of an array of strings
  64485. * @returns the tags
  64486. */
  64487. static GetTags(obj: any, asString?: boolean): any;
  64488. /**
  64489. * Adds tags to an object
  64490. * @param obj defines the object to use
  64491. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  64492. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  64493. */
  64494. static AddTagsTo(obj: any, tagsString: string): void;
  64495. /**
  64496. * @hidden
  64497. */
  64498. static _AddTagTo(obj: any, tag: string): void;
  64499. /**
  64500. * Removes specific tags from a specific object
  64501. * @param obj defines the object to use
  64502. * @param tagsString defines the tags to remove
  64503. */
  64504. static RemoveTagsFrom(obj: any, tagsString: string): void;
  64505. /**
  64506. * @hidden
  64507. */
  64508. static _RemoveTagFrom(obj: any, tag: string): void;
  64509. /**
  64510. * Defines if tags hosted on an object match a given query
  64511. * @param obj defines the object to use
  64512. * @param tagsQuery defines the tag query
  64513. * @returns a boolean
  64514. */
  64515. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  64516. }
  64517. }
  64518. declare module BABYLON {
  64519. /**
  64520. * Manages the defines for the Material
  64521. */
  64522. export class MaterialDefines {
  64523. private _keys;
  64524. private _isDirty;
  64525. /** @hidden */
  64526. _renderId: number;
  64527. /** @hidden */
  64528. _areLightsDirty: boolean;
  64529. /** @hidden */
  64530. _areAttributesDirty: boolean;
  64531. /** @hidden */
  64532. _areTexturesDirty: boolean;
  64533. /** @hidden */
  64534. _areFresnelDirty: boolean;
  64535. /** @hidden */
  64536. _areMiscDirty: boolean;
  64537. /** @hidden */
  64538. _areImageProcessingDirty: boolean;
  64539. /** @hidden */
  64540. _normals: boolean;
  64541. /** @hidden */
  64542. _uvs: boolean;
  64543. /** @hidden */
  64544. _needNormals: boolean;
  64545. /** @hidden */
  64546. _needUVs: boolean;
  64547. /**
  64548. * Specifies if the material needs to be re-calculated
  64549. */
  64550. readonly isDirty: boolean;
  64551. /**
  64552. * Marks the material to indicate that it has been re-calculated
  64553. */
  64554. markAsProcessed(): void;
  64555. /**
  64556. * Marks the material to indicate that it needs to be re-calculated
  64557. */
  64558. markAsUnprocessed(): void;
  64559. /**
  64560. * Marks the material to indicate all of its defines need to be re-calculated
  64561. */
  64562. markAllAsDirty(): void;
  64563. /**
  64564. * Marks the material to indicate that image processing needs to be re-calculated
  64565. */
  64566. markAsImageProcessingDirty(): void;
  64567. /**
  64568. * Marks the material to indicate the lights need to be re-calculated
  64569. */
  64570. markAsLightDirty(): void;
  64571. /**
  64572. * Marks the attribute state as changed
  64573. */
  64574. markAsAttributesDirty(): void;
  64575. /**
  64576. * Marks the texture state as changed
  64577. */
  64578. markAsTexturesDirty(): void;
  64579. /**
  64580. * Marks the fresnel state as changed
  64581. */
  64582. markAsFresnelDirty(): void;
  64583. /**
  64584. * Marks the misc state as changed
  64585. */
  64586. markAsMiscDirty(): void;
  64587. /**
  64588. * Rebuilds the material defines
  64589. */
  64590. rebuild(): void;
  64591. /**
  64592. * Specifies if two material defines are equal
  64593. * @param other - A material define instance to compare to
  64594. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  64595. */
  64596. isEqual(other: MaterialDefines): boolean;
  64597. /**
  64598. * Clones this instance's defines to another instance
  64599. * @param other - material defines to clone values to
  64600. */
  64601. cloneTo(other: MaterialDefines): void;
  64602. /**
  64603. * Resets the material define values
  64604. */
  64605. reset(): void;
  64606. /**
  64607. * Converts the material define values to a string
  64608. * @returns - String of material define information
  64609. */
  64610. toString(): string;
  64611. }
  64612. }
  64613. declare module BABYLON {
  64614. /**
  64615. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  64616. */
  64617. export class PerformanceMonitor {
  64618. private _enabled;
  64619. private _rollingFrameTime;
  64620. private _lastFrameTimeMs;
  64621. /**
  64622. * constructor
  64623. * @param frameSampleSize The number of samples required to saturate the sliding window
  64624. */
  64625. constructor(frameSampleSize?: number);
  64626. /**
  64627. * Samples current frame
  64628. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  64629. */
  64630. sampleFrame(timeMs?: number): void;
  64631. /**
  64632. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64633. */
  64634. readonly averageFrameTime: number;
  64635. /**
  64636. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64637. */
  64638. readonly averageFrameTimeVariance: number;
  64639. /**
  64640. * Returns the frame time of the most recent frame
  64641. */
  64642. readonly instantaneousFrameTime: number;
  64643. /**
  64644. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  64645. */
  64646. readonly averageFPS: number;
  64647. /**
  64648. * Returns the average framerate in frames per second using the most recent frame time
  64649. */
  64650. readonly instantaneousFPS: number;
  64651. /**
  64652. * Returns true if enough samples have been taken to completely fill the sliding window
  64653. */
  64654. readonly isSaturated: boolean;
  64655. /**
  64656. * Enables contributions to the sliding window sample set
  64657. */
  64658. enable(): void;
  64659. /**
  64660. * Disables contributions to the sliding window sample set
  64661. * Samples will not be interpolated over the disabled period
  64662. */
  64663. disable(): void;
  64664. /**
  64665. * Returns true if sampling is enabled
  64666. */
  64667. readonly isEnabled: boolean;
  64668. /**
  64669. * Resets performance monitor
  64670. */
  64671. reset(): void;
  64672. }
  64673. /**
  64674. * RollingAverage
  64675. *
  64676. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  64677. */
  64678. export class RollingAverage {
  64679. /**
  64680. * Current average
  64681. */
  64682. average: number;
  64683. /**
  64684. * Current variance
  64685. */
  64686. variance: number;
  64687. protected _samples: Array<number>;
  64688. protected _sampleCount: number;
  64689. protected _pos: number;
  64690. protected _m2: number;
  64691. /**
  64692. * constructor
  64693. * @param length The number of samples required to saturate the sliding window
  64694. */
  64695. constructor(length: number);
  64696. /**
  64697. * Adds a sample to the sample set
  64698. * @param v The sample value
  64699. */
  64700. add(v: number): void;
  64701. /**
  64702. * Returns previously added values or null if outside of history or outside the sliding window domain
  64703. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  64704. * @return Value previously recorded with add() or null if outside of range
  64705. */
  64706. history(i: number): number;
  64707. /**
  64708. * Returns true if enough samples have been taken to completely fill the sliding window
  64709. * @return true if sample-set saturated
  64710. */
  64711. isSaturated(): boolean;
  64712. /**
  64713. * Resets the rolling average (equivalent to 0 samples taken so far)
  64714. */
  64715. reset(): void;
  64716. /**
  64717. * Wraps a value around the sample range boundaries
  64718. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  64719. * @return Wrapped position in sample range
  64720. */
  64721. protected _wrapPosition(i: number): number;
  64722. }
  64723. }
  64724. declare module BABYLON {
  64725. /**
  64726. * This class implement a typical dictionary using a string as key and the generic type T as value.
  64727. * The underlying implementation relies on an associative array to ensure the best performances.
  64728. * The value can be anything including 'null' but except 'undefined'
  64729. */
  64730. export class StringDictionary<T> {
  64731. /**
  64732. * This will clear this dictionary and copy the content from the 'source' one.
  64733. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  64734. * @param source the dictionary to take the content from and copy to this dictionary
  64735. */
  64736. copyFrom(source: StringDictionary<T>): void;
  64737. /**
  64738. * Get a value based from its key
  64739. * @param key the given key to get the matching value from
  64740. * @return the value if found, otherwise undefined is returned
  64741. */
  64742. get(key: string): T | undefined;
  64743. /**
  64744. * Get a value from its key or add it if it doesn't exist.
  64745. * This method will ensure you that a given key/data will be present in the dictionary.
  64746. * @param key the given key to get the matching value from
  64747. * @param factory the factory that will create the value if the key is not present in the dictionary.
  64748. * The factory will only be invoked if there's no data for the given key.
  64749. * @return the value corresponding to the key.
  64750. */
  64751. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  64752. /**
  64753. * Get a value from its key if present in the dictionary otherwise add it
  64754. * @param key the key to get the value from
  64755. * @param val if there's no such key/value pair in the dictionary add it with this value
  64756. * @return the value corresponding to the key
  64757. */
  64758. getOrAdd(key: string, val: T): T;
  64759. /**
  64760. * Check if there's a given key in the dictionary
  64761. * @param key the key to check for
  64762. * @return true if the key is present, false otherwise
  64763. */
  64764. contains(key: string): boolean;
  64765. /**
  64766. * Add a new key and its corresponding value
  64767. * @param key the key to add
  64768. * @param value the value corresponding to the key
  64769. * @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
  64770. */
  64771. add(key: string, value: T): boolean;
  64772. /**
  64773. * Update a specific value associated to a key
  64774. * @param key defines the key to use
  64775. * @param value defines the value to store
  64776. * @returns true if the value was updated (or false if the key was not found)
  64777. */
  64778. set(key: string, value: T): boolean;
  64779. /**
  64780. * Get the element of the given key and remove it from the dictionary
  64781. * @param key defines the key to search
  64782. * @returns the value associated with the key or null if not found
  64783. */
  64784. getAndRemove(key: string): Nullable<T>;
  64785. /**
  64786. * Remove a key/value from the dictionary.
  64787. * @param key the key to remove
  64788. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  64789. */
  64790. remove(key: string): boolean;
  64791. /**
  64792. * Clear the whole content of the dictionary
  64793. */
  64794. clear(): void;
  64795. /**
  64796. * Gets the current count
  64797. */
  64798. readonly count: number;
  64799. /**
  64800. * Execute a callback on each key/val of the dictionary.
  64801. * Note that you can remove any element in this dictionary in the callback implementation
  64802. * @param callback the callback to execute on a given key/value pair
  64803. */
  64804. forEach(callback: (key: string, val: T) => void): void;
  64805. /**
  64806. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  64807. * If the callback returns null or undefined the method will iterate to the next key/value pair
  64808. * Note that you can remove any element in this dictionary in the callback implementation
  64809. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  64810. * @returns the first item
  64811. */
  64812. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  64813. private _count;
  64814. private _data;
  64815. }
  64816. }
  64817. declare module BABYLON {
  64818. /**
  64819. * Helper class that provides a small promise polyfill
  64820. */
  64821. export class PromisePolyfill {
  64822. /**
  64823. * Static function used to check if the polyfill is required
  64824. * If this is the case then the function will inject the polyfill to window.Promise
  64825. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  64826. */
  64827. static Apply(force?: boolean): void;
  64828. }
  64829. }
  64830. declare module BABYLON {
  64831. /**
  64832. * Class used to store data that will be store in GPU memory
  64833. */
  64834. export class Buffer {
  64835. private _engine;
  64836. private _buffer;
  64837. /** @hidden */
  64838. _data: Nullable<DataArray>;
  64839. private _updatable;
  64840. private _instanced;
  64841. /**
  64842. * Gets the byte stride.
  64843. */
  64844. readonly byteStride: number;
  64845. /**
  64846. * Constructor
  64847. * @param engine the engine
  64848. * @param data the data to use for this buffer
  64849. * @param updatable whether the data is updatable
  64850. * @param stride the stride (optional)
  64851. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64852. * @param instanced whether the buffer is instanced (optional)
  64853. * @param useBytes set to true if the stride in in bytes (optional)
  64854. */
  64855. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  64856. /**
  64857. * Create a new VertexBuffer based on the current buffer
  64858. * @param kind defines the vertex buffer kind (position, normal, etc.)
  64859. * @param offset defines offset in the buffer (0 by default)
  64860. * @param size defines the size in floats of attributes (position is 3 for instance)
  64861. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  64862. * @param instanced defines if the vertex buffer contains indexed data
  64863. * @param useBytes defines if the offset and stride are in bytes
  64864. * @returns the new vertex buffer
  64865. */
  64866. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  64867. /**
  64868. * Gets a boolean indicating if the Buffer is updatable?
  64869. * @returns true if the buffer is updatable
  64870. */
  64871. isUpdatable(): boolean;
  64872. /**
  64873. * Gets current buffer's data
  64874. * @returns a DataArray or null
  64875. */
  64876. getData(): Nullable<DataArray>;
  64877. /**
  64878. * Gets underlying native buffer
  64879. * @returns underlying native buffer
  64880. */
  64881. getBuffer(): Nullable<WebGLBuffer>;
  64882. /**
  64883. * Gets the stride in float32 units (i.e. byte stride / 4).
  64884. * May not be an integer if the byte stride is not divisible by 4.
  64885. * DEPRECATED. Use byteStride instead.
  64886. * @returns the stride in float32 units
  64887. */
  64888. getStrideSize(): number;
  64889. /**
  64890. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64891. * @param data defines the data to store
  64892. */
  64893. create(data?: Nullable<DataArray>): void;
  64894. /** @hidden */
  64895. _rebuild(): void;
  64896. /**
  64897. * Update current buffer data
  64898. * @param data defines the data to store
  64899. */
  64900. update(data: DataArray): void;
  64901. /**
  64902. * Updates the data directly.
  64903. * @param data the new data
  64904. * @param offset the new offset
  64905. * @param vertexCount the vertex count (optional)
  64906. * @param useBytes set to true if the offset is in bytes
  64907. */
  64908. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  64909. /**
  64910. * Release all resources
  64911. */
  64912. dispose(): void;
  64913. }
  64914. /**
  64915. * Specialized buffer used to store vertex data
  64916. */
  64917. export class VertexBuffer {
  64918. /** @hidden */
  64919. _buffer: Buffer;
  64920. private _kind;
  64921. private _size;
  64922. private _ownsBuffer;
  64923. private _instanced;
  64924. private _instanceDivisor;
  64925. /**
  64926. * The byte type.
  64927. */
  64928. static readonly BYTE: number;
  64929. /**
  64930. * The unsigned byte type.
  64931. */
  64932. static readonly UNSIGNED_BYTE: number;
  64933. /**
  64934. * The short type.
  64935. */
  64936. static readonly SHORT: number;
  64937. /**
  64938. * The unsigned short type.
  64939. */
  64940. static readonly UNSIGNED_SHORT: number;
  64941. /**
  64942. * The integer type.
  64943. */
  64944. static readonly INT: number;
  64945. /**
  64946. * The unsigned integer type.
  64947. */
  64948. static readonly UNSIGNED_INT: number;
  64949. /**
  64950. * The float type.
  64951. */
  64952. static readonly FLOAT: number;
  64953. /**
  64954. * Gets or sets the instance divisor when in instanced mode
  64955. */
  64956. instanceDivisor: number;
  64957. /**
  64958. * Gets the byte stride.
  64959. */
  64960. readonly byteStride: number;
  64961. /**
  64962. * Gets the byte offset.
  64963. */
  64964. readonly byteOffset: number;
  64965. /**
  64966. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  64967. */
  64968. readonly normalized: boolean;
  64969. /**
  64970. * Gets the data type of each component in the array.
  64971. */
  64972. readonly type: number;
  64973. /**
  64974. * Constructor
  64975. * @param engine the engine
  64976. * @param data the data to use for this vertex buffer
  64977. * @param kind the vertex buffer kind
  64978. * @param updatable whether the data is updatable
  64979. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64980. * @param stride the stride (optional)
  64981. * @param instanced whether the buffer is instanced (optional)
  64982. * @param offset the offset of the data (optional)
  64983. * @param size the number of components (optional)
  64984. * @param type the type of the component (optional)
  64985. * @param normalized whether the data contains normalized data (optional)
  64986. * @param useBytes set to true if stride and offset are in bytes (optional)
  64987. */
  64988. 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);
  64989. /** @hidden */
  64990. _rebuild(): void;
  64991. /**
  64992. * Returns the kind of the VertexBuffer (string)
  64993. * @returns a string
  64994. */
  64995. getKind(): string;
  64996. /**
  64997. * Gets a boolean indicating if the VertexBuffer is updatable?
  64998. * @returns true if the buffer is updatable
  64999. */
  65000. isUpdatable(): boolean;
  65001. /**
  65002. * Gets current buffer's data
  65003. * @returns a DataArray or null
  65004. */
  65005. getData(): Nullable<DataArray>;
  65006. /**
  65007. * Gets underlying native buffer
  65008. * @returns underlying native buffer
  65009. */
  65010. getBuffer(): Nullable<WebGLBuffer>;
  65011. /**
  65012. * Gets the stride in float32 units (i.e. byte stride / 4).
  65013. * May not be an integer if the byte stride is not divisible by 4.
  65014. * DEPRECATED. Use byteStride instead.
  65015. * @returns the stride in float32 units
  65016. */
  65017. getStrideSize(): number;
  65018. /**
  65019. * Returns the offset as a multiple of the type byte length.
  65020. * DEPRECATED. Use byteOffset instead.
  65021. * @returns the offset in bytes
  65022. */
  65023. getOffset(): number;
  65024. /**
  65025. * Returns the number of components per vertex attribute (integer)
  65026. * @returns the size in float
  65027. */
  65028. getSize(): number;
  65029. /**
  65030. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65031. * @returns true if this buffer is instanced
  65032. */
  65033. getIsInstanced(): boolean;
  65034. /**
  65035. * Returns the instancing divisor, zero for non-instanced (integer).
  65036. * @returns a number
  65037. */
  65038. getInstanceDivisor(): number;
  65039. /**
  65040. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65041. * @param data defines the data to store
  65042. */
  65043. create(data?: DataArray): void;
  65044. /**
  65045. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65046. * This function will create a new buffer if the current one is not updatable
  65047. * @param data defines the data to store
  65048. */
  65049. update(data: DataArray): void;
  65050. /**
  65051. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65052. * Returns the directly updated WebGLBuffer.
  65053. * @param data the new data
  65054. * @param offset the new offset
  65055. * @param useBytes set to true if the offset is in bytes
  65056. */
  65057. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65058. /**
  65059. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65060. */
  65061. dispose(): void;
  65062. /**
  65063. * Enumerates each value of this vertex buffer as numbers.
  65064. * @param count the number of values to enumerate
  65065. * @param callback the callback function called for each value
  65066. */
  65067. forEach(count: number, callback: (value: number, index: number) => void): void;
  65068. /**
  65069. * Positions
  65070. */
  65071. static readonly PositionKind: string;
  65072. /**
  65073. * Normals
  65074. */
  65075. static readonly NormalKind: string;
  65076. /**
  65077. * Tangents
  65078. */
  65079. static readonly TangentKind: string;
  65080. /**
  65081. * Texture coordinates
  65082. */
  65083. static readonly UVKind: string;
  65084. /**
  65085. * Texture coordinates 2
  65086. */
  65087. static readonly UV2Kind: string;
  65088. /**
  65089. * Texture coordinates 3
  65090. */
  65091. static readonly UV3Kind: string;
  65092. /**
  65093. * Texture coordinates 4
  65094. */
  65095. static readonly UV4Kind: string;
  65096. /**
  65097. * Texture coordinates 5
  65098. */
  65099. static readonly UV5Kind: string;
  65100. /**
  65101. * Texture coordinates 6
  65102. */
  65103. static readonly UV6Kind: string;
  65104. /**
  65105. * Colors
  65106. */
  65107. static readonly ColorKind: string;
  65108. /**
  65109. * Matrix indices (for bones)
  65110. */
  65111. static readonly MatricesIndicesKind: string;
  65112. /**
  65113. * Matrix weights (for bones)
  65114. */
  65115. static readonly MatricesWeightsKind: string;
  65116. /**
  65117. * Additional matrix indices (for bones)
  65118. */
  65119. static readonly MatricesIndicesExtraKind: string;
  65120. /**
  65121. * Additional matrix weights (for bones)
  65122. */
  65123. static readonly MatricesWeightsExtraKind: string;
  65124. /**
  65125. * Deduces the stride given a kind.
  65126. * @param kind The kind string to deduce
  65127. * @returns The deduced stride
  65128. */
  65129. static DeduceStride(kind: string): number;
  65130. /**
  65131. * Gets the byte length of the given type.
  65132. * @param type the type
  65133. * @returns the number of bytes
  65134. */
  65135. static GetTypeByteLength(type: number): number;
  65136. /**
  65137. * Enumerates each value of the given parameters as numbers.
  65138. * @param data the data to enumerate
  65139. * @param byteOffset the byte offset of the data
  65140. * @param byteStride the byte stride of the data
  65141. * @param componentCount the number of components per element
  65142. * @param componentType the type of the component
  65143. * @param count the total number of components
  65144. * @param normalized whether the data is normalized
  65145. * @param callback the callback function called for each value
  65146. */
  65147. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65148. private static _GetFloatValue;
  65149. }
  65150. }
  65151. declare module BABYLON {
  65152. /**
  65153. * Class representing spherical polynomial coefficients to the 3rd degree
  65154. */
  65155. export class SphericalPolynomial {
  65156. /**
  65157. * The x coefficients of the spherical polynomial
  65158. */
  65159. x: Vector3;
  65160. /**
  65161. * The y coefficients of the spherical polynomial
  65162. */
  65163. y: Vector3;
  65164. /**
  65165. * The z coefficients of the spherical polynomial
  65166. */
  65167. z: Vector3;
  65168. /**
  65169. * The xx coefficients of the spherical polynomial
  65170. */
  65171. xx: Vector3;
  65172. /**
  65173. * The yy coefficients of the spherical polynomial
  65174. */
  65175. yy: Vector3;
  65176. /**
  65177. * The zz coefficients of the spherical polynomial
  65178. */
  65179. zz: Vector3;
  65180. /**
  65181. * The xy coefficients of the spherical polynomial
  65182. */
  65183. xy: Vector3;
  65184. /**
  65185. * The yz coefficients of the spherical polynomial
  65186. */
  65187. yz: Vector3;
  65188. /**
  65189. * The zx coefficients of the spherical polynomial
  65190. */
  65191. zx: Vector3;
  65192. /**
  65193. * Adds an ambient color to the spherical polynomial
  65194. * @param color the color to add
  65195. */
  65196. addAmbient(color: Color3): void;
  65197. /**
  65198. * Scales the spherical polynomial by the given amount
  65199. * @param scale the amount to scale
  65200. */
  65201. scale(scale: number): void;
  65202. /**
  65203. * Gets the spherical polynomial from harmonics
  65204. * @param harmonics the spherical harmonics
  65205. * @returns the spherical polynomial
  65206. */
  65207. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  65208. /**
  65209. * Constructs a spherical polynomial from an array.
  65210. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  65211. * @returns the spherical polynomial
  65212. */
  65213. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  65214. }
  65215. /**
  65216. * Class representing spherical harmonics coefficients to the 3rd degree
  65217. */
  65218. export class SphericalHarmonics {
  65219. /**
  65220. * The l0,0 coefficients of the spherical harmonics
  65221. */
  65222. l00: Vector3;
  65223. /**
  65224. * The l1,-1 coefficients of the spherical harmonics
  65225. */
  65226. l1_1: Vector3;
  65227. /**
  65228. * The l1,0 coefficients of the spherical harmonics
  65229. */
  65230. l10: Vector3;
  65231. /**
  65232. * The l1,1 coefficients of the spherical harmonics
  65233. */
  65234. l11: Vector3;
  65235. /**
  65236. * The l2,-2 coefficients of the spherical harmonics
  65237. */
  65238. l2_2: Vector3;
  65239. /**
  65240. * The l2,-1 coefficients of the spherical harmonics
  65241. */
  65242. l2_1: Vector3;
  65243. /**
  65244. * The l2,0 coefficients of the spherical harmonics
  65245. */
  65246. l20: Vector3;
  65247. /**
  65248. * The l2,1 coefficients of the spherical harmonics
  65249. */
  65250. l21: Vector3;
  65251. /**
  65252. * The l2,2 coefficients of the spherical harmonics
  65253. */
  65254. lL22: Vector3;
  65255. /**
  65256. * Adds a light to the spherical harmonics
  65257. * @param direction the direction of the light
  65258. * @param color the color of the light
  65259. * @param deltaSolidAngle the delta solid angle of the light
  65260. */
  65261. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  65262. /**
  65263. * Scales the spherical harmonics by the given amount
  65264. * @param scale the amount to scale
  65265. */
  65266. scale(scale: number): void;
  65267. /**
  65268. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  65269. *
  65270. * ```
  65271. * E_lm = A_l * L_lm
  65272. * ```
  65273. *
  65274. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  65275. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  65276. * the scaling factors are given in equation 9.
  65277. */
  65278. convertIncidentRadianceToIrradiance(): void;
  65279. /**
  65280. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  65281. *
  65282. * ```
  65283. * L = (1/pi) * E * rho
  65284. * ```
  65285. *
  65286. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  65287. */
  65288. convertIrradianceToLambertianRadiance(): void;
  65289. /**
  65290. * Gets the spherical harmonics from polynomial
  65291. * @param polynomial the spherical polynomial
  65292. * @returns the spherical harmonics
  65293. */
  65294. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  65295. /**
  65296. * Constructs a spherical harmonics from an array.
  65297. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  65298. * @returns the spherical harmonics
  65299. */
  65300. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  65301. }
  65302. }
  65303. declare module BABYLON {
  65304. /**
  65305. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  65306. */
  65307. export interface CubeMapInfo {
  65308. /**
  65309. * The pixel array for the front face.
  65310. * This is stored in format, left to right, up to down format.
  65311. */
  65312. front: Nullable<ArrayBufferView>;
  65313. /**
  65314. * The pixel array for the back face.
  65315. * This is stored in format, left to right, up to down format.
  65316. */
  65317. back: Nullable<ArrayBufferView>;
  65318. /**
  65319. * The pixel array for the left face.
  65320. * This is stored in format, left to right, up to down format.
  65321. */
  65322. left: Nullable<ArrayBufferView>;
  65323. /**
  65324. * The pixel array for the right face.
  65325. * This is stored in format, left to right, up to down format.
  65326. */
  65327. right: Nullable<ArrayBufferView>;
  65328. /**
  65329. * The pixel array for the up face.
  65330. * This is stored in format, left to right, up to down format.
  65331. */
  65332. up: Nullable<ArrayBufferView>;
  65333. /**
  65334. * The pixel array for the down face.
  65335. * This is stored in format, left to right, up to down format.
  65336. */
  65337. down: Nullable<ArrayBufferView>;
  65338. /**
  65339. * The size of the cubemap stored.
  65340. *
  65341. * Each faces will be size * size pixels.
  65342. */
  65343. size: number;
  65344. /**
  65345. * The format of the texture.
  65346. *
  65347. * RGBA, RGB.
  65348. */
  65349. format: number;
  65350. /**
  65351. * The type of the texture data.
  65352. *
  65353. * UNSIGNED_INT, FLOAT.
  65354. */
  65355. type: number;
  65356. /**
  65357. * Specifies whether the texture is in gamma space.
  65358. */
  65359. gammaSpace: boolean;
  65360. }
  65361. /**
  65362. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  65363. */
  65364. export class PanoramaToCubeMapTools {
  65365. private static FACE_FRONT;
  65366. private static FACE_BACK;
  65367. private static FACE_RIGHT;
  65368. private static FACE_LEFT;
  65369. private static FACE_DOWN;
  65370. private static FACE_UP;
  65371. /**
  65372. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  65373. *
  65374. * @param float32Array The source data.
  65375. * @param inputWidth The width of the input panorama.
  65376. * @param inputHeight The height of the input panorama.
  65377. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  65378. * @return The cubemap data
  65379. */
  65380. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  65381. private static CreateCubemapTexture;
  65382. private static CalcProjectionSpherical;
  65383. }
  65384. }
  65385. declare module BABYLON {
  65386. /**
  65387. * Helper class dealing with the extraction of spherical polynomial dataArray
  65388. * from a cube map.
  65389. */
  65390. export class CubeMapToSphericalPolynomialTools {
  65391. private static FileFaces;
  65392. /**
  65393. * Converts a texture to the according Spherical Polynomial data.
  65394. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65395. *
  65396. * @param texture The texture to extract the information from.
  65397. * @return The Spherical Polynomial data.
  65398. */
  65399. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  65400. /**
  65401. * Converts a cubemap to the according Spherical Polynomial data.
  65402. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65403. *
  65404. * @param cubeInfo The Cube map to extract the information from.
  65405. * @return The Spherical Polynomial data.
  65406. */
  65407. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  65408. }
  65409. }
  65410. declare module BABYLON {
  65411. /**
  65412. * The engine store class is responsible to hold all the instances of Engine and Scene created
  65413. * during the life time of the application.
  65414. */
  65415. export class EngineStore {
  65416. /** Gets the list of created engines */
  65417. static Instances: Engine[];
  65418. /**
  65419. * Gets the latest created engine
  65420. */
  65421. static readonly LastCreatedEngine: Nullable<Engine>;
  65422. /**
  65423. * Gets the latest created scene
  65424. */
  65425. static readonly LastCreatedScene: Nullable<Scene>;
  65426. }
  65427. }
  65428. declare module BABYLON {
  65429. /**
  65430. * Define options used to create a render target texture
  65431. */
  65432. export class RenderTargetCreationOptions {
  65433. /**
  65434. * Specifies is mipmaps must be generated
  65435. */
  65436. generateMipMaps?: boolean;
  65437. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  65438. generateDepthBuffer?: boolean;
  65439. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  65440. generateStencilBuffer?: boolean;
  65441. /** Defines texture type (int by default) */
  65442. type?: number;
  65443. /** Defines sampling mode (trilinear by default) */
  65444. samplingMode?: number;
  65445. /** Defines format (RGBA by default) */
  65446. format?: number;
  65447. }
  65448. }
  65449. declare module BABYLON {
  65450. /**
  65451. * @hidden
  65452. **/
  65453. export class _AlphaState {
  65454. private _isAlphaBlendDirty;
  65455. private _isBlendFunctionParametersDirty;
  65456. private _isBlendEquationParametersDirty;
  65457. private _isBlendConstantsDirty;
  65458. private _alphaBlend;
  65459. private _blendFunctionParameters;
  65460. private _blendEquationParameters;
  65461. private _blendConstants;
  65462. /**
  65463. * Initializes the state.
  65464. */
  65465. constructor();
  65466. readonly isDirty: boolean;
  65467. alphaBlend: boolean;
  65468. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  65469. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  65470. setAlphaEquationParameters(rgb: number, alpha: number): void;
  65471. reset(): void;
  65472. apply(gl: WebGLRenderingContext): void;
  65473. }
  65474. }
  65475. declare module BABYLON {
  65476. /**
  65477. * @hidden
  65478. **/
  65479. export class _DepthCullingState {
  65480. private _isDepthTestDirty;
  65481. private _isDepthMaskDirty;
  65482. private _isDepthFuncDirty;
  65483. private _isCullFaceDirty;
  65484. private _isCullDirty;
  65485. private _isZOffsetDirty;
  65486. private _isFrontFaceDirty;
  65487. private _depthTest;
  65488. private _depthMask;
  65489. private _depthFunc;
  65490. private _cull;
  65491. private _cullFace;
  65492. private _zOffset;
  65493. private _frontFace;
  65494. /**
  65495. * Initializes the state.
  65496. */
  65497. constructor();
  65498. readonly isDirty: boolean;
  65499. zOffset: number;
  65500. cullFace: Nullable<number>;
  65501. cull: Nullable<boolean>;
  65502. depthFunc: Nullable<number>;
  65503. depthMask: boolean;
  65504. depthTest: boolean;
  65505. frontFace: Nullable<number>;
  65506. reset(): void;
  65507. apply(gl: WebGLRenderingContext): void;
  65508. }
  65509. }
  65510. declare module BABYLON {
  65511. /**
  65512. * @hidden
  65513. **/
  65514. export class _StencilState {
  65515. /** 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 */
  65516. static readonly ALWAYS: number;
  65517. /** Passed to stencilOperation to specify that stencil value must be kept */
  65518. static readonly KEEP: number;
  65519. /** Passed to stencilOperation to specify that stencil value must be replaced */
  65520. static readonly REPLACE: number;
  65521. private _isStencilTestDirty;
  65522. private _isStencilMaskDirty;
  65523. private _isStencilFuncDirty;
  65524. private _isStencilOpDirty;
  65525. private _stencilTest;
  65526. private _stencilMask;
  65527. private _stencilFunc;
  65528. private _stencilFuncRef;
  65529. private _stencilFuncMask;
  65530. private _stencilOpStencilFail;
  65531. private _stencilOpDepthFail;
  65532. private _stencilOpStencilDepthPass;
  65533. readonly isDirty: boolean;
  65534. stencilFunc: number;
  65535. stencilFuncRef: number;
  65536. stencilFuncMask: number;
  65537. stencilOpStencilFail: number;
  65538. stencilOpDepthFail: number;
  65539. stencilOpStencilDepthPass: number;
  65540. stencilMask: number;
  65541. stencilTest: boolean;
  65542. constructor();
  65543. reset(): void;
  65544. apply(gl: WebGLRenderingContext): void;
  65545. }
  65546. }
  65547. declare module BABYLON {
  65548. /**
  65549. * @hidden
  65550. **/
  65551. export class _TimeToken {
  65552. _startTimeQuery: Nullable<WebGLQuery>;
  65553. _endTimeQuery: Nullable<WebGLQuery>;
  65554. _timeElapsedQuery: Nullable<WebGLQuery>;
  65555. _timeElapsedQueryEnded: boolean;
  65556. }
  65557. }
  65558. declare module BABYLON {
  65559. /**
  65560. * Class used to store data associated with WebGL texture data for the engine
  65561. * This class should not be used directly
  65562. */
  65563. export class InternalTexture {
  65564. /** hidden */
  65565. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  65566. /**
  65567. * The source of the texture data is unknown
  65568. */
  65569. static DATASOURCE_UNKNOWN: number;
  65570. /**
  65571. * Texture data comes from an URL
  65572. */
  65573. static DATASOURCE_URL: number;
  65574. /**
  65575. * Texture data is only used for temporary storage
  65576. */
  65577. static DATASOURCE_TEMP: number;
  65578. /**
  65579. * Texture data comes from raw data (ArrayBuffer)
  65580. */
  65581. static DATASOURCE_RAW: number;
  65582. /**
  65583. * Texture content is dynamic (video or dynamic texture)
  65584. */
  65585. static DATASOURCE_DYNAMIC: number;
  65586. /**
  65587. * Texture content is generated by rendering to it
  65588. */
  65589. static DATASOURCE_RENDERTARGET: number;
  65590. /**
  65591. * Texture content is part of a multi render target process
  65592. */
  65593. static DATASOURCE_MULTIRENDERTARGET: number;
  65594. /**
  65595. * Texture data comes from a cube data file
  65596. */
  65597. static DATASOURCE_CUBE: number;
  65598. /**
  65599. * Texture data comes from a raw cube data
  65600. */
  65601. static DATASOURCE_CUBERAW: number;
  65602. /**
  65603. * Texture data come from a prefiltered cube data file
  65604. */
  65605. static DATASOURCE_CUBEPREFILTERED: number;
  65606. /**
  65607. * Texture content is raw 3D data
  65608. */
  65609. static DATASOURCE_RAW3D: number;
  65610. /**
  65611. * Texture content is a depth texture
  65612. */
  65613. static DATASOURCE_DEPTHTEXTURE: number;
  65614. /**
  65615. * Texture data comes from a raw cube data encoded with RGBD
  65616. */
  65617. static DATASOURCE_CUBERAW_RGBD: number;
  65618. /**
  65619. * Defines if the texture is ready
  65620. */
  65621. isReady: boolean;
  65622. /**
  65623. * Defines if the texture is a cube texture
  65624. */
  65625. isCube: boolean;
  65626. /**
  65627. * Defines if the texture contains 3D data
  65628. */
  65629. is3D: boolean;
  65630. /**
  65631. * Defines if the texture contains multiview data
  65632. */
  65633. isMultiview: boolean;
  65634. /**
  65635. * Gets the URL used to load this texture
  65636. */
  65637. url: string;
  65638. /**
  65639. * Gets the sampling mode of the texture
  65640. */
  65641. samplingMode: number;
  65642. /**
  65643. * Gets a boolean indicating if the texture needs mipmaps generation
  65644. */
  65645. generateMipMaps: boolean;
  65646. /**
  65647. * Gets the number of samples used by the texture (WebGL2+ only)
  65648. */
  65649. samples: number;
  65650. /**
  65651. * Gets the type of the texture (int, float...)
  65652. */
  65653. type: number;
  65654. /**
  65655. * Gets the format of the texture (RGB, RGBA...)
  65656. */
  65657. format: number;
  65658. /**
  65659. * Observable called when the texture is loaded
  65660. */
  65661. onLoadedObservable: Observable<InternalTexture>;
  65662. /**
  65663. * Gets the width of the texture
  65664. */
  65665. width: number;
  65666. /**
  65667. * Gets the height of the texture
  65668. */
  65669. height: number;
  65670. /**
  65671. * Gets the depth of the texture
  65672. */
  65673. depth: number;
  65674. /**
  65675. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  65676. */
  65677. baseWidth: number;
  65678. /**
  65679. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  65680. */
  65681. baseHeight: number;
  65682. /**
  65683. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  65684. */
  65685. baseDepth: number;
  65686. /**
  65687. * Gets a boolean indicating if the texture is inverted on Y axis
  65688. */
  65689. invertY: boolean;
  65690. /** @hidden */
  65691. _invertVScale: boolean;
  65692. /** @hidden */
  65693. _associatedChannel: number;
  65694. /** @hidden */
  65695. _dataSource: number;
  65696. /** @hidden */
  65697. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  65698. /** @hidden */
  65699. _bufferView: Nullable<ArrayBufferView>;
  65700. /** @hidden */
  65701. _bufferViewArray: Nullable<ArrayBufferView[]>;
  65702. /** @hidden */
  65703. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  65704. /** @hidden */
  65705. _size: number;
  65706. /** @hidden */
  65707. _extension: string;
  65708. /** @hidden */
  65709. _files: Nullable<string[]>;
  65710. /** @hidden */
  65711. _workingCanvas: HTMLCanvasElement;
  65712. /** @hidden */
  65713. _workingContext: CanvasRenderingContext2D;
  65714. /** @hidden */
  65715. _framebuffer: Nullable<WebGLFramebuffer>;
  65716. /** @hidden */
  65717. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  65718. /** @hidden */
  65719. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  65720. /** @hidden */
  65721. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  65722. /** @hidden */
  65723. _attachments: Nullable<number[]>;
  65724. /** @hidden */
  65725. _cachedCoordinatesMode: Nullable<number>;
  65726. /** @hidden */
  65727. _cachedWrapU: Nullable<number>;
  65728. /** @hidden */
  65729. _cachedWrapV: Nullable<number>;
  65730. /** @hidden */
  65731. _cachedWrapR: Nullable<number>;
  65732. /** @hidden */
  65733. _cachedAnisotropicFilteringLevel: Nullable<number>;
  65734. /** @hidden */
  65735. _isDisabled: boolean;
  65736. /** @hidden */
  65737. _compression: Nullable<string>;
  65738. /** @hidden */
  65739. _generateStencilBuffer: boolean;
  65740. /** @hidden */
  65741. _generateDepthBuffer: boolean;
  65742. /** @hidden */
  65743. _comparisonFunction: number;
  65744. /** @hidden */
  65745. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  65746. /** @hidden */
  65747. _lodGenerationScale: number;
  65748. /** @hidden */
  65749. _lodGenerationOffset: number;
  65750. /** @hidden */
  65751. _colorTextureArray: Nullable<WebGLTexture>;
  65752. /** @hidden */
  65753. _depthStencilTextureArray: Nullable<WebGLTexture>;
  65754. /** @hidden */
  65755. _lodTextureHigh: BaseTexture;
  65756. /** @hidden */
  65757. _lodTextureMid: BaseTexture;
  65758. /** @hidden */
  65759. _lodTextureLow: BaseTexture;
  65760. /** @hidden */
  65761. _isRGBD: boolean;
  65762. /** @hidden */
  65763. _webGLTexture: Nullable<WebGLTexture>;
  65764. /** @hidden */
  65765. _references: number;
  65766. private _engine;
  65767. /**
  65768. * Gets the Engine the texture belongs to.
  65769. * @returns The babylon engine
  65770. */
  65771. getEngine(): Engine;
  65772. /**
  65773. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  65774. */
  65775. readonly dataSource: number;
  65776. /**
  65777. * Creates a new InternalTexture
  65778. * @param engine defines the engine to use
  65779. * @param dataSource defines the type of data that will be used
  65780. * @param delayAllocation if the texture allocation should be delayed (default: false)
  65781. */
  65782. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  65783. /**
  65784. * Increments the number of references (ie. the number of Texture that point to it)
  65785. */
  65786. incrementReferences(): void;
  65787. /**
  65788. * Change the size of the texture (not the size of the content)
  65789. * @param width defines the new width
  65790. * @param height defines the new height
  65791. * @param depth defines the new depth (1 by default)
  65792. */
  65793. updateSize(width: int, height: int, depth?: int): void;
  65794. /** @hidden */
  65795. _rebuild(): void;
  65796. /** @hidden */
  65797. _swapAndDie(target: InternalTexture): void;
  65798. /**
  65799. * Dispose the current allocated resources
  65800. */
  65801. dispose(): void;
  65802. }
  65803. }
  65804. declare module BABYLON {
  65805. /**
  65806. * This represents the main contract an easing function should follow.
  65807. * Easing functions are used throughout the animation system.
  65808. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65809. */
  65810. export interface IEasingFunction {
  65811. /**
  65812. * Given an input gradient between 0 and 1, this returns the corrseponding value
  65813. * of the easing function.
  65814. * The link below provides some of the most common examples of easing functions.
  65815. * @see https://easings.net/
  65816. * @param gradient Defines the value between 0 and 1 we want the easing value for
  65817. * @returns the corresponding value on the curve defined by the easing function
  65818. */
  65819. ease(gradient: number): number;
  65820. }
  65821. /**
  65822. * Base class used for every default easing function.
  65823. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65824. */
  65825. export class EasingFunction implements IEasingFunction {
  65826. /**
  65827. * Interpolation follows the mathematical formula associated with the easing function.
  65828. */
  65829. static readonly EASINGMODE_EASEIN: number;
  65830. /**
  65831. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  65832. */
  65833. static readonly EASINGMODE_EASEOUT: number;
  65834. /**
  65835. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  65836. */
  65837. static readonly EASINGMODE_EASEINOUT: number;
  65838. private _easingMode;
  65839. /**
  65840. * Sets the easing mode of the current function.
  65841. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  65842. */
  65843. setEasingMode(easingMode: number): void;
  65844. /**
  65845. * Gets the current easing mode.
  65846. * @returns the easing mode
  65847. */
  65848. getEasingMode(): number;
  65849. /**
  65850. * @hidden
  65851. */
  65852. easeInCore(gradient: number): number;
  65853. /**
  65854. * Given an input gradient between 0 and 1, this returns the corrseponding value
  65855. * of the easing function.
  65856. * @param gradient Defines the value between 0 and 1 we want the easing value for
  65857. * @returns the corresponding value on the curve defined by the easing function
  65858. */
  65859. ease(gradient: number): number;
  65860. }
  65861. /**
  65862. * Easing function with a circle shape (see link below).
  65863. * @see https://easings.net/#easeInCirc
  65864. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65865. */
  65866. export class CircleEase extends EasingFunction implements IEasingFunction {
  65867. /** @hidden */
  65868. easeInCore(gradient: number): number;
  65869. }
  65870. /**
  65871. * Easing function with a ease back shape (see link below).
  65872. * @see https://easings.net/#easeInBack
  65873. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65874. */
  65875. export class BackEase extends EasingFunction implements IEasingFunction {
  65876. /** Defines the amplitude of the function */
  65877. amplitude: number;
  65878. /**
  65879. * Instantiates a back ease easing
  65880. * @see https://easings.net/#easeInBack
  65881. * @param amplitude Defines the amplitude of the function
  65882. */
  65883. constructor(
  65884. /** Defines the amplitude of the function */
  65885. amplitude?: number);
  65886. /** @hidden */
  65887. easeInCore(gradient: number): number;
  65888. }
  65889. /**
  65890. * Easing function with a bouncing shape (see link below).
  65891. * @see https://easings.net/#easeInBounce
  65892. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65893. */
  65894. export class BounceEase extends EasingFunction implements IEasingFunction {
  65895. /** Defines the number of bounces */
  65896. bounces: number;
  65897. /** Defines the amplitude of the bounce */
  65898. bounciness: number;
  65899. /**
  65900. * Instantiates a bounce easing
  65901. * @see https://easings.net/#easeInBounce
  65902. * @param bounces Defines the number of bounces
  65903. * @param bounciness Defines the amplitude of the bounce
  65904. */
  65905. constructor(
  65906. /** Defines the number of bounces */
  65907. bounces?: number,
  65908. /** Defines the amplitude of the bounce */
  65909. bounciness?: number);
  65910. /** @hidden */
  65911. easeInCore(gradient: number): number;
  65912. }
  65913. /**
  65914. * Easing function with a power of 3 shape (see link below).
  65915. * @see https://easings.net/#easeInCubic
  65916. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65917. */
  65918. export class CubicEase extends EasingFunction implements IEasingFunction {
  65919. /** @hidden */
  65920. easeInCore(gradient: number): number;
  65921. }
  65922. /**
  65923. * Easing function with an elastic shape (see link below).
  65924. * @see https://easings.net/#easeInElastic
  65925. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65926. */
  65927. export class ElasticEase extends EasingFunction implements IEasingFunction {
  65928. /** Defines the number of oscillations*/
  65929. oscillations: number;
  65930. /** Defines the amplitude of the oscillations*/
  65931. springiness: number;
  65932. /**
  65933. * Instantiates an elastic easing function
  65934. * @see https://easings.net/#easeInElastic
  65935. * @param oscillations Defines the number of oscillations
  65936. * @param springiness Defines the amplitude of the oscillations
  65937. */
  65938. constructor(
  65939. /** Defines the number of oscillations*/
  65940. oscillations?: number,
  65941. /** Defines the amplitude of the oscillations*/
  65942. springiness?: number);
  65943. /** @hidden */
  65944. easeInCore(gradient: number): number;
  65945. }
  65946. /**
  65947. * Easing function with an exponential shape (see link below).
  65948. * @see https://easings.net/#easeInExpo
  65949. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65950. */
  65951. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  65952. /** Defines the exponent of the function */
  65953. exponent: number;
  65954. /**
  65955. * Instantiates an exponential easing function
  65956. * @see https://easings.net/#easeInExpo
  65957. * @param exponent Defines the exponent of the function
  65958. */
  65959. constructor(
  65960. /** Defines the exponent of the function */
  65961. exponent?: number);
  65962. /** @hidden */
  65963. easeInCore(gradient: number): number;
  65964. }
  65965. /**
  65966. * Easing function with a power shape (see link below).
  65967. * @see https://easings.net/#easeInQuad
  65968. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65969. */
  65970. export class PowerEase extends EasingFunction implements IEasingFunction {
  65971. /** Defines the power of the function */
  65972. power: number;
  65973. /**
  65974. * Instantiates an power base easing function
  65975. * @see https://easings.net/#easeInQuad
  65976. * @param power Defines the power of the function
  65977. */
  65978. constructor(
  65979. /** Defines the power of the function */
  65980. power?: number);
  65981. /** @hidden */
  65982. easeInCore(gradient: number): number;
  65983. }
  65984. /**
  65985. * Easing function with a power of 2 shape (see link below).
  65986. * @see https://easings.net/#easeInQuad
  65987. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65988. */
  65989. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  65990. /** @hidden */
  65991. easeInCore(gradient: number): number;
  65992. }
  65993. /**
  65994. * Easing function with a power of 4 shape (see link below).
  65995. * @see https://easings.net/#easeInQuart
  65996. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65997. */
  65998. export class QuarticEase extends EasingFunction implements IEasingFunction {
  65999. /** @hidden */
  66000. easeInCore(gradient: number): number;
  66001. }
  66002. /**
  66003. * Easing function with a power of 5 shape (see link below).
  66004. * @see https://easings.net/#easeInQuint
  66005. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66006. */
  66007. export class QuinticEase extends EasingFunction implements IEasingFunction {
  66008. /** @hidden */
  66009. easeInCore(gradient: number): number;
  66010. }
  66011. /**
  66012. * Easing function with a sin shape (see link below).
  66013. * @see https://easings.net/#easeInSine
  66014. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66015. */
  66016. export class SineEase extends EasingFunction implements IEasingFunction {
  66017. /** @hidden */
  66018. easeInCore(gradient: number): number;
  66019. }
  66020. /**
  66021. * Easing function with a bezier shape (see link below).
  66022. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66023. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66024. */
  66025. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  66026. /** Defines the x component of the start tangent in the bezier curve */
  66027. x1: number;
  66028. /** Defines the y component of the start tangent in the bezier curve */
  66029. y1: number;
  66030. /** Defines the x component of the end tangent in the bezier curve */
  66031. x2: number;
  66032. /** Defines the y component of the end tangent in the bezier curve */
  66033. y2: number;
  66034. /**
  66035. * Instantiates a bezier function
  66036. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66037. * @param x1 Defines the x component of the start tangent in the bezier curve
  66038. * @param y1 Defines the y component of the start tangent in the bezier curve
  66039. * @param x2 Defines the x component of the end tangent in the bezier curve
  66040. * @param y2 Defines the y component of the end tangent in the bezier curve
  66041. */
  66042. constructor(
  66043. /** Defines the x component of the start tangent in the bezier curve */
  66044. x1?: number,
  66045. /** Defines the y component of the start tangent in the bezier curve */
  66046. y1?: number,
  66047. /** Defines the x component of the end tangent in the bezier curve */
  66048. x2?: number,
  66049. /** Defines the y component of the end tangent in the bezier curve */
  66050. y2?: number);
  66051. /** @hidden */
  66052. easeInCore(gradient: number): number;
  66053. }
  66054. }
  66055. declare module BABYLON {
  66056. /**
  66057. * Defines an interface which represents an animation key frame
  66058. */
  66059. export interface IAnimationKey {
  66060. /**
  66061. * Frame of the key frame
  66062. */
  66063. frame: number;
  66064. /**
  66065. * Value at the specifies key frame
  66066. */
  66067. value: any;
  66068. /**
  66069. * The input tangent for the cubic hermite spline
  66070. */
  66071. inTangent?: any;
  66072. /**
  66073. * The output tangent for the cubic hermite spline
  66074. */
  66075. outTangent?: any;
  66076. /**
  66077. * The animation interpolation type
  66078. */
  66079. interpolation?: AnimationKeyInterpolation;
  66080. }
  66081. /**
  66082. * Enum for the animation key frame interpolation type
  66083. */
  66084. export enum AnimationKeyInterpolation {
  66085. /**
  66086. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  66087. */
  66088. STEP = 1
  66089. }
  66090. }
  66091. declare module BABYLON {
  66092. /**
  66093. * Represents the range of an animation
  66094. */
  66095. export class AnimationRange {
  66096. /**The name of the animation range**/
  66097. name: string;
  66098. /**The starting frame of the animation */
  66099. from: number;
  66100. /**The ending frame of the animation*/
  66101. to: number;
  66102. /**
  66103. * Initializes the range of an animation
  66104. * @param name The name of the animation range
  66105. * @param from The starting frame of the animation
  66106. * @param to The ending frame of the animation
  66107. */
  66108. constructor(
  66109. /**The name of the animation range**/
  66110. name: string,
  66111. /**The starting frame of the animation */
  66112. from: number,
  66113. /**The ending frame of the animation*/
  66114. to: number);
  66115. /**
  66116. * Makes a copy of the animation range
  66117. * @returns A copy of the animation range
  66118. */
  66119. clone(): AnimationRange;
  66120. }
  66121. }
  66122. declare module BABYLON {
  66123. /**
  66124. * Composed of a frame, and an action function
  66125. */
  66126. export class AnimationEvent {
  66127. /** The frame for which the event is triggered **/
  66128. frame: number;
  66129. /** The event to perform when triggered **/
  66130. action: (currentFrame: number) => void;
  66131. /** Specifies if the event should be triggered only once**/
  66132. onlyOnce?: boolean | undefined;
  66133. /**
  66134. * Specifies if the animation event is done
  66135. */
  66136. isDone: boolean;
  66137. /**
  66138. * Initializes the animation event
  66139. * @param frame The frame for which the event is triggered
  66140. * @param action The event to perform when triggered
  66141. * @param onlyOnce Specifies if the event should be triggered only once
  66142. */
  66143. constructor(
  66144. /** The frame for which the event is triggered **/
  66145. frame: number,
  66146. /** The event to perform when triggered **/
  66147. action: (currentFrame: number) => void,
  66148. /** Specifies if the event should be triggered only once**/
  66149. onlyOnce?: boolean | undefined);
  66150. /** @hidden */
  66151. _clone(): AnimationEvent;
  66152. }
  66153. }
  66154. declare module BABYLON {
  66155. /**
  66156. * Interface used to define a behavior
  66157. */
  66158. export interface Behavior<T> {
  66159. /** gets or sets behavior's name */
  66160. name: string;
  66161. /**
  66162. * Function called when the behavior needs to be initialized (after attaching it to a target)
  66163. */
  66164. init(): void;
  66165. /**
  66166. * Called when the behavior is attached to a target
  66167. * @param target defines the target where the behavior is attached to
  66168. */
  66169. attach(target: T): void;
  66170. /**
  66171. * Called when the behavior is detached from its target
  66172. */
  66173. detach(): void;
  66174. }
  66175. /**
  66176. * Interface implemented by classes supporting behaviors
  66177. */
  66178. export interface IBehaviorAware<T> {
  66179. /**
  66180. * Attach a behavior
  66181. * @param behavior defines the behavior to attach
  66182. * @returns the current host
  66183. */
  66184. addBehavior(behavior: Behavior<T>): T;
  66185. /**
  66186. * Remove a behavior from the current object
  66187. * @param behavior defines the behavior to detach
  66188. * @returns the current host
  66189. */
  66190. removeBehavior(behavior: Behavior<T>): T;
  66191. /**
  66192. * Gets a behavior using its name to search
  66193. * @param name defines the name to search
  66194. * @returns the behavior or null if not found
  66195. */
  66196. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  66197. }
  66198. }
  66199. declare module BABYLON {
  66200. /**
  66201. * @hidden
  66202. */
  66203. export class IntersectionInfo {
  66204. bu: Nullable<number>;
  66205. bv: Nullable<number>;
  66206. distance: number;
  66207. faceId: number;
  66208. subMeshId: number;
  66209. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  66210. }
  66211. }
  66212. declare module BABYLON {
  66213. /**
  66214. * Class used to store bounding sphere information
  66215. */
  66216. export class BoundingSphere {
  66217. /**
  66218. * Gets the center of the bounding sphere in local space
  66219. */
  66220. readonly center: Vector3;
  66221. /**
  66222. * Radius of the bounding sphere in local space
  66223. */
  66224. radius: number;
  66225. /**
  66226. * Gets the center of the bounding sphere in world space
  66227. */
  66228. readonly centerWorld: Vector3;
  66229. /**
  66230. * Radius of the bounding sphere in world space
  66231. */
  66232. radiusWorld: number;
  66233. /**
  66234. * Gets the minimum vector in local space
  66235. */
  66236. readonly minimum: Vector3;
  66237. /**
  66238. * Gets the maximum vector in local space
  66239. */
  66240. readonly maximum: Vector3;
  66241. private _worldMatrix;
  66242. private static readonly TmpVector3;
  66243. /**
  66244. * Creates a new bounding sphere
  66245. * @param min defines the minimum vector (in local space)
  66246. * @param max defines the maximum vector (in local space)
  66247. * @param worldMatrix defines the new world matrix
  66248. */
  66249. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66250. /**
  66251. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  66252. * @param min defines the new minimum vector (in local space)
  66253. * @param max defines the new maximum vector (in local space)
  66254. * @param worldMatrix defines the new world matrix
  66255. */
  66256. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66257. /**
  66258. * Scale the current bounding sphere by applying a scale factor
  66259. * @param factor defines the scale factor to apply
  66260. * @returns the current bounding box
  66261. */
  66262. scale(factor: number): BoundingSphere;
  66263. /**
  66264. * Gets the world matrix of the bounding box
  66265. * @returns a matrix
  66266. */
  66267. getWorldMatrix(): DeepImmutable<Matrix>;
  66268. /** @hidden */
  66269. _update(worldMatrix: DeepImmutable<Matrix>): void;
  66270. /**
  66271. * Tests if the bounding sphere is intersecting the frustum planes
  66272. * @param frustumPlanes defines the frustum planes to test
  66273. * @returns true if there is an intersection
  66274. */
  66275. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66276. /**
  66277. * Tests if the bounding sphere center is in between the frustum planes.
  66278. * Used for optimistic fast inclusion.
  66279. * @param frustumPlanes defines the frustum planes to test
  66280. * @returns true if the sphere center is in between the frustum planes
  66281. */
  66282. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66283. /**
  66284. * Tests if a point is inside the bounding sphere
  66285. * @param point defines the point to test
  66286. * @returns true if the point is inside the bounding sphere
  66287. */
  66288. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66289. /**
  66290. * Checks if two sphere intersct
  66291. * @param sphere0 sphere 0
  66292. * @param sphere1 sphere 1
  66293. * @returns true if the speres intersect
  66294. */
  66295. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  66296. }
  66297. }
  66298. declare module BABYLON {
  66299. /**
  66300. * Class used to store bounding box information
  66301. */
  66302. export class BoundingBox implements ICullable {
  66303. /**
  66304. * Gets the 8 vectors representing the bounding box in local space
  66305. */
  66306. readonly vectors: Vector3[];
  66307. /**
  66308. * Gets the center of the bounding box in local space
  66309. */
  66310. readonly center: Vector3;
  66311. /**
  66312. * Gets the center of the bounding box in world space
  66313. */
  66314. readonly centerWorld: Vector3;
  66315. /**
  66316. * Gets the extend size in local space
  66317. */
  66318. readonly extendSize: Vector3;
  66319. /**
  66320. * Gets the extend size in world space
  66321. */
  66322. readonly extendSizeWorld: Vector3;
  66323. /**
  66324. * Gets the OBB (object bounding box) directions
  66325. */
  66326. readonly directions: Vector3[];
  66327. /**
  66328. * Gets the 8 vectors representing the bounding box in world space
  66329. */
  66330. readonly vectorsWorld: Vector3[];
  66331. /**
  66332. * Gets the minimum vector in world space
  66333. */
  66334. readonly minimumWorld: Vector3;
  66335. /**
  66336. * Gets the maximum vector in world space
  66337. */
  66338. readonly maximumWorld: Vector3;
  66339. /**
  66340. * Gets the minimum vector in local space
  66341. */
  66342. readonly minimum: Vector3;
  66343. /**
  66344. * Gets the maximum vector in local space
  66345. */
  66346. readonly maximum: Vector3;
  66347. private _worldMatrix;
  66348. private static readonly TmpVector3;
  66349. /**
  66350. * @hidden
  66351. */
  66352. _tag: number;
  66353. /**
  66354. * Creates a new bounding box
  66355. * @param min defines the minimum vector (in local space)
  66356. * @param max defines the maximum vector (in local space)
  66357. * @param worldMatrix defines the new world matrix
  66358. */
  66359. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66360. /**
  66361. * Recreates the entire bounding box from scratch as if we call the constructor in place
  66362. * @param min defines the new minimum vector (in local space)
  66363. * @param max defines the new maximum vector (in local space)
  66364. * @param worldMatrix defines the new world matrix
  66365. */
  66366. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66367. /**
  66368. * Scale the current bounding box by applying a scale factor
  66369. * @param factor defines the scale factor to apply
  66370. * @returns the current bounding box
  66371. */
  66372. scale(factor: number): BoundingBox;
  66373. /**
  66374. * Gets the world matrix of the bounding box
  66375. * @returns a matrix
  66376. */
  66377. getWorldMatrix(): DeepImmutable<Matrix>;
  66378. /** @hidden */
  66379. _update(world: DeepImmutable<Matrix>): void;
  66380. /**
  66381. * Tests if the bounding box is intersecting the frustum planes
  66382. * @param frustumPlanes defines the frustum planes to test
  66383. * @returns true if there is an intersection
  66384. */
  66385. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66386. /**
  66387. * Tests if the bounding box is entirely inside the frustum planes
  66388. * @param frustumPlanes defines the frustum planes to test
  66389. * @returns true if there is an inclusion
  66390. */
  66391. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66392. /**
  66393. * Tests if a point is inside the bounding box
  66394. * @param point defines the point to test
  66395. * @returns true if the point is inside the bounding box
  66396. */
  66397. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66398. /**
  66399. * Tests if the bounding box intersects with a bounding sphere
  66400. * @param sphere defines the sphere to test
  66401. * @returns true if there is an intersection
  66402. */
  66403. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  66404. /**
  66405. * Tests if the bounding box intersects with a box defined by a min and max vectors
  66406. * @param min defines the min vector to use
  66407. * @param max defines the max vector to use
  66408. * @returns true if there is an intersection
  66409. */
  66410. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  66411. /**
  66412. * Tests if two bounding boxes are intersections
  66413. * @param box0 defines the first box to test
  66414. * @param box1 defines the second box to test
  66415. * @returns true if there is an intersection
  66416. */
  66417. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  66418. /**
  66419. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  66420. * @param minPoint defines the minimum vector of the bounding box
  66421. * @param maxPoint defines the maximum vector of the bounding box
  66422. * @param sphereCenter defines the sphere center
  66423. * @param sphereRadius defines the sphere radius
  66424. * @returns true if there is an intersection
  66425. */
  66426. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  66427. /**
  66428. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  66429. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66430. * @param frustumPlanes defines the frustum planes to test
  66431. * @return true if there is an inclusion
  66432. */
  66433. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66434. /**
  66435. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  66436. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66437. * @param frustumPlanes defines the frustum planes to test
  66438. * @return true if there is an intersection
  66439. */
  66440. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66441. }
  66442. }
  66443. declare module BABYLON {
  66444. /** @hidden */
  66445. export class Collider {
  66446. /** Define if a collision was found */
  66447. collisionFound: boolean;
  66448. /**
  66449. * Define last intersection point in local space
  66450. */
  66451. intersectionPoint: Vector3;
  66452. /**
  66453. * Define last collided mesh
  66454. */
  66455. collidedMesh: Nullable<AbstractMesh>;
  66456. private _collisionPoint;
  66457. private _planeIntersectionPoint;
  66458. private _tempVector;
  66459. private _tempVector2;
  66460. private _tempVector3;
  66461. private _tempVector4;
  66462. private _edge;
  66463. private _baseToVertex;
  66464. private _destinationPoint;
  66465. private _slidePlaneNormal;
  66466. private _displacementVector;
  66467. /** @hidden */
  66468. _radius: Vector3;
  66469. /** @hidden */
  66470. _retry: number;
  66471. private _velocity;
  66472. private _basePoint;
  66473. private _epsilon;
  66474. /** @hidden */
  66475. _velocityWorldLength: number;
  66476. /** @hidden */
  66477. _basePointWorld: Vector3;
  66478. private _velocityWorld;
  66479. private _normalizedVelocity;
  66480. /** @hidden */
  66481. _initialVelocity: Vector3;
  66482. /** @hidden */
  66483. _initialPosition: Vector3;
  66484. private _nearestDistance;
  66485. private _collisionMask;
  66486. collisionMask: number;
  66487. /**
  66488. * Gets the plane normal used to compute the sliding response (in local space)
  66489. */
  66490. readonly slidePlaneNormal: Vector3;
  66491. /** @hidden */
  66492. _initialize(source: Vector3, dir: Vector3, e: number): void;
  66493. /** @hidden */
  66494. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  66495. /** @hidden */
  66496. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  66497. /** @hidden */
  66498. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  66499. /** @hidden */
  66500. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  66501. /** @hidden */
  66502. _getResponse(pos: Vector3, vel: Vector3): void;
  66503. }
  66504. }
  66505. declare module BABYLON {
  66506. /**
  66507. * Interface for cullable objects
  66508. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  66509. */
  66510. export interface ICullable {
  66511. /**
  66512. * Checks if the object or part of the object is in the frustum
  66513. * @param frustumPlanes Camera near/planes
  66514. * @returns true if the object is in frustum otherwise false
  66515. */
  66516. isInFrustum(frustumPlanes: Plane[]): boolean;
  66517. /**
  66518. * Checks if a cullable object (mesh...) is in the camera frustum
  66519. * Unlike isInFrustum this cheks the full bounding box
  66520. * @param frustumPlanes Camera near/planes
  66521. * @returns true if the object is in frustum otherwise false
  66522. */
  66523. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  66524. }
  66525. /**
  66526. * Info for a bounding data of a mesh
  66527. */
  66528. export class BoundingInfo implements ICullable {
  66529. /**
  66530. * Bounding box for the mesh
  66531. */
  66532. readonly boundingBox: BoundingBox;
  66533. /**
  66534. * Bounding sphere for the mesh
  66535. */
  66536. readonly boundingSphere: BoundingSphere;
  66537. private _isLocked;
  66538. private static readonly TmpVector3;
  66539. /**
  66540. * Constructs bounding info
  66541. * @param minimum min vector of the bounding box/sphere
  66542. * @param maximum max vector of the bounding box/sphere
  66543. * @param worldMatrix defines the new world matrix
  66544. */
  66545. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66546. /**
  66547. * Recreates the entire bounding info from scratch as if we call the constructor in place
  66548. * @param min defines the new minimum vector (in local space)
  66549. * @param max defines the new maximum vector (in local space)
  66550. * @param worldMatrix defines the new world matrix
  66551. */
  66552. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66553. /**
  66554. * min vector of the bounding box/sphere
  66555. */
  66556. readonly minimum: Vector3;
  66557. /**
  66558. * max vector of the bounding box/sphere
  66559. */
  66560. readonly maximum: Vector3;
  66561. /**
  66562. * If the info is locked and won't be updated to avoid perf overhead
  66563. */
  66564. isLocked: boolean;
  66565. /**
  66566. * Updates the bounding sphere and box
  66567. * @param world world matrix to be used to update
  66568. */
  66569. update(world: DeepImmutable<Matrix>): void;
  66570. /**
  66571. * Recreate the bounding info to be centered around a specific point given a specific extend.
  66572. * @param center New center of the bounding info
  66573. * @param extend New extend of the bounding info
  66574. * @returns the current bounding info
  66575. */
  66576. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  66577. /**
  66578. * Scale the current bounding info by applying a scale factor
  66579. * @param factor defines the scale factor to apply
  66580. * @returns the current bounding info
  66581. */
  66582. scale(factor: number): BoundingInfo;
  66583. /**
  66584. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  66585. * @param frustumPlanes defines the frustum to test
  66586. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  66587. * @returns true if the bounding info is in the frustum planes
  66588. */
  66589. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  66590. /**
  66591. * Gets the world distance between the min and max points of the bounding box
  66592. */
  66593. readonly diagonalLength: number;
  66594. /**
  66595. * Checks if a cullable object (mesh...) is in the camera frustum
  66596. * Unlike isInFrustum this cheks the full bounding box
  66597. * @param frustumPlanes Camera near/planes
  66598. * @returns true if the object is in frustum otherwise false
  66599. */
  66600. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66601. /** @hidden */
  66602. _checkCollision(collider: Collider): boolean;
  66603. /**
  66604. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  66605. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  66606. * @param point the point to check intersection with
  66607. * @returns if the point intersects
  66608. */
  66609. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66610. /**
  66611. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  66612. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  66613. * @param boundingInfo the bounding info to check intersection with
  66614. * @param precise if the intersection should be done using OBB
  66615. * @returns if the bounding info intersects
  66616. */
  66617. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  66618. }
  66619. }
  66620. declare module BABYLON {
  66621. /**
  66622. * Defines an array and its length.
  66623. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  66624. */
  66625. export interface ISmartArrayLike<T> {
  66626. /**
  66627. * The data of the array.
  66628. */
  66629. data: Array<T>;
  66630. /**
  66631. * The active length of the array.
  66632. */
  66633. length: number;
  66634. }
  66635. /**
  66636. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  66637. */
  66638. export class SmartArray<T> implements ISmartArrayLike<T> {
  66639. /**
  66640. * The full set of data from the array.
  66641. */
  66642. data: Array<T>;
  66643. /**
  66644. * The active length of the array.
  66645. */
  66646. length: number;
  66647. protected _id: number;
  66648. /**
  66649. * Instantiates a Smart Array.
  66650. * @param capacity defines the default capacity of the array.
  66651. */
  66652. constructor(capacity: number);
  66653. /**
  66654. * Pushes a value at the end of the active data.
  66655. * @param value defines the object to push in the array.
  66656. */
  66657. push(value: T): void;
  66658. /**
  66659. * Iterates over the active data and apply the lambda to them.
  66660. * @param func defines the action to apply on each value.
  66661. */
  66662. forEach(func: (content: T) => void): void;
  66663. /**
  66664. * Sorts the full sets of data.
  66665. * @param compareFn defines the comparison function to apply.
  66666. */
  66667. sort(compareFn: (a: T, b: T) => number): void;
  66668. /**
  66669. * Resets the active data to an empty array.
  66670. */
  66671. reset(): void;
  66672. /**
  66673. * Releases all the data from the array as well as the array.
  66674. */
  66675. dispose(): void;
  66676. /**
  66677. * Concats the active data with a given array.
  66678. * @param array defines the data to concatenate with.
  66679. */
  66680. concat(array: any): void;
  66681. /**
  66682. * Returns the position of a value in the active data.
  66683. * @param value defines the value to find the index for
  66684. * @returns the index if found in the active data otherwise -1
  66685. */
  66686. indexOf(value: T): number;
  66687. /**
  66688. * Returns whether an element is part of the active data.
  66689. * @param value defines the value to look for
  66690. * @returns true if found in the active data otherwise false
  66691. */
  66692. contains(value: T): boolean;
  66693. private static _GlobalId;
  66694. }
  66695. /**
  66696. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  66697. * The data in this array can only be present once
  66698. */
  66699. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  66700. private _duplicateId;
  66701. /**
  66702. * Pushes a value at the end of the active data.
  66703. * THIS DOES NOT PREVENT DUPPLICATE DATA
  66704. * @param value defines the object to push in the array.
  66705. */
  66706. push(value: T): void;
  66707. /**
  66708. * Pushes a value at the end of the active data.
  66709. * If the data is already present, it won t be added again
  66710. * @param value defines the object to push in the array.
  66711. * @returns true if added false if it was already present
  66712. */
  66713. pushNoDuplicate(value: T): boolean;
  66714. /**
  66715. * Resets the active data to an empty array.
  66716. */
  66717. reset(): void;
  66718. /**
  66719. * Concats the active data with a given array.
  66720. * This ensures no dupplicate will be present in the result.
  66721. * @param array defines the data to concatenate with.
  66722. */
  66723. concatWithNoDuplicate(array: any): void;
  66724. }
  66725. }
  66726. declare module BABYLON {
  66727. /**
  66728. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66729. * separate meshes. This can be use to improve performances.
  66730. * @see http://doc.babylonjs.com/how_to/multi_materials
  66731. */
  66732. export class MultiMaterial extends Material {
  66733. private _subMaterials;
  66734. /**
  66735. * Gets or Sets the list of Materials used within the multi material.
  66736. * They need to be ordered according to the submeshes order in the associated mesh
  66737. */
  66738. subMaterials: Nullable<Material>[];
  66739. /**
  66740. * Function used to align with Node.getChildren()
  66741. * @returns the list of Materials used within the multi material
  66742. */
  66743. getChildren(): Nullable<Material>[];
  66744. /**
  66745. * Instantiates a new Multi Material
  66746. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66747. * separate meshes. This can be use to improve performances.
  66748. * @see http://doc.babylonjs.com/how_to/multi_materials
  66749. * @param name Define the name in the scene
  66750. * @param scene Define the scene the material belongs to
  66751. */
  66752. constructor(name: string, scene: Scene);
  66753. private _hookArray;
  66754. /**
  66755. * Get one of the submaterial by its index in the submaterials array
  66756. * @param index The index to look the sub material at
  66757. * @returns The Material if the index has been defined
  66758. */
  66759. getSubMaterial(index: number): Nullable<Material>;
  66760. /**
  66761. * Get the list of active textures for the whole sub materials list.
  66762. * @returns All the textures that will be used during the rendering
  66763. */
  66764. getActiveTextures(): BaseTexture[];
  66765. /**
  66766. * Gets the current class name of the material e.g. "MultiMaterial"
  66767. * Mainly use in serialization.
  66768. * @returns the class name
  66769. */
  66770. getClassName(): string;
  66771. /**
  66772. * Checks if the material is ready to render the requested sub mesh
  66773. * @param mesh Define the mesh the submesh belongs to
  66774. * @param subMesh Define the sub mesh to look readyness for
  66775. * @param useInstances Define whether or not the material is used with instances
  66776. * @returns true if ready, otherwise false
  66777. */
  66778. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  66779. /**
  66780. * Clones the current material and its related sub materials
  66781. * @param name Define the name of the newly cloned material
  66782. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  66783. * @returns the cloned material
  66784. */
  66785. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  66786. /**
  66787. * Serializes the materials into a JSON representation.
  66788. * @returns the JSON representation
  66789. */
  66790. serialize(): any;
  66791. /**
  66792. * Dispose the material and release its associated resources
  66793. * @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)
  66794. * @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)
  66795. * @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)
  66796. */
  66797. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  66798. /**
  66799. * Creates a MultiMaterial from parsed MultiMaterial data.
  66800. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  66801. * @param scene defines the hosting scene
  66802. * @returns a new MultiMaterial
  66803. */
  66804. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  66805. }
  66806. }
  66807. declare module BABYLON {
  66808. /**
  66809. * Class used to represent data loading progression
  66810. */
  66811. export class SceneLoaderFlags {
  66812. private static _ForceFullSceneLoadingForIncremental;
  66813. private static _ShowLoadingScreen;
  66814. private static _CleanBoneMatrixWeights;
  66815. private static _loggingLevel;
  66816. /**
  66817. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  66818. */
  66819. static ForceFullSceneLoadingForIncremental: boolean;
  66820. /**
  66821. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  66822. */
  66823. static ShowLoadingScreen: boolean;
  66824. /**
  66825. * Defines the current logging level (while loading the scene)
  66826. * @ignorenaming
  66827. */
  66828. static loggingLevel: number;
  66829. /**
  66830. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  66831. */
  66832. static CleanBoneMatrixWeights: boolean;
  66833. }
  66834. }
  66835. declare module BABYLON {
  66836. /**
  66837. * 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.
  66838. * @see https://doc.babylonjs.com/how_to/transformnode
  66839. */
  66840. export class TransformNode extends Node {
  66841. /**
  66842. * Object will not rotate to face the camera
  66843. */
  66844. static BILLBOARDMODE_NONE: number;
  66845. /**
  66846. * Object will rotate to face the camera but only on the x axis
  66847. */
  66848. static BILLBOARDMODE_X: number;
  66849. /**
  66850. * Object will rotate to face the camera but only on the y axis
  66851. */
  66852. static BILLBOARDMODE_Y: number;
  66853. /**
  66854. * Object will rotate to face the camera but only on the z axis
  66855. */
  66856. static BILLBOARDMODE_Z: number;
  66857. /**
  66858. * Object will rotate to face the camera
  66859. */
  66860. static BILLBOARDMODE_ALL: number;
  66861. private _forward;
  66862. private _forwardInverted;
  66863. private _up;
  66864. private _right;
  66865. private _rightInverted;
  66866. private _position;
  66867. private _rotation;
  66868. private _rotationQuaternion;
  66869. protected _scaling: Vector3;
  66870. protected _isDirty: boolean;
  66871. private _transformToBoneReferal;
  66872. private _billboardMode;
  66873. /**
  66874. * Gets or sets the billboard mode. Default is 0.
  66875. *
  66876. * | Value | Type | Description |
  66877. * | --- | --- | --- |
  66878. * | 0 | BILLBOARDMODE_NONE | |
  66879. * | 1 | BILLBOARDMODE_X | |
  66880. * | 2 | BILLBOARDMODE_Y | |
  66881. * | 4 | BILLBOARDMODE_Z | |
  66882. * | 7 | BILLBOARDMODE_ALL | |
  66883. *
  66884. */
  66885. billboardMode: number;
  66886. private _preserveParentRotationForBillboard;
  66887. /**
  66888. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  66889. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  66890. */
  66891. preserveParentRotationForBillboard: boolean;
  66892. /**
  66893. * 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
  66894. */
  66895. scalingDeterminant: number;
  66896. /**
  66897. * Sets the distance of the object to max, often used by skybox
  66898. */
  66899. infiniteDistance: boolean;
  66900. /**
  66901. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  66902. * By default the system will update normals to compensate
  66903. */
  66904. ignoreNonUniformScaling: boolean;
  66905. /**
  66906. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  66907. */
  66908. reIntegrateRotationIntoRotationQuaternion: boolean;
  66909. /** @hidden */
  66910. _poseMatrix: Matrix;
  66911. /** @hidden */
  66912. _localMatrix: Matrix;
  66913. private _absolutePosition;
  66914. private _pivotMatrix;
  66915. private _pivotMatrixInverse;
  66916. protected _postMultiplyPivotMatrix: boolean;
  66917. protected _isWorldMatrixFrozen: boolean;
  66918. /** @hidden */
  66919. _indexInSceneTransformNodesArray: number;
  66920. private _connectBillboardProcessors;
  66921. /**
  66922. * An event triggered after the world matrix is updated
  66923. */
  66924. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  66925. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  66926. /**
  66927. * Gets a string identifying the name of the class
  66928. * @returns "TransformNode" string
  66929. */
  66930. getClassName(): string;
  66931. /**
  66932. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  66933. */
  66934. position: Vector3;
  66935. /**
  66936. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  66937. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  66938. */
  66939. rotation: Vector3;
  66940. /**
  66941. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  66942. */
  66943. scaling: Vector3;
  66944. /**
  66945. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  66946. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  66947. */
  66948. rotationQuaternion: Nullable<Quaternion>;
  66949. /**
  66950. * The forward direction of that transform in world space.
  66951. */
  66952. readonly forward: Vector3;
  66953. /**
  66954. * The up direction of that transform in world space.
  66955. */
  66956. readonly up: Vector3;
  66957. /**
  66958. * The right direction of that transform in world space.
  66959. */
  66960. readonly right: Vector3;
  66961. /**
  66962. * Copies the parameter passed Matrix into the mesh Pose matrix.
  66963. * @param matrix the matrix to copy the pose from
  66964. * @returns this TransformNode.
  66965. */
  66966. updatePoseMatrix(matrix: Matrix): TransformNode;
  66967. /**
  66968. * Returns the mesh Pose matrix.
  66969. * @returns the pose matrix
  66970. */
  66971. getPoseMatrix(): Matrix;
  66972. /** @hidden */
  66973. _isSynchronized(): boolean;
  66974. /** @hidden */
  66975. _initCache(): void;
  66976. /**
  66977. * Flag the transform node as dirty (Forcing it to update everything)
  66978. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  66979. * @returns this transform node
  66980. */
  66981. markAsDirty(property: string): TransformNode;
  66982. /**
  66983. * Returns the current mesh absolute position.
  66984. * Returns a Vector3.
  66985. */
  66986. readonly absolutePosition: Vector3;
  66987. /**
  66988. * Sets a new matrix to apply before all other transformation
  66989. * @param matrix defines the transform matrix
  66990. * @returns the current TransformNode
  66991. */
  66992. setPreTransformMatrix(matrix: Matrix): TransformNode;
  66993. /**
  66994. * Sets a new pivot matrix to the current node
  66995. * @param matrix defines the new pivot matrix to use
  66996. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  66997. * @returns the current TransformNode
  66998. */
  66999. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  67000. /**
  67001. * Returns the mesh pivot matrix.
  67002. * Default : Identity.
  67003. * @returns the matrix
  67004. */
  67005. getPivotMatrix(): Matrix;
  67006. /**
  67007. * Prevents the World matrix to be computed any longer.
  67008. * @returns the TransformNode.
  67009. */
  67010. freezeWorldMatrix(): TransformNode;
  67011. /**
  67012. * Allows back the World matrix computation.
  67013. * @returns the TransformNode.
  67014. */
  67015. unfreezeWorldMatrix(): this;
  67016. /**
  67017. * True if the World matrix has been frozen.
  67018. */
  67019. readonly isWorldMatrixFrozen: boolean;
  67020. /**
  67021. * Retuns the mesh absolute position in the World.
  67022. * @returns a Vector3.
  67023. */
  67024. getAbsolutePosition(): Vector3;
  67025. /**
  67026. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  67027. * @param absolutePosition the absolute position to set
  67028. * @returns the TransformNode.
  67029. */
  67030. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  67031. /**
  67032. * Sets the mesh position in its local space.
  67033. * @param vector3 the position to set in localspace
  67034. * @returns the TransformNode.
  67035. */
  67036. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  67037. /**
  67038. * Returns the mesh position in the local space from the current World matrix values.
  67039. * @returns a new Vector3.
  67040. */
  67041. getPositionExpressedInLocalSpace(): Vector3;
  67042. /**
  67043. * Translates the mesh along the passed Vector3 in its local space.
  67044. * @param vector3 the distance to translate in localspace
  67045. * @returns the TransformNode.
  67046. */
  67047. locallyTranslate(vector3: Vector3): TransformNode;
  67048. private static _lookAtVectorCache;
  67049. /**
  67050. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  67051. * @param targetPoint the position (must be in same space as current mesh) to look at
  67052. * @param yawCor optional yaw (y-axis) correction in radians
  67053. * @param pitchCor optional pitch (x-axis) correction in radians
  67054. * @param rollCor optional roll (z-axis) correction in radians
  67055. * @param space the choosen space of the target
  67056. * @returns the TransformNode.
  67057. */
  67058. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  67059. /**
  67060. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67061. * This Vector3 is expressed in the World space.
  67062. * @param localAxis axis to rotate
  67063. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67064. */
  67065. getDirection(localAxis: Vector3): Vector3;
  67066. /**
  67067. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  67068. * localAxis is expressed in the mesh local space.
  67069. * result is computed in the Wordl space from the mesh World matrix.
  67070. * @param localAxis axis to rotate
  67071. * @param result the resulting transformnode
  67072. * @returns this TransformNode.
  67073. */
  67074. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  67075. /**
  67076. * Sets this transform node rotation to the given local axis.
  67077. * @param localAxis the axis in local space
  67078. * @param yawCor optional yaw (y-axis) correction in radians
  67079. * @param pitchCor optional pitch (x-axis) correction in radians
  67080. * @param rollCor optional roll (z-axis) correction in radians
  67081. * @returns this TransformNode
  67082. */
  67083. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  67084. /**
  67085. * Sets a new pivot point to the current node
  67086. * @param point defines the new pivot point to use
  67087. * @param space defines if the point is in world or local space (local by default)
  67088. * @returns the current TransformNode
  67089. */
  67090. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  67091. /**
  67092. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  67093. * @returns the pivot point
  67094. */
  67095. getPivotPoint(): Vector3;
  67096. /**
  67097. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  67098. * @param result the vector3 to store the result
  67099. * @returns this TransformNode.
  67100. */
  67101. getPivotPointToRef(result: Vector3): TransformNode;
  67102. /**
  67103. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  67104. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  67105. */
  67106. getAbsolutePivotPoint(): Vector3;
  67107. /**
  67108. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  67109. * @param result vector3 to store the result
  67110. * @returns this TransformNode.
  67111. */
  67112. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  67113. /**
  67114. * Defines the passed node as the parent of the current node.
  67115. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  67116. * @see https://doc.babylonjs.com/how_to/parenting
  67117. * @param node the node ot set as the parent
  67118. * @returns this TransformNode.
  67119. */
  67120. setParent(node: Nullable<Node>): TransformNode;
  67121. private _nonUniformScaling;
  67122. /**
  67123. * True if the scaling property of this object is non uniform eg. (1,2,1)
  67124. */
  67125. readonly nonUniformScaling: boolean;
  67126. /** @hidden */
  67127. _updateNonUniformScalingState(value: boolean): boolean;
  67128. /**
  67129. * Attach the current TransformNode to another TransformNode associated with a bone
  67130. * @param bone Bone affecting the TransformNode
  67131. * @param affectedTransformNode TransformNode associated with the bone
  67132. * @returns this object
  67133. */
  67134. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  67135. /**
  67136. * Detach the transform node if its associated with a bone
  67137. * @returns this object
  67138. */
  67139. detachFromBone(): TransformNode;
  67140. private static _rotationAxisCache;
  67141. /**
  67142. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  67143. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67144. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67145. * The passed axis is also normalized.
  67146. * @param axis the axis to rotate around
  67147. * @param amount the amount to rotate in radians
  67148. * @param space Space to rotate in (Default: local)
  67149. * @returns the TransformNode.
  67150. */
  67151. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  67152. /**
  67153. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  67154. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67155. * The passed axis is also normalized. .
  67156. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  67157. * @param point the point to rotate around
  67158. * @param axis the axis to rotate around
  67159. * @param amount the amount to rotate in radians
  67160. * @returns the TransformNode
  67161. */
  67162. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  67163. /**
  67164. * Translates the mesh along the axis vector for the passed distance in the given space.
  67165. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67166. * @param axis the axis to translate in
  67167. * @param distance the distance to translate
  67168. * @param space Space to rotate in (Default: local)
  67169. * @returns the TransformNode.
  67170. */
  67171. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  67172. /**
  67173. * Adds a rotation step to the mesh current rotation.
  67174. * x, y, z are Euler angles expressed in radians.
  67175. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  67176. * This means this rotation is made in the mesh local space only.
  67177. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  67178. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  67179. * ```javascript
  67180. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  67181. * ```
  67182. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  67183. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  67184. * @param x Rotation to add
  67185. * @param y Rotation to add
  67186. * @param z Rotation to add
  67187. * @returns the TransformNode.
  67188. */
  67189. addRotation(x: number, y: number, z: number): TransformNode;
  67190. /**
  67191. * @hidden
  67192. */
  67193. protected _getEffectiveParent(): Nullable<Node>;
  67194. private _activeCompositionProcess;
  67195. private _defaultCompositionProcessor;
  67196. private _pivotCompositionProcessor;
  67197. private _activeParentProcessor;
  67198. private _activeBillboardPostProcessor;
  67199. private _defaultParentProcessor;
  67200. private _billboardParentProcessor;
  67201. private _billboardPostProcessor;
  67202. /**
  67203. * Computes the world matrix of the node
  67204. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67205. * @returns the world matrix
  67206. */
  67207. computeWorldMatrix(force?: boolean): Matrix;
  67208. protected _afterComputeWorldMatrix(): void;
  67209. /**
  67210. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  67211. * @param func callback function to add
  67212. *
  67213. * @returns the TransformNode.
  67214. */
  67215. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67216. /**
  67217. * Removes a registered callback function.
  67218. * @param func callback function to remove
  67219. * @returns the TransformNode.
  67220. */
  67221. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67222. /**
  67223. * Gets the position of the current mesh in camera space
  67224. * @param camera defines the camera to use
  67225. * @returns a position
  67226. */
  67227. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  67228. /**
  67229. * Returns the distance from the mesh to the active camera
  67230. * @param camera defines the camera to use
  67231. * @returns the distance
  67232. */
  67233. getDistanceToCamera(camera?: Nullable<Camera>): number;
  67234. /**
  67235. * Clone the current transform node
  67236. * @param name Name of the new clone
  67237. * @param newParent New parent for the clone
  67238. * @param doNotCloneChildren Do not clone children hierarchy
  67239. * @returns the new transform node
  67240. */
  67241. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  67242. /**
  67243. * Serializes the objects information.
  67244. * @param currentSerializationObject defines the object to serialize in
  67245. * @returns the serialized object
  67246. */
  67247. serialize(currentSerializationObject?: any): any;
  67248. /**
  67249. * Returns a new TransformNode object parsed from the source provided.
  67250. * @param parsedTransformNode is the source.
  67251. * @param scene the scne the object belongs to
  67252. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  67253. * @returns a new TransformNode object parsed from the source provided.
  67254. */
  67255. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  67256. /**
  67257. * Get all child-transformNodes of this node
  67258. * @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
  67259. * @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
  67260. * @returns an array of TransformNode
  67261. */
  67262. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  67263. /**
  67264. * Releases resources associated with this transform node.
  67265. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67266. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67267. */
  67268. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67269. }
  67270. }
  67271. declare module BABYLON {
  67272. /**
  67273. * Class used to override all child animations of a given target
  67274. */
  67275. export class AnimationPropertiesOverride {
  67276. /**
  67277. * Gets or sets a value indicating if animation blending must be used
  67278. */
  67279. enableBlending: boolean;
  67280. /**
  67281. * Gets or sets the blending speed to use when enableBlending is true
  67282. */
  67283. blendingSpeed: number;
  67284. /**
  67285. * Gets or sets the default loop mode to use
  67286. */
  67287. loopMode: number;
  67288. }
  67289. }
  67290. declare module BABYLON {
  67291. /**
  67292. * Class used to store bone information
  67293. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  67294. */
  67295. export class Bone extends Node {
  67296. /**
  67297. * defines the bone name
  67298. */
  67299. name: string;
  67300. private static _tmpVecs;
  67301. private static _tmpQuat;
  67302. private static _tmpMats;
  67303. /**
  67304. * Gets the list of child bones
  67305. */
  67306. children: Bone[];
  67307. /** Gets the animations associated with this bone */
  67308. animations: Animation[];
  67309. /**
  67310. * Gets or sets bone length
  67311. */
  67312. length: number;
  67313. /**
  67314. * @hidden Internal only
  67315. * Set this value to map this bone to a different index in the transform matrices
  67316. * Set this value to -1 to exclude the bone from the transform matrices
  67317. */
  67318. _index: Nullable<number>;
  67319. private _skeleton;
  67320. private _localMatrix;
  67321. private _restPose;
  67322. private _baseMatrix;
  67323. private _absoluteTransform;
  67324. private _invertedAbsoluteTransform;
  67325. private _parent;
  67326. private _scalingDeterminant;
  67327. private _worldTransform;
  67328. private _localScaling;
  67329. private _localRotation;
  67330. private _localPosition;
  67331. private _needToDecompose;
  67332. private _needToCompose;
  67333. /** @hidden */
  67334. _linkedTransformNode: Nullable<TransformNode>;
  67335. /** @hidden */
  67336. /** @hidden */
  67337. _matrix: Matrix;
  67338. /**
  67339. * Create a new bone
  67340. * @param name defines the bone name
  67341. * @param skeleton defines the parent skeleton
  67342. * @param parentBone defines the parent (can be null if the bone is the root)
  67343. * @param localMatrix defines the local matrix
  67344. * @param restPose defines the rest pose matrix
  67345. * @param baseMatrix defines the base matrix
  67346. * @param index defines index of the bone in the hiearchy
  67347. */
  67348. constructor(
  67349. /**
  67350. * defines the bone name
  67351. */
  67352. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  67353. /**
  67354. * Gets the current object class name.
  67355. * @return the class name
  67356. */
  67357. getClassName(): string;
  67358. /**
  67359. * Gets the parent skeleton
  67360. * @returns a skeleton
  67361. */
  67362. getSkeleton(): Skeleton;
  67363. /**
  67364. * Gets parent bone
  67365. * @returns a bone or null if the bone is the root of the bone hierarchy
  67366. */
  67367. getParent(): Nullable<Bone>;
  67368. /**
  67369. * Returns an array containing the root bones
  67370. * @returns an array containing the root bones
  67371. */
  67372. getChildren(): Array<Bone>;
  67373. /**
  67374. * Sets the parent bone
  67375. * @param parent defines the parent (can be null if the bone is the root)
  67376. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67377. */
  67378. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  67379. /**
  67380. * Gets the local matrix
  67381. * @returns a matrix
  67382. */
  67383. getLocalMatrix(): Matrix;
  67384. /**
  67385. * Gets the base matrix (initial matrix which remains unchanged)
  67386. * @returns a matrix
  67387. */
  67388. getBaseMatrix(): Matrix;
  67389. /**
  67390. * Gets the rest pose matrix
  67391. * @returns a matrix
  67392. */
  67393. getRestPose(): Matrix;
  67394. /**
  67395. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  67396. */
  67397. getWorldMatrix(): Matrix;
  67398. /**
  67399. * Sets the local matrix to rest pose matrix
  67400. */
  67401. returnToRest(): void;
  67402. /**
  67403. * Gets the inverse of the absolute transform matrix.
  67404. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  67405. * @returns a matrix
  67406. */
  67407. getInvertedAbsoluteTransform(): Matrix;
  67408. /**
  67409. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  67410. * @returns a matrix
  67411. */
  67412. getAbsoluteTransform(): Matrix;
  67413. /**
  67414. * Links with the given transform node.
  67415. * The local matrix of this bone is copied from the transform node every frame.
  67416. * @param transformNode defines the transform node to link to
  67417. */
  67418. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  67419. /** Gets or sets current position (in local space) */
  67420. position: Vector3;
  67421. /** Gets or sets current rotation (in local space) */
  67422. rotation: Vector3;
  67423. /** Gets or sets current rotation quaternion (in local space) */
  67424. rotationQuaternion: Quaternion;
  67425. /** Gets or sets current scaling (in local space) */
  67426. scaling: Vector3;
  67427. /**
  67428. * Gets the animation properties override
  67429. */
  67430. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  67431. private _decompose;
  67432. private _compose;
  67433. /**
  67434. * Update the base and local matrices
  67435. * @param matrix defines the new base or local matrix
  67436. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67437. * @param updateLocalMatrix defines if the local matrix should be updated
  67438. */
  67439. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  67440. /** @hidden */
  67441. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  67442. /**
  67443. * Flag the bone as dirty (Forcing it to update everything)
  67444. */
  67445. markAsDirty(): void;
  67446. private _markAsDirtyAndCompose;
  67447. private _markAsDirtyAndDecompose;
  67448. /**
  67449. * Translate the bone in local or world space
  67450. * @param vec The amount to translate the bone
  67451. * @param space The space that the translation is in
  67452. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67453. */
  67454. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67455. /**
  67456. * Set the postion of the bone in local or world space
  67457. * @param position The position to set the bone
  67458. * @param space The space that the position is in
  67459. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67460. */
  67461. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67462. /**
  67463. * Set the absolute position of the bone (world space)
  67464. * @param position The position to set the bone
  67465. * @param mesh The mesh that this bone is attached to
  67466. */
  67467. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  67468. /**
  67469. * Scale the bone on the x, y and z axes (in local space)
  67470. * @param x The amount to scale the bone on the x axis
  67471. * @param y The amount to scale the bone on the y axis
  67472. * @param z The amount to scale the bone on the z axis
  67473. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  67474. */
  67475. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  67476. /**
  67477. * Set the bone scaling in local space
  67478. * @param scale defines the scaling vector
  67479. */
  67480. setScale(scale: Vector3): void;
  67481. /**
  67482. * Gets the current scaling in local space
  67483. * @returns the current scaling vector
  67484. */
  67485. getScale(): Vector3;
  67486. /**
  67487. * Gets the current scaling in local space and stores it in a target vector
  67488. * @param result defines the target vector
  67489. */
  67490. getScaleToRef(result: Vector3): void;
  67491. /**
  67492. * Set the yaw, pitch, and roll of the bone in local or world space
  67493. * @param yaw The rotation of the bone on the y axis
  67494. * @param pitch The rotation of the bone on the x axis
  67495. * @param roll The rotation of the bone on the z axis
  67496. * @param space The space that the axes of rotation are in
  67497. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67498. */
  67499. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  67500. /**
  67501. * Add a rotation to the bone on an axis in local or world space
  67502. * @param axis The axis to rotate the bone on
  67503. * @param amount The amount to rotate the bone
  67504. * @param space The space that the axis is in
  67505. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67506. */
  67507. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  67508. /**
  67509. * Set the rotation of the bone to a particular axis angle in local or world space
  67510. * @param axis The axis to rotate the bone on
  67511. * @param angle The angle that the bone should be rotated to
  67512. * @param space The space that the axis is in
  67513. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67514. */
  67515. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  67516. /**
  67517. * Set the euler rotation of the bone in local of world space
  67518. * @param rotation The euler rotation that the bone should be set to
  67519. * @param space The space that the rotation is in
  67520. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67521. */
  67522. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67523. /**
  67524. * Set the quaternion rotation of the bone in local of world space
  67525. * @param quat The quaternion rotation that the bone should be set to
  67526. * @param space The space that the rotation is in
  67527. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67528. */
  67529. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  67530. /**
  67531. * Set the rotation matrix of the bone in local of world space
  67532. * @param rotMat The rotation matrix that the bone should be set to
  67533. * @param space The space that the rotation is in
  67534. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67535. */
  67536. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  67537. private _rotateWithMatrix;
  67538. private _getNegativeRotationToRef;
  67539. /**
  67540. * Get the position of the bone in local or world space
  67541. * @param space The space that the returned position is in
  67542. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67543. * @returns The position of the bone
  67544. */
  67545. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  67546. /**
  67547. * Copy the position of the bone to a vector3 in local or world space
  67548. * @param space The space that the returned position is in
  67549. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67550. * @param result The vector3 to copy the position to
  67551. */
  67552. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  67553. /**
  67554. * Get the absolute position of the bone (world space)
  67555. * @param mesh The mesh that this bone is attached to
  67556. * @returns The absolute position of the bone
  67557. */
  67558. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  67559. /**
  67560. * Copy the absolute position of the bone (world space) to the result param
  67561. * @param mesh The mesh that this bone is attached to
  67562. * @param result The vector3 to copy the absolute position to
  67563. */
  67564. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  67565. /**
  67566. * Compute the absolute transforms of this bone and its children
  67567. */
  67568. computeAbsoluteTransforms(): void;
  67569. /**
  67570. * Get the world direction from an axis that is in the local space of the bone
  67571. * @param localAxis The local direction that is used to compute the world direction
  67572. * @param mesh The mesh that this bone is attached to
  67573. * @returns The world direction
  67574. */
  67575. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67576. /**
  67577. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  67578. * @param localAxis The local direction that is used to compute the world direction
  67579. * @param mesh The mesh that this bone is attached to
  67580. * @param result The vector3 that the world direction will be copied to
  67581. */
  67582. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67583. /**
  67584. * Get the euler rotation of the bone in local or world space
  67585. * @param space The space that the rotation should be in
  67586. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67587. * @returns The euler rotation
  67588. */
  67589. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  67590. /**
  67591. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  67592. * @param space The space that the rotation should be in
  67593. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67594. * @param result The vector3 that the rotation should be copied to
  67595. */
  67596. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67597. /**
  67598. * Get the quaternion rotation of the bone in either local or world space
  67599. * @param space The space that the rotation should be in
  67600. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67601. * @returns The quaternion rotation
  67602. */
  67603. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  67604. /**
  67605. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  67606. * @param space The space that the rotation should be in
  67607. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67608. * @param result The quaternion that the rotation should be copied to
  67609. */
  67610. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  67611. /**
  67612. * Get the rotation matrix of the bone in local or world space
  67613. * @param space The space that the rotation should be in
  67614. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67615. * @returns The rotation matrix
  67616. */
  67617. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  67618. /**
  67619. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  67620. * @param space The space that the rotation should be in
  67621. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67622. * @param result The quaternion that the rotation should be copied to
  67623. */
  67624. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  67625. /**
  67626. * Get the world position of a point that is in the local space of the bone
  67627. * @param position The local position
  67628. * @param mesh The mesh that this bone is attached to
  67629. * @returns The world position
  67630. */
  67631. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67632. /**
  67633. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  67634. * @param position The local position
  67635. * @param mesh The mesh that this bone is attached to
  67636. * @param result The vector3 that the world position should be copied to
  67637. */
  67638. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67639. /**
  67640. * Get the local position of a point that is in world space
  67641. * @param position The world position
  67642. * @param mesh The mesh that this bone is attached to
  67643. * @returns The local position
  67644. */
  67645. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67646. /**
  67647. * Get the local position of a point that is in world space and copy it to the result param
  67648. * @param position The world position
  67649. * @param mesh The mesh that this bone is attached to
  67650. * @param result The vector3 that the local position should be copied to
  67651. */
  67652. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67653. }
  67654. }
  67655. declare module BABYLON {
  67656. /**
  67657. * Enum that determines the text-wrapping mode to use.
  67658. */
  67659. export enum InspectableType {
  67660. /**
  67661. * Checkbox for booleans
  67662. */
  67663. Checkbox = 0,
  67664. /**
  67665. * Sliders for numbers
  67666. */
  67667. Slider = 1,
  67668. /**
  67669. * Vector3
  67670. */
  67671. Vector3 = 2,
  67672. /**
  67673. * Quaternions
  67674. */
  67675. Quaternion = 3,
  67676. /**
  67677. * Color3
  67678. */
  67679. Color3 = 4
  67680. }
  67681. /**
  67682. * Interface used to define custom inspectable properties.
  67683. * This interface is used by the inspector to display custom property grids
  67684. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  67685. */
  67686. export interface IInspectable {
  67687. /**
  67688. * Gets the label to display
  67689. */
  67690. label: string;
  67691. /**
  67692. * Gets the name of the property to edit
  67693. */
  67694. propertyName: string;
  67695. /**
  67696. * Gets the type of the editor to use
  67697. */
  67698. type: InspectableType;
  67699. /**
  67700. * Gets the minimum value of the property when using in "slider" mode
  67701. */
  67702. min?: number;
  67703. /**
  67704. * Gets the maximum value of the property when using in "slider" mode
  67705. */
  67706. max?: number;
  67707. /**
  67708. * Gets the setp to use when using in "slider" mode
  67709. */
  67710. step?: number;
  67711. }
  67712. }
  67713. declare module BABYLON {
  67714. /**
  67715. * Class for creating a cube texture
  67716. */
  67717. export class CubeTexture extends BaseTexture {
  67718. private _delayedOnLoad;
  67719. /**
  67720. * The url of the texture
  67721. */
  67722. url: string;
  67723. /**
  67724. * Gets or sets the center of the bounding box associated with the cube texture.
  67725. * It must define where the camera used to render the texture was set
  67726. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  67727. */
  67728. boundingBoxPosition: Vector3;
  67729. private _boundingBoxSize;
  67730. /**
  67731. * Gets or sets the size of the bounding box associated with the cube texture
  67732. * When defined, the cubemap will switch to local mode
  67733. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  67734. * @example https://www.babylonjs-playground.com/#RNASML
  67735. */
  67736. /**
  67737. * Returns the bounding box size
  67738. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  67739. */
  67740. boundingBoxSize: Vector3;
  67741. protected _rotationY: number;
  67742. /**
  67743. * Sets texture matrix rotation angle around Y axis in radians.
  67744. */
  67745. /**
  67746. * Gets texture matrix rotation angle around Y axis radians.
  67747. */
  67748. rotationY: number;
  67749. /**
  67750. * Are mip maps generated for this texture or not.
  67751. */
  67752. readonly noMipmap: boolean;
  67753. private _noMipmap;
  67754. private _files;
  67755. private _extensions;
  67756. private _textureMatrix;
  67757. private _format;
  67758. private _createPolynomials;
  67759. /** @hidden */
  67760. _prefiltered: boolean;
  67761. /**
  67762. * Creates a cube texture from an array of image urls
  67763. * @param files defines an array of image urls
  67764. * @param scene defines the hosting scene
  67765. * @param noMipmap specifies if mip maps are not used
  67766. * @returns a cube texture
  67767. */
  67768. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  67769. /**
  67770. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  67771. * @param url defines the url of the prefiltered texture
  67772. * @param scene defines the scene the texture is attached to
  67773. * @param forcedExtension defines the extension of the file if different from the url
  67774. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67775. * @return the prefiltered texture
  67776. */
  67777. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  67778. /**
  67779. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  67780. * as prefiltered data.
  67781. * @param rootUrl defines the url of the texture or the root name of the six images
  67782. * @param scene defines the scene the texture is attached to
  67783. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  67784. * @param noMipmap defines if mipmaps should be created or not
  67785. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  67786. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  67787. * @param onError defines a callback triggered in case of error during load
  67788. * @param format defines the internal format to use for the texture once loaded
  67789. * @param prefiltered defines whether or not the texture is created from prefiltered data
  67790. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  67791. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67792. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  67793. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  67794. * @return the cube texture
  67795. */
  67796. 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);
  67797. /**
  67798. * Get the current class name of the texture useful for serialization or dynamic coding.
  67799. * @returns "CubeTexture"
  67800. */
  67801. getClassName(): string;
  67802. /**
  67803. * Update the url (and optional buffer) of this texture if url was null during construction.
  67804. * @param url the url of the texture
  67805. * @param forcedExtension defines the extension to use
  67806. * @param onLoad callback called when the texture is loaded (defaults to null)
  67807. */
  67808. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  67809. /**
  67810. * Delays loading of the cube texture
  67811. * @param forcedExtension defines the extension to use
  67812. */
  67813. delayLoad(forcedExtension?: string): void;
  67814. /**
  67815. * Returns the reflection texture matrix
  67816. * @returns the reflection texture matrix
  67817. */
  67818. getReflectionTextureMatrix(): Matrix;
  67819. /**
  67820. * Sets the reflection texture matrix
  67821. * @param value Reflection texture matrix
  67822. */
  67823. setReflectionTextureMatrix(value: Matrix): void;
  67824. /**
  67825. * Parses text to create a cube texture
  67826. * @param parsedTexture define the serialized text to read from
  67827. * @param scene defines the hosting scene
  67828. * @param rootUrl defines the root url of the cube texture
  67829. * @returns a cube texture
  67830. */
  67831. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  67832. /**
  67833. * Makes a clone, or deep copy, of the cube texture
  67834. * @returns a new cube texture
  67835. */
  67836. clone(): CubeTexture;
  67837. }
  67838. }
  67839. declare module BABYLON {
  67840. /** @hidden */
  67841. export var postprocessVertexShader: {
  67842. name: string;
  67843. shader: string;
  67844. };
  67845. }
  67846. declare module BABYLON {
  67847. /**
  67848. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  67849. * This is the base of the follow, arc rotate cameras and Free camera
  67850. * @see http://doc.babylonjs.com/features/cameras
  67851. */
  67852. export class TargetCamera extends Camera {
  67853. private static _RigCamTransformMatrix;
  67854. private static _TargetTransformMatrix;
  67855. private static _TargetFocalPoint;
  67856. /**
  67857. * Define the current direction the camera is moving to
  67858. */
  67859. cameraDirection: Vector3;
  67860. /**
  67861. * Define the current rotation the camera is rotating to
  67862. */
  67863. cameraRotation: Vector2;
  67864. /**
  67865. * When set, the up vector of the camera will be updated by the rotation of the camera
  67866. */
  67867. updateUpVectorFromRotation: boolean;
  67868. private _tmpQuaternion;
  67869. /**
  67870. * Define the current rotation of the camera
  67871. */
  67872. rotation: Vector3;
  67873. /**
  67874. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  67875. */
  67876. rotationQuaternion: Quaternion;
  67877. /**
  67878. * Define the current speed of the camera
  67879. */
  67880. speed: number;
  67881. /**
  67882. * Add cconstraint to the camera to prevent it to move freely in all directions and
  67883. * around all axis.
  67884. */
  67885. noRotationConstraint: boolean;
  67886. /**
  67887. * Define the current target of the camera as an object or a position.
  67888. */
  67889. lockedTarget: any;
  67890. /** @hidden */
  67891. _currentTarget: Vector3;
  67892. /** @hidden */
  67893. _initialFocalDistance: number;
  67894. /** @hidden */
  67895. _viewMatrix: Matrix;
  67896. /** @hidden */
  67897. _camMatrix: Matrix;
  67898. /** @hidden */
  67899. _cameraTransformMatrix: Matrix;
  67900. /** @hidden */
  67901. _cameraRotationMatrix: Matrix;
  67902. /** @hidden */
  67903. _referencePoint: Vector3;
  67904. /** @hidden */
  67905. _transformedReferencePoint: Vector3;
  67906. protected _globalCurrentTarget: Vector3;
  67907. protected _globalCurrentUpVector: Vector3;
  67908. /** @hidden */
  67909. _reset: () => void;
  67910. private _defaultUp;
  67911. /**
  67912. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  67913. * This is the base of the follow, arc rotate cameras and Free camera
  67914. * @see http://doc.babylonjs.com/features/cameras
  67915. * @param name Defines the name of the camera in the scene
  67916. * @param position Defines the start position of the camera in the scene
  67917. * @param scene Defines the scene the camera belongs to
  67918. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  67919. */
  67920. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  67921. /**
  67922. * Gets the position in front of the camera at a given distance.
  67923. * @param distance The distance from the camera we want the position to be
  67924. * @returns the position
  67925. */
  67926. getFrontPosition(distance: number): Vector3;
  67927. /** @hidden */
  67928. _getLockedTargetPosition(): Nullable<Vector3>;
  67929. private _storedPosition;
  67930. private _storedRotation;
  67931. private _storedRotationQuaternion;
  67932. /**
  67933. * Store current camera state of the camera (fov, position, rotation, etc..)
  67934. * @returns the camera
  67935. */
  67936. storeState(): Camera;
  67937. /**
  67938. * Restored camera state. You must call storeState() first
  67939. * @returns whether it was successful or not
  67940. * @hidden
  67941. */
  67942. _restoreStateValues(): boolean;
  67943. /** @hidden */
  67944. _initCache(): void;
  67945. /** @hidden */
  67946. _updateCache(ignoreParentClass?: boolean): void;
  67947. /** @hidden */
  67948. _isSynchronizedViewMatrix(): boolean;
  67949. /** @hidden */
  67950. _computeLocalCameraSpeed(): number;
  67951. /**
  67952. * Defines the target the camera should look at.
  67953. * This will automatically adapt alpha beta and radius to fit within the new target.
  67954. * @param target Defines the new target as a Vector or a mesh
  67955. */
  67956. setTarget(target: Vector3): void;
  67957. /**
  67958. * Return the current target position of the camera. This value is expressed in local space.
  67959. * @returns the target position
  67960. */
  67961. getTarget(): Vector3;
  67962. /** @hidden */
  67963. _decideIfNeedsToMove(): boolean;
  67964. /** @hidden */
  67965. _updatePosition(): void;
  67966. /** @hidden */
  67967. _checkInputs(): void;
  67968. protected _updateCameraRotationMatrix(): void;
  67969. /**
  67970. * 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)
  67971. * @returns the current camera
  67972. */
  67973. private _rotateUpVectorWithCameraRotationMatrix;
  67974. private _cachedRotationZ;
  67975. private _cachedQuaternionRotationZ;
  67976. /** @hidden */
  67977. _getViewMatrix(): Matrix;
  67978. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  67979. /**
  67980. * @hidden
  67981. */
  67982. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  67983. /**
  67984. * @hidden
  67985. */
  67986. _updateRigCameras(): void;
  67987. private _getRigCamPositionAndTarget;
  67988. /**
  67989. * Gets the current object class name.
  67990. * @return the class name
  67991. */
  67992. getClassName(): string;
  67993. }
  67994. }
  67995. declare module BABYLON {
  67996. /**
  67997. * @ignore
  67998. * This is a list of all the different input types that are available in the application.
  67999. * Fo instance: ArcRotateCameraGamepadInput...
  68000. */
  68001. export var CameraInputTypes: {};
  68002. /**
  68003. * This is the contract to implement in order to create a new input class.
  68004. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  68005. */
  68006. export interface ICameraInput<TCamera extends Camera> {
  68007. /**
  68008. * Defines the camera the input is attached to.
  68009. */
  68010. camera: Nullable<TCamera>;
  68011. /**
  68012. * Gets the class name of the current intput.
  68013. * @returns the class name
  68014. */
  68015. getClassName(): string;
  68016. /**
  68017. * Get the friendly name associated with the input class.
  68018. * @returns the input friendly name
  68019. */
  68020. getSimpleName(): string;
  68021. /**
  68022. * Attach the input controls to a specific dom element to get the input from.
  68023. * @param element Defines the element the controls should be listened from
  68024. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68025. */
  68026. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68027. /**
  68028. * Detach the current controls from the specified dom element.
  68029. * @param element Defines the element to stop listening the inputs from
  68030. */
  68031. detachControl(element: Nullable<HTMLElement>): void;
  68032. /**
  68033. * Update the current camera state depending on the inputs that have been used this frame.
  68034. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68035. */
  68036. checkInputs?: () => void;
  68037. }
  68038. /**
  68039. * Represents a map of input types to input instance or input index to input instance.
  68040. */
  68041. export interface CameraInputsMap<TCamera extends Camera> {
  68042. /**
  68043. * Accessor to the input by input type.
  68044. */
  68045. [name: string]: ICameraInput<TCamera>;
  68046. /**
  68047. * Accessor to the input by input index.
  68048. */
  68049. [idx: number]: ICameraInput<TCamera>;
  68050. }
  68051. /**
  68052. * This represents the input manager used within a camera.
  68053. * It helps dealing with all the different kind of input attached to a camera.
  68054. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68055. */
  68056. export class CameraInputsManager<TCamera extends Camera> {
  68057. /**
  68058. * Defines the list of inputs attahed to the camera.
  68059. */
  68060. attached: CameraInputsMap<TCamera>;
  68061. /**
  68062. * Defines the dom element the camera is collecting inputs from.
  68063. * This is null if the controls have not been attached.
  68064. */
  68065. attachedElement: Nullable<HTMLElement>;
  68066. /**
  68067. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68068. */
  68069. noPreventDefault: boolean;
  68070. /**
  68071. * Defined the camera the input manager belongs to.
  68072. */
  68073. camera: TCamera;
  68074. /**
  68075. * Update the current camera state depending on the inputs that have been used this frame.
  68076. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68077. */
  68078. checkInputs: () => void;
  68079. /**
  68080. * Instantiate a new Camera Input Manager.
  68081. * @param camera Defines the camera the input manager blongs to
  68082. */
  68083. constructor(camera: TCamera);
  68084. /**
  68085. * Add an input method to a camera
  68086. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68087. * @param input camera input method
  68088. */
  68089. add(input: ICameraInput<TCamera>): void;
  68090. /**
  68091. * Remove a specific input method from a camera
  68092. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  68093. * @param inputToRemove camera input method
  68094. */
  68095. remove(inputToRemove: ICameraInput<TCamera>): void;
  68096. /**
  68097. * Remove a specific input type from a camera
  68098. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  68099. * @param inputType the type of the input to remove
  68100. */
  68101. removeByType(inputType: string): void;
  68102. private _addCheckInputs;
  68103. /**
  68104. * Attach the input controls to the currently attached dom element to listen the events from.
  68105. * @param input Defines the input to attach
  68106. */
  68107. attachInput(input: ICameraInput<TCamera>): void;
  68108. /**
  68109. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  68110. * @param element Defines the dom element to collect the events from
  68111. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68112. */
  68113. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  68114. /**
  68115. * Detach the current manager inputs controls from a specific dom element.
  68116. * @param element Defines the dom element to collect the events from
  68117. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  68118. */
  68119. detachElement(element: HTMLElement, disconnect?: boolean): void;
  68120. /**
  68121. * Rebuild the dynamic inputCheck function from the current list of
  68122. * defined inputs in the manager.
  68123. */
  68124. rebuildInputCheck(): void;
  68125. /**
  68126. * Remove all attached input methods from a camera
  68127. */
  68128. clear(): void;
  68129. /**
  68130. * Serialize the current input manager attached to a camera.
  68131. * This ensures than once parsed,
  68132. * the input associated to the camera will be identical to the current ones
  68133. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  68134. */
  68135. serialize(serializedCamera: any): void;
  68136. /**
  68137. * Parses an input manager serialized JSON to restore the previous list of inputs
  68138. * and states associated to a camera.
  68139. * @param parsedCamera Defines the JSON to parse
  68140. */
  68141. parse(parsedCamera: any): void;
  68142. }
  68143. }
  68144. declare module BABYLON {
  68145. /**
  68146. * Gather the list of keyboard event types as constants.
  68147. */
  68148. export class KeyboardEventTypes {
  68149. /**
  68150. * The keydown event is fired when a key becomes active (pressed).
  68151. */
  68152. static readonly KEYDOWN: number;
  68153. /**
  68154. * The keyup event is fired when a key has been released.
  68155. */
  68156. static readonly KEYUP: number;
  68157. }
  68158. /**
  68159. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68160. */
  68161. export class KeyboardInfo {
  68162. /**
  68163. * Defines the type of event (KeyboardEventTypes)
  68164. */
  68165. type: number;
  68166. /**
  68167. * Defines the related dom event
  68168. */
  68169. event: KeyboardEvent;
  68170. /**
  68171. * Instantiates a new keyboard info.
  68172. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68173. * @param type Defines the type of event (KeyboardEventTypes)
  68174. * @param event Defines the related dom event
  68175. */
  68176. constructor(
  68177. /**
  68178. * Defines the type of event (KeyboardEventTypes)
  68179. */
  68180. type: number,
  68181. /**
  68182. * Defines the related dom event
  68183. */
  68184. event: KeyboardEvent);
  68185. }
  68186. /**
  68187. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68188. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  68189. */
  68190. export class KeyboardInfoPre extends KeyboardInfo {
  68191. /**
  68192. * Defines the type of event (KeyboardEventTypes)
  68193. */
  68194. type: number;
  68195. /**
  68196. * Defines the related dom event
  68197. */
  68198. event: KeyboardEvent;
  68199. /**
  68200. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  68201. */
  68202. skipOnPointerObservable: boolean;
  68203. /**
  68204. * Instantiates a new keyboard pre info.
  68205. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68206. * @param type Defines the type of event (KeyboardEventTypes)
  68207. * @param event Defines the related dom event
  68208. */
  68209. constructor(
  68210. /**
  68211. * Defines the type of event (KeyboardEventTypes)
  68212. */
  68213. type: number,
  68214. /**
  68215. * Defines the related dom event
  68216. */
  68217. event: KeyboardEvent);
  68218. }
  68219. }
  68220. declare module BABYLON {
  68221. /**
  68222. * Manage the keyboard inputs to control the movement of a free camera.
  68223. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68224. */
  68225. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  68226. /**
  68227. * Defines the camera the input is attached to.
  68228. */
  68229. camera: FreeCamera;
  68230. /**
  68231. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68232. */
  68233. keysUp: number[];
  68234. /**
  68235. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68236. */
  68237. keysDown: number[];
  68238. /**
  68239. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68240. */
  68241. keysLeft: number[];
  68242. /**
  68243. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  68244. */
  68245. keysRight: number[];
  68246. private _keys;
  68247. private _onCanvasBlurObserver;
  68248. private _onKeyboardObserver;
  68249. private _engine;
  68250. private _scene;
  68251. /**
  68252. * Attach the input controls to a specific dom element to get the input from.
  68253. * @param element Defines the element the controls should be listened from
  68254. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68255. */
  68256. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68257. /**
  68258. * Detach the current controls from the specified dom element.
  68259. * @param element Defines the element to stop listening the inputs from
  68260. */
  68261. detachControl(element: Nullable<HTMLElement>): void;
  68262. /**
  68263. * Update the current camera state depending on the inputs that have been used this frame.
  68264. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68265. */
  68266. checkInputs(): void;
  68267. /**
  68268. * Gets the class name of the current intput.
  68269. * @returns the class name
  68270. */
  68271. getClassName(): string;
  68272. /** @hidden */
  68273. _onLostFocus(): void;
  68274. /**
  68275. * Get the friendly name associated with the input class.
  68276. * @returns the input friendly name
  68277. */
  68278. getSimpleName(): string;
  68279. }
  68280. }
  68281. declare module BABYLON {
  68282. /**
  68283. * Interface describing all the common properties and methods a shadow light needs to implement.
  68284. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  68285. * as well as binding the different shadow properties to the effects.
  68286. */
  68287. export interface IShadowLight extends Light {
  68288. /**
  68289. * The light id in the scene (used in scene.findLighById for instance)
  68290. */
  68291. id: string;
  68292. /**
  68293. * The position the shdow will be casted from.
  68294. */
  68295. position: Vector3;
  68296. /**
  68297. * In 2d mode (needCube being false), the direction used to cast the shadow.
  68298. */
  68299. direction: Vector3;
  68300. /**
  68301. * The transformed position. Position of the light in world space taking parenting in account.
  68302. */
  68303. transformedPosition: Vector3;
  68304. /**
  68305. * The transformed direction. Direction of the light in world space taking parenting in account.
  68306. */
  68307. transformedDirection: Vector3;
  68308. /**
  68309. * The friendly name of the light in the scene.
  68310. */
  68311. name: string;
  68312. /**
  68313. * Defines the shadow projection clipping minimum z value.
  68314. */
  68315. shadowMinZ: number;
  68316. /**
  68317. * Defines the shadow projection clipping maximum z value.
  68318. */
  68319. shadowMaxZ: number;
  68320. /**
  68321. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68322. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68323. */
  68324. computeTransformedInformation(): boolean;
  68325. /**
  68326. * Gets the scene the light belongs to.
  68327. * @returns The scene
  68328. */
  68329. getScene(): Scene;
  68330. /**
  68331. * Callback defining a custom Projection Matrix Builder.
  68332. * This can be used to override the default projection matrix computation.
  68333. */
  68334. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68335. /**
  68336. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68337. * @param matrix The materix to updated with the projection information
  68338. * @param viewMatrix The transform matrix of the light
  68339. * @param renderList The list of mesh to render in the map
  68340. * @returns The current light
  68341. */
  68342. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  68343. /**
  68344. * Gets the current depth scale used in ESM.
  68345. * @returns The scale
  68346. */
  68347. getDepthScale(): number;
  68348. /**
  68349. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68350. * @returns true if a cube texture needs to be use
  68351. */
  68352. needCube(): boolean;
  68353. /**
  68354. * Detects if the projection matrix requires to be recomputed this frame.
  68355. * @returns true if it requires to be recomputed otherwise, false.
  68356. */
  68357. needProjectionMatrixCompute(): boolean;
  68358. /**
  68359. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68360. */
  68361. forceProjectionMatrixCompute(): void;
  68362. /**
  68363. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  68364. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68365. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68366. */
  68367. getShadowDirection(faceIndex?: number): Vector3;
  68368. /**
  68369. * Gets the minZ used for shadow according to both the scene and the light.
  68370. * @param activeCamera The camera we are returning the min for
  68371. * @returns the depth min z
  68372. */
  68373. getDepthMinZ(activeCamera: Camera): number;
  68374. /**
  68375. * Gets the maxZ used for shadow according to both the scene and the light.
  68376. * @param activeCamera The camera we are returning the max for
  68377. * @returns the depth max z
  68378. */
  68379. getDepthMaxZ(activeCamera: Camera): number;
  68380. }
  68381. /**
  68382. * Base implementation IShadowLight
  68383. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  68384. */
  68385. export abstract class ShadowLight extends Light implements IShadowLight {
  68386. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  68387. protected _position: Vector3;
  68388. protected _setPosition(value: Vector3): void;
  68389. /**
  68390. * Sets the position the shadow will be casted from. Also use as the light position for both
  68391. * point and spot lights.
  68392. */
  68393. /**
  68394. * Sets the position the shadow will be casted from. Also use as the light position for both
  68395. * point and spot lights.
  68396. */
  68397. position: Vector3;
  68398. protected _direction: Vector3;
  68399. protected _setDirection(value: Vector3): void;
  68400. /**
  68401. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  68402. * Also use as the light direction on spot and directional lights.
  68403. */
  68404. /**
  68405. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  68406. * Also use as the light direction on spot and directional lights.
  68407. */
  68408. direction: Vector3;
  68409. private _shadowMinZ;
  68410. /**
  68411. * Gets the shadow projection clipping minimum z value.
  68412. */
  68413. /**
  68414. * Sets the shadow projection clipping minimum z value.
  68415. */
  68416. shadowMinZ: number;
  68417. private _shadowMaxZ;
  68418. /**
  68419. * Sets the shadow projection clipping maximum z value.
  68420. */
  68421. /**
  68422. * Gets the shadow projection clipping maximum z value.
  68423. */
  68424. shadowMaxZ: number;
  68425. /**
  68426. * Callback defining a custom Projection Matrix Builder.
  68427. * This can be used to override the default projection matrix computation.
  68428. */
  68429. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68430. /**
  68431. * The transformed position. Position of the light in world space taking parenting in account.
  68432. */
  68433. transformedPosition: Vector3;
  68434. /**
  68435. * The transformed direction. Direction of the light in world space taking parenting in account.
  68436. */
  68437. transformedDirection: Vector3;
  68438. private _needProjectionMatrixCompute;
  68439. /**
  68440. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68441. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68442. */
  68443. computeTransformedInformation(): boolean;
  68444. /**
  68445. * Return the depth scale used for the shadow map.
  68446. * @returns the depth scale.
  68447. */
  68448. getDepthScale(): number;
  68449. /**
  68450. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  68451. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68452. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68453. */
  68454. getShadowDirection(faceIndex?: number): Vector3;
  68455. /**
  68456. * Returns the ShadowLight absolute position in the World.
  68457. * @returns the position vector in world space
  68458. */
  68459. getAbsolutePosition(): Vector3;
  68460. /**
  68461. * Sets the ShadowLight direction toward the passed target.
  68462. * @param target The point to target in local space
  68463. * @returns the updated ShadowLight direction
  68464. */
  68465. setDirectionToTarget(target: Vector3): Vector3;
  68466. /**
  68467. * Returns the light rotation in euler definition.
  68468. * @returns the x y z rotation in local space.
  68469. */
  68470. getRotation(): Vector3;
  68471. /**
  68472. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68473. * @returns true if a cube texture needs to be use
  68474. */
  68475. needCube(): boolean;
  68476. /**
  68477. * Detects if the projection matrix requires to be recomputed this frame.
  68478. * @returns true if it requires to be recomputed otherwise, false.
  68479. */
  68480. needProjectionMatrixCompute(): boolean;
  68481. /**
  68482. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68483. */
  68484. forceProjectionMatrixCompute(): void;
  68485. /** @hidden */
  68486. _initCache(): void;
  68487. /** @hidden */
  68488. _isSynchronized(): boolean;
  68489. /**
  68490. * Computes the world matrix of the node
  68491. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  68492. * @returns the world matrix
  68493. */
  68494. computeWorldMatrix(force?: boolean): Matrix;
  68495. /**
  68496. * Gets the minZ used for shadow according to both the scene and the light.
  68497. * @param activeCamera The camera we are returning the min for
  68498. * @returns the depth min z
  68499. */
  68500. getDepthMinZ(activeCamera: Camera): number;
  68501. /**
  68502. * Gets the maxZ used for shadow according to both the scene and the light.
  68503. * @param activeCamera The camera we are returning the max for
  68504. * @returns the depth max z
  68505. */
  68506. getDepthMaxZ(activeCamera: Camera): number;
  68507. /**
  68508. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68509. * @param matrix The materix to updated with the projection information
  68510. * @param viewMatrix The transform matrix of the light
  68511. * @param renderList The list of mesh to render in the map
  68512. * @returns The current light
  68513. */
  68514. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  68515. }
  68516. }
  68517. declare module BABYLON {
  68518. /**
  68519. * "Static Class" containing the most commonly used helper while dealing with material for
  68520. * rendering purpose.
  68521. *
  68522. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  68523. *
  68524. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  68525. */
  68526. export class MaterialHelper {
  68527. /**
  68528. * Bind the current view position to an effect.
  68529. * @param effect The effect to be bound
  68530. * @param scene The scene the eyes position is used from
  68531. */
  68532. static BindEyePosition(effect: Effect, scene: Scene): void;
  68533. /**
  68534. * Helps preparing the defines values about the UVs in used in the effect.
  68535. * UVs are shared as much as we can accross channels in the shaders.
  68536. * @param texture The texture we are preparing the UVs for
  68537. * @param defines The defines to update
  68538. * @param key The channel key "diffuse", "specular"... used in the shader
  68539. */
  68540. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  68541. /**
  68542. * Binds a texture matrix value to its corrsponding uniform
  68543. * @param texture The texture to bind the matrix for
  68544. * @param uniformBuffer The uniform buffer receivin the data
  68545. * @param key The channel key "diffuse", "specular"... used in the shader
  68546. */
  68547. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  68548. /**
  68549. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  68550. * @param mesh defines the current mesh
  68551. * @param scene defines the current scene
  68552. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  68553. * @param pointsCloud defines if point cloud rendering has to be turned on
  68554. * @param fogEnabled defines if fog has to be turned on
  68555. * @param alphaTest defines if alpha testing has to be turned on
  68556. * @param defines defines the current list of defines
  68557. */
  68558. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  68559. /**
  68560. * Helper used to prepare the list of defines associated with frame values for shader compilation
  68561. * @param scene defines the current scene
  68562. * @param engine defines the current engine
  68563. * @param defines specifies the list of active defines
  68564. * @param useInstances defines if instances have to be turned on
  68565. * @param useClipPlane defines if clip plane have to be turned on
  68566. */
  68567. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  68568. /**
  68569. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  68570. * @param mesh The mesh containing the geometry data we will draw
  68571. * @param defines The defines to update
  68572. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  68573. * @param useBones Precise whether bones should be used or not (override mesh info)
  68574. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  68575. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  68576. * @returns false if defines are considered not dirty and have not been checked
  68577. */
  68578. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  68579. /**
  68580. * Prepares the defines related to multiview
  68581. * @param scene The scene we are intending to draw
  68582. * @param defines The defines to update
  68583. */
  68584. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  68585. /**
  68586. * Prepares the defines related to the light information passed in parameter
  68587. * @param scene The scene we are intending to draw
  68588. * @param mesh The mesh the effect is compiling for
  68589. * @param defines The defines to update
  68590. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  68591. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  68592. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  68593. * @returns true if normals will be required for the rest of the effect
  68594. */
  68595. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  68596. /**
  68597. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  68598. * that won t be acctive due to defines being turned off.
  68599. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  68600. * @param samplersList The samplers list
  68601. * @param defines The defines helping in the list generation
  68602. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  68603. */
  68604. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  68605. /**
  68606. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  68607. * @param defines The defines to update while falling back
  68608. * @param fallbacks The authorized effect fallbacks
  68609. * @param maxSimultaneousLights The maximum number of lights allowed
  68610. * @param rank the current rank of the Effect
  68611. * @returns The newly affected rank
  68612. */
  68613. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  68614. /**
  68615. * Prepares the list of attributes required for morph targets according to the effect defines.
  68616. * @param attribs The current list of supported attribs
  68617. * @param mesh The mesh to prepare the morph targets attributes for
  68618. * @param defines The current Defines of the effect
  68619. */
  68620. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  68621. /**
  68622. * Prepares the list of attributes required for bones according to the effect defines.
  68623. * @param attribs The current list of supported attribs
  68624. * @param mesh The mesh to prepare the bones attributes for
  68625. * @param defines The current Defines of the effect
  68626. * @param fallbacks The current efffect fallback strategy
  68627. */
  68628. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  68629. /**
  68630. * Prepares the list of attributes required for instances according to the effect defines.
  68631. * @param attribs The current list of supported attribs
  68632. * @param defines The current Defines of the effect
  68633. */
  68634. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  68635. /**
  68636. * Binds the light shadow information to the effect for the given mesh.
  68637. * @param light The light containing the generator
  68638. * @param scene The scene the lights belongs to
  68639. * @param mesh The mesh we are binding the information to render
  68640. * @param lightIndex The light index in the effect used to render the mesh
  68641. * @param effect The effect we are binding the data to
  68642. */
  68643. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  68644. /**
  68645. * Binds the light information to the effect.
  68646. * @param light The light containing the generator
  68647. * @param effect The effect we are binding the data to
  68648. * @param lightIndex The light index in the effect used to render
  68649. */
  68650. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  68651. /**
  68652. * Binds the lights information from the scene to the effect for the given mesh.
  68653. * @param scene The scene the lights belongs to
  68654. * @param mesh The mesh we are binding the information to render
  68655. * @param effect The effect we are binding the data to
  68656. * @param defines The generated defines for the effect
  68657. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  68658. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  68659. */
  68660. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  68661. private static _tempFogColor;
  68662. /**
  68663. * Binds the fog information from the scene to the effect for the given mesh.
  68664. * @param scene The scene the lights belongs to
  68665. * @param mesh The mesh we are binding the information to render
  68666. * @param effect The effect we are binding the data to
  68667. * @param linearSpace Defines if the fog effect is applied in linear space
  68668. */
  68669. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  68670. /**
  68671. * Binds the bones information from the mesh to the effect.
  68672. * @param mesh The mesh we are binding the information to render
  68673. * @param effect The effect we are binding the data to
  68674. */
  68675. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  68676. /**
  68677. * Binds the morph targets information from the mesh to the effect.
  68678. * @param abstractMesh The mesh we are binding the information to render
  68679. * @param effect The effect we are binding the data to
  68680. */
  68681. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  68682. /**
  68683. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  68684. * @param defines The generated defines used in the effect
  68685. * @param effect The effect we are binding the data to
  68686. * @param scene The scene we are willing to render with logarithmic scale for
  68687. */
  68688. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  68689. /**
  68690. * Binds the clip plane information from the scene to the effect.
  68691. * @param scene The scene the clip plane information are extracted from
  68692. * @param effect The effect we are binding the data to
  68693. */
  68694. static BindClipPlane(effect: Effect, scene: Scene): void;
  68695. }
  68696. }
  68697. declare module BABYLON {
  68698. /** @hidden */
  68699. export var kernelBlurVaryingDeclaration: {
  68700. name: string;
  68701. shader: string;
  68702. };
  68703. }
  68704. declare module BABYLON {
  68705. /** @hidden */
  68706. export var kernelBlurFragment: {
  68707. name: string;
  68708. shader: string;
  68709. };
  68710. }
  68711. declare module BABYLON {
  68712. /** @hidden */
  68713. export var kernelBlurFragment2: {
  68714. name: string;
  68715. shader: string;
  68716. };
  68717. }
  68718. declare module BABYLON {
  68719. /** @hidden */
  68720. export var kernelBlurPixelShader: {
  68721. name: string;
  68722. shader: string;
  68723. };
  68724. }
  68725. declare module BABYLON {
  68726. /** @hidden */
  68727. export var kernelBlurVertex: {
  68728. name: string;
  68729. shader: string;
  68730. };
  68731. }
  68732. declare module BABYLON {
  68733. /** @hidden */
  68734. export var kernelBlurVertexShader: {
  68735. name: string;
  68736. shader: string;
  68737. };
  68738. }
  68739. declare module BABYLON {
  68740. /**
  68741. * The Blur Post Process which blurs an image based on a kernel and direction.
  68742. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  68743. */
  68744. export class BlurPostProcess extends PostProcess {
  68745. /** The direction in which to blur the image. */
  68746. direction: Vector2;
  68747. private blockCompilation;
  68748. protected _kernel: number;
  68749. protected _idealKernel: number;
  68750. protected _packedFloat: boolean;
  68751. private _staticDefines;
  68752. /**
  68753. * Sets the length in pixels of the blur sample region
  68754. */
  68755. /**
  68756. * Gets the length in pixels of the blur sample region
  68757. */
  68758. kernel: number;
  68759. /**
  68760. * Sets wether or not the blur needs to unpack/repack floats
  68761. */
  68762. /**
  68763. * Gets wether or not the blur is unpacking/repacking floats
  68764. */
  68765. packedFloat: boolean;
  68766. /**
  68767. * Creates a new instance BlurPostProcess
  68768. * @param name The name of the effect.
  68769. * @param direction The direction in which to blur the image.
  68770. * @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.
  68771. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  68772. * @param camera The camera to apply the render pass to.
  68773. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68774. * @param engine The engine which the post process will be applied. (default: current engine)
  68775. * @param reusable If the post process can be reused on the same frame. (default: false)
  68776. * @param textureType Type of textures used when performing the post process. (default: 0)
  68777. * @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)
  68778. */
  68779. constructor(name: string,
  68780. /** The direction in which to blur the image. */
  68781. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  68782. /**
  68783. * Updates the effect with the current post process compile time values and recompiles the shader.
  68784. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68785. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68786. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68787. * @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
  68788. * @param onCompiled Called when the shader has been compiled.
  68789. * @param onError Called if there is an error when compiling a shader.
  68790. */
  68791. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68792. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68793. /**
  68794. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  68795. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  68796. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  68797. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  68798. * The gaps between physical kernels are compensated for in the weighting of the samples
  68799. * @param idealKernel Ideal blur kernel.
  68800. * @return Nearest best kernel.
  68801. */
  68802. protected _nearestBestKernel(idealKernel: number): number;
  68803. /**
  68804. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  68805. * @param x The point on the Gaussian distribution to sample.
  68806. * @return the value of the Gaussian function at x.
  68807. */
  68808. protected _gaussianWeight(x: number): number;
  68809. /**
  68810. * Generates a string that can be used as a floating point number in GLSL.
  68811. * @param x Value to print.
  68812. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  68813. * @return GLSL float string.
  68814. */
  68815. protected _glslFloat(x: number, decimalFigures?: number): string;
  68816. }
  68817. }
  68818. declare module BABYLON {
  68819. /** @hidden */
  68820. export var shadowMapPixelShader: {
  68821. name: string;
  68822. shader: string;
  68823. };
  68824. }
  68825. declare module BABYLON {
  68826. /** @hidden */
  68827. export var bonesDeclaration: {
  68828. name: string;
  68829. shader: string;
  68830. };
  68831. }
  68832. declare module BABYLON {
  68833. /** @hidden */
  68834. export var morphTargetsVertexGlobalDeclaration: {
  68835. name: string;
  68836. shader: string;
  68837. };
  68838. }
  68839. declare module BABYLON {
  68840. /** @hidden */
  68841. export var morphTargetsVertexDeclaration: {
  68842. name: string;
  68843. shader: string;
  68844. };
  68845. }
  68846. declare module BABYLON {
  68847. /** @hidden */
  68848. export var instancesDeclaration: {
  68849. name: string;
  68850. shader: string;
  68851. };
  68852. }
  68853. declare module BABYLON {
  68854. /** @hidden */
  68855. export var helperFunctions: {
  68856. name: string;
  68857. shader: string;
  68858. };
  68859. }
  68860. declare module BABYLON {
  68861. /** @hidden */
  68862. export var morphTargetsVertex: {
  68863. name: string;
  68864. shader: string;
  68865. };
  68866. }
  68867. declare module BABYLON {
  68868. /** @hidden */
  68869. export var instancesVertex: {
  68870. name: string;
  68871. shader: string;
  68872. };
  68873. }
  68874. declare module BABYLON {
  68875. /** @hidden */
  68876. export var bonesVertex: {
  68877. name: string;
  68878. shader: string;
  68879. };
  68880. }
  68881. declare module BABYLON {
  68882. /** @hidden */
  68883. export var shadowMapVertexShader: {
  68884. name: string;
  68885. shader: string;
  68886. };
  68887. }
  68888. declare module BABYLON {
  68889. /** @hidden */
  68890. export var depthBoxBlurPixelShader: {
  68891. name: string;
  68892. shader: string;
  68893. };
  68894. }
  68895. declare module BABYLON {
  68896. /**
  68897. * Defines the options associated with the creation of a custom shader for a shadow generator.
  68898. */
  68899. export interface ICustomShaderOptions {
  68900. /**
  68901. * Gets or sets the custom shader name to use
  68902. */
  68903. shaderName: string;
  68904. /**
  68905. * The list of attribute names used in the shader
  68906. */
  68907. attributes?: string[];
  68908. /**
  68909. * The list of unifrom names used in the shader
  68910. */
  68911. uniforms?: string[];
  68912. /**
  68913. * The list of sampler names used in the shader
  68914. */
  68915. samplers?: string[];
  68916. /**
  68917. * The list of defines used in the shader
  68918. */
  68919. defines?: string[];
  68920. }
  68921. /**
  68922. * Interface to implement to create a shadow generator compatible with BJS.
  68923. */
  68924. export interface IShadowGenerator {
  68925. /**
  68926. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  68927. * @returns The render target texture if present otherwise, null
  68928. */
  68929. getShadowMap(): Nullable<RenderTargetTexture>;
  68930. /**
  68931. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  68932. * @returns The render target texture if the shadow map is present otherwise, null
  68933. */
  68934. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  68935. /**
  68936. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  68937. * @param subMesh The submesh we want to render in the shadow map
  68938. * @param useInstances Defines wether will draw in the map using instances
  68939. * @returns true if ready otherwise, false
  68940. */
  68941. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68942. /**
  68943. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  68944. * @param defines Defines of the material we want to update
  68945. * @param lightIndex Index of the light in the enabled light list of the material
  68946. */
  68947. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  68948. /**
  68949. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  68950. * defined in the generator but impacting the effect).
  68951. * It implies the unifroms available on the materials are the standard BJS ones.
  68952. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  68953. * @param effect The effect we are binfing the information for
  68954. */
  68955. bindShadowLight(lightIndex: string, effect: Effect): void;
  68956. /**
  68957. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  68958. * (eq to shadow prjection matrix * light transform matrix)
  68959. * @returns The transform matrix used to create the shadow map
  68960. */
  68961. getTransformMatrix(): Matrix;
  68962. /**
  68963. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  68964. * Cube and 2D textures for instance.
  68965. */
  68966. recreateShadowMap(): void;
  68967. /**
  68968. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68969. * @param onCompiled Callback triggered at the and of the effects compilation
  68970. * @param options Sets of optional options forcing the compilation with different modes
  68971. */
  68972. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  68973. useInstances: boolean;
  68974. }>): void;
  68975. /**
  68976. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68977. * @param options Sets of optional options forcing the compilation with different modes
  68978. * @returns A promise that resolves when the compilation completes
  68979. */
  68980. forceCompilationAsync(options?: Partial<{
  68981. useInstances: boolean;
  68982. }>): Promise<void>;
  68983. /**
  68984. * Serializes the shadow generator setup to a json object.
  68985. * @returns The serialized JSON object
  68986. */
  68987. serialize(): any;
  68988. /**
  68989. * Disposes the Shadow map and related Textures and effects.
  68990. */
  68991. dispose(): void;
  68992. }
  68993. /**
  68994. * Default implementation IShadowGenerator.
  68995. * This is the main object responsible of generating shadows in the framework.
  68996. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  68997. */
  68998. export class ShadowGenerator implements IShadowGenerator {
  68999. /**
  69000. * Shadow generator mode None: no filtering applied.
  69001. */
  69002. static readonly FILTER_NONE: number;
  69003. /**
  69004. * Shadow generator mode ESM: Exponential Shadow Mapping.
  69005. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69006. */
  69007. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  69008. /**
  69009. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  69010. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  69011. */
  69012. static readonly FILTER_POISSONSAMPLING: number;
  69013. /**
  69014. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  69015. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69016. */
  69017. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  69018. /**
  69019. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  69020. * edge artifacts on steep falloff.
  69021. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69022. */
  69023. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  69024. /**
  69025. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  69026. * edge artifacts on steep falloff.
  69027. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69028. */
  69029. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  69030. /**
  69031. * Shadow generator mode PCF: Percentage Closer Filtering
  69032. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69033. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  69034. */
  69035. static readonly FILTER_PCF: number;
  69036. /**
  69037. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  69038. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69039. * Contact Hardening
  69040. */
  69041. static readonly FILTER_PCSS: number;
  69042. /**
  69043. * Reserved for PCF and PCSS
  69044. * Highest Quality.
  69045. *
  69046. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  69047. *
  69048. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  69049. */
  69050. static readonly QUALITY_HIGH: number;
  69051. /**
  69052. * Reserved for PCF and PCSS
  69053. * Good tradeoff for quality/perf cross devices
  69054. *
  69055. * Execute PCF on a 3*3 kernel.
  69056. *
  69057. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  69058. */
  69059. static readonly QUALITY_MEDIUM: number;
  69060. /**
  69061. * Reserved for PCF and PCSS
  69062. * The lowest quality but the fastest.
  69063. *
  69064. * Execute PCF on a 1*1 kernel.
  69065. *
  69066. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  69067. */
  69068. static readonly QUALITY_LOW: number;
  69069. /** Gets or sets the custom shader name to use */
  69070. customShaderOptions: ICustomShaderOptions;
  69071. /**
  69072. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  69073. */
  69074. onBeforeShadowMapRenderObservable: Observable<Effect>;
  69075. /**
  69076. * Observable triggered before a mesh is rendered in the shadow map.
  69077. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  69078. */
  69079. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  69080. private _bias;
  69081. /**
  69082. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  69083. */
  69084. /**
  69085. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  69086. */
  69087. bias: number;
  69088. private _normalBias;
  69089. /**
  69090. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69091. */
  69092. /**
  69093. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69094. */
  69095. normalBias: number;
  69096. private _blurBoxOffset;
  69097. /**
  69098. * Gets the blur box offset: offset applied during the blur pass.
  69099. * Only useful if useKernelBlur = false
  69100. */
  69101. /**
  69102. * Sets the blur box offset: offset applied during the blur pass.
  69103. * Only useful if useKernelBlur = false
  69104. */
  69105. blurBoxOffset: number;
  69106. private _blurScale;
  69107. /**
  69108. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  69109. * 2 means half of the size.
  69110. */
  69111. /**
  69112. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  69113. * 2 means half of the size.
  69114. */
  69115. blurScale: number;
  69116. private _blurKernel;
  69117. /**
  69118. * Gets the blur kernel: kernel size of the blur pass.
  69119. * Only useful if useKernelBlur = true
  69120. */
  69121. /**
  69122. * Sets the blur kernel: kernel size of the blur pass.
  69123. * Only useful if useKernelBlur = true
  69124. */
  69125. blurKernel: number;
  69126. private _useKernelBlur;
  69127. /**
  69128. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  69129. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69130. */
  69131. /**
  69132. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  69133. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69134. */
  69135. useKernelBlur: boolean;
  69136. private _depthScale;
  69137. /**
  69138. * Gets the depth scale used in ESM mode.
  69139. */
  69140. /**
  69141. * Sets the depth scale used in ESM mode.
  69142. * This can override the scale stored on the light.
  69143. */
  69144. depthScale: number;
  69145. private _filter;
  69146. /**
  69147. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  69148. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69149. */
  69150. /**
  69151. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  69152. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69153. */
  69154. filter: number;
  69155. /**
  69156. * Gets if the current filter is set to Poisson Sampling.
  69157. */
  69158. /**
  69159. * Sets the current filter to Poisson Sampling.
  69160. */
  69161. usePoissonSampling: boolean;
  69162. /**
  69163. * Gets if the current filter is set to ESM.
  69164. */
  69165. /**
  69166. * Sets the current filter is to ESM.
  69167. */
  69168. useExponentialShadowMap: boolean;
  69169. /**
  69170. * Gets if the current filter is set to filtered ESM.
  69171. */
  69172. /**
  69173. * Gets if the current filter is set to filtered ESM.
  69174. */
  69175. useBlurExponentialShadowMap: boolean;
  69176. /**
  69177. * Gets if the current filter is set to "close ESM" (using the inverse of the
  69178. * exponential to prevent steep falloff artifacts).
  69179. */
  69180. /**
  69181. * Sets the current filter to "close ESM" (using the inverse of the
  69182. * exponential to prevent steep falloff artifacts).
  69183. */
  69184. useCloseExponentialShadowMap: boolean;
  69185. /**
  69186. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  69187. * exponential to prevent steep falloff artifacts).
  69188. */
  69189. /**
  69190. * Sets the current filter to filtered "close ESM" (using the inverse of the
  69191. * exponential to prevent steep falloff artifacts).
  69192. */
  69193. useBlurCloseExponentialShadowMap: boolean;
  69194. /**
  69195. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  69196. */
  69197. /**
  69198. * Sets the current filter to "PCF" (percentage closer filtering).
  69199. */
  69200. usePercentageCloserFiltering: boolean;
  69201. private _filteringQuality;
  69202. /**
  69203. * Gets the PCF or PCSS Quality.
  69204. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69205. */
  69206. /**
  69207. * Sets the PCF or PCSS Quality.
  69208. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69209. */
  69210. filteringQuality: number;
  69211. /**
  69212. * Gets if the current filter is set to "PCSS" (contact hardening).
  69213. */
  69214. /**
  69215. * Sets the current filter to "PCSS" (contact hardening).
  69216. */
  69217. useContactHardeningShadow: boolean;
  69218. private _contactHardeningLightSizeUVRatio;
  69219. /**
  69220. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69221. * Using a ratio helps keeping shape stability independently of the map size.
  69222. *
  69223. * It does not account for the light projection as it was having too much
  69224. * instability during the light setup or during light position changes.
  69225. *
  69226. * Only valid if useContactHardeningShadow is true.
  69227. */
  69228. /**
  69229. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69230. * Using a ratio helps keeping shape stability independently of the map size.
  69231. *
  69232. * It does not account for the light projection as it was having too much
  69233. * instability during the light setup or during light position changes.
  69234. *
  69235. * Only valid if useContactHardeningShadow is true.
  69236. */
  69237. contactHardeningLightSizeUVRatio: number;
  69238. private _darkness;
  69239. /**
  69240. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  69241. * 0 means strongest and 1 would means no shadow.
  69242. * @returns the darkness.
  69243. */
  69244. getDarkness(): number;
  69245. /**
  69246. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  69247. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  69248. * @returns the shadow generator allowing fluent coding.
  69249. */
  69250. setDarkness(darkness: number): ShadowGenerator;
  69251. private _transparencyShadow;
  69252. /**
  69253. * Sets the ability to have transparent shadow (boolean).
  69254. * @param transparent True if transparent else False
  69255. * @returns the shadow generator allowing fluent coding
  69256. */
  69257. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  69258. private _shadowMap;
  69259. private _shadowMap2;
  69260. /**
  69261. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69262. * @returns The render target texture if present otherwise, null
  69263. */
  69264. getShadowMap(): Nullable<RenderTargetTexture>;
  69265. /**
  69266. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69267. * @returns The render target texture if the shadow map is present otherwise, null
  69268. */
  69269. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69270. /**
  69271. * Helper function to add a mesh and its descendants to the list of shadow casters.
  69272. * @param mesh Mesh to add
  69273. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  69274. * @returns the Shadow Generator itself
  69275. */
  69276. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69277. /**
  69278. * Helper function to remove a mesh and its descendants from the list of shadow casters
  69279. * @param mesh Mesh to remove
  69280. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  69281. * @returns the Shadow Generator itself
  69282. */
  69283. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69284. /**
  69285. * Controls the extent to which the shadows fade out at the edge of the frustum
  69286. * Used only by directionals and spots
  69287. */
  69288. frustumEdgeFalloff: number;
  69289. private _light;
  69290. /**
  69291. * Returns the associated light object.
  69292. * @returns the light generating the shadow
  69293. */
  69294. getLight(): IShadowLight;
  69295. /**
  69296. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  69297. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  69298. * It might on the other hand introduce peter panning.
  69299. */
  69300. forceBackFacesOnly: boolean;
  69301. private _scene;
  69302. private _lightDirection;
  69303. private _effect;
  69304. private _viewMatrix;
  69305. private _projectionMatrix;
  69306. private _transformMatrix;
  69307. private _cachedPosition;
  69308. private _cachedDirection;
  69309. private _cachedDefines;
  69310. private _currentRenderID;
  69311. private _boxBlurPostprocess;
  69312. private _kernelBlurXPostprocess;
  69313. private _kernelBlurYPostprocess;
  69314. private _blurPostProcesses;
  69315. private _mapSize;
  69316. private _currentFaceIndex;
  69317. private _currentFaceIndexCache;
  69318. private _textureType;
  69319. private _defaultTextureMatrix;
  69320. /** @hidden */
  69321. static _SceneComponentInitialization: (scene: Scene) => void;
  69322. /**
  69323. * Creates a ShadowGenerator object.
  69324. * A ShadowGenerator is the required tool to use the shadows.
  69325. * Each light casting shadows needs to use its own ShadowGenerator.
  69326. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  69327. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  69328. * @param light The light object generating the shadows.
  69329. * @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.
  69330. */
  69331. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  69332. private _initializeGenerator;
  69333. private _initializeShadowMap;
  69334. private _initializeBlurRTTAndPostProcesses;
  69335. private _renderForShadowMap;
  69336. private _renderSubMeshForShadowMap;
  69337. private _applyFilterValues;
  69338. /**
  69339. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69340. * @param onCompiled Callback triggered at the and of the effects compilation
  69341. * @param options Sets of optional options forcing the compilation with different modes
  69342. */
  69343. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69344. useInstances: boolean;
  69345. }>): void;
  69346. /**
  69347. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69348. * @param options Sets of optional options forcing the compilation with different modes
  69349. * @returns A promise that resolves when the compilation completes
  69350. */
  69351. forceCompilationAsync(options?: Partial<{
  69352. useInstances: boolean;
  69353. }>): Promise<void>;
  69354. /**
  69355. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69356. * @param subMesh The submesh we want to render in the shadow map
  69357. * @param useInstances Defines wether will draw in the map using instances
  69358. * @returns true if ready otherwise, false
  69359. */
  69360. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69361. /**
  69362. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69363. * @param defines Defines of the material we want to update
  69364. * @param lightIndex Index of the light in the enabled light list of the material
  69365. */
  69366. prepareDefines(defines: any, lightIndex: number): void;
  69367. /**
  69368. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69369. * defined in the generator but impacting the effect).
  69370. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69371. * @param effect The effect we are binfing the information for
  69372. */
  69373. bindShadowLight(lightIndex: string, effect: Effect): void;
  69374. /**
  69375. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69376. * (eq to shadow prjection matrix * light transform matrix)
  69377. * @returns The transform matrix used to create the shadow map
  69378. */
  69379. getTransformMatrix(): Matrix;
  69380. /**
  69381. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69382. * Cube and 2D textures for instance.
  69383. */
  69384. recreateShadowMap(): void;
  69385. private _disposeBlurPostProcesses;
  69386. private _disposeRTTandPostProcesses;
  69387. /**
  69388. * Disposes the ShadowGenerator.
  69389. * Returns nothing.
  69390. */
  69391. dispose(): void;
  69392. /**
  69393. * Serializes the shadow generator setup to a json object.
  69394. * @returns The serialized JSON object
  69395. */
  69396. serialize(): any;
  69397. /**
  69398. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  69399. * @param parsedShadowGenerator The JSON object to parse
  69400. * @param scene The scene to create the shadow map for
  69401. * @returns The parsed shadow generator
  69402. */
  69403. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  69404. }
  69405. }
  69406. declare module BABYLON {
  69407. /**
  69408. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  69409. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  69410. * 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.
  69411. */
  69412. export abstract class Light extends Node {
  69413. /**
  69414. * Falloff Default: light is falling off following the material specification:
  69415. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  69416. */
  69417. static readonly FALLOFF_DEFAULT: number;
  69418. /**
  69419. * Falloff Physical: light is falling off following the inverse squared distance law.
  69420. */
  69421. static readonly FALLOFF_PHYSICAL: number;
  69422. /**
  69423. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  69424. * to enhance interoperability with other engines.
  69425. */
  69426. static readonly FALLOFF_GLTF: number;
  69427. /**
  69428. * Falloff Standard: light is falling off like in the standard material
  69429. * to enhance interoperability with other materials.
  69430. */
  69431. static readonly FALLOFF_STANDARD: number;
  69432. /**
  69433. * If every light affecting the material is in this lightmapMode,
  69434. * material.lightmapTexture adds or multiplies
  69435. * (depends on material.useLightmapAsShadowmap)
  69436. * after every other light calculations.
  69437. */
  69438. static readonly LIGHTMAP_DEFAULT: number;
  69439. /**
  69440. * material.lightmapTexture as only diffuse lighting from this light
  69441. * adds only specular lighting from this light
  69442. * adds dynamic shadows
  69443. */
  69444. static readonly LIGHTMAP_SPECULAR: number;
  69445. /**
  69446. * material.lightmapTexture as only lighting
  69447. * no light calculation from this light
  69448. * only adds dynamic shadows from this light
  69449. */
  69450. static readonly LIGHTMAP_SHADOWSONLY: number;
  69451. /**
  69452. * Each light type uses the default quantity according to its type:
  69453. * point/spot lights use luminous intensity
  69454. * directional lights use illuminance
  69455. */
  69456. static readonly INTENSITYMODE_AUTOMATIC: number;
  69457. /**
  69458. * lumen (lm)
  69459. */
  69460. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  69461. /**
  69462. * candela (lm/sr)
  69463. */
  69464. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  69465. /**
  69466. * lux (lm/m^2)
  69467. */
  69468. static readonly INTENSITYMODE_ILLUMINANCE: number;
  69469. /**
  69470. * nit (cd/m^2)
  69471. */
  69472. static readonly INTENSITYMODE_LUMINANCE: number;
  69473. /**
  69474. * Light type const id of the point light.
  69475. */
  69476. static readonly LIGHTTYPEID_POINTLIGHT: number;
  69477. /**
  69478. * Light type const id of the directional light.
  69479. */
  69480. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  69481. /**
  69482. * Light type const id of the spot light.
  69483. */
  69484. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  69485. /**
  69486. * Light type const id of the hemispheric light.
  69487. */
  69488. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  69489. /**
  69490. * Diffuse gives the basic color to an object.
  69491. */
  69492. diffuse: Color3;
  69493. /**
  69494. * Specular produces a highlight color on an object.
  69495. * Note: This is note affecting PBR materials.
  69496. */
  69497. specular: Color3;
  69498. /**
  69499. * Defines the falloff type for this light. This lets overrriding how punctual light are
  69500. * falling off base on range or angle.
  69501. * This can be set to any values in Light.FALLOFF_x.
  69502. *
  69503. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  69504. * other types of materials.
  69505. */
  69506. falloffType: number;
  69507. /**
  69508. * Strength of the light.
  69509. * Note: By default it is define in the framework own unit.
  69510. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  69511. */
  69512. intensity: number;
  69513. private _range;
  69514. protected _inverseSquaredRange: number;
  69515. /**
  69516. * Defines how far from the source the light is impacting in scene units.
  69517. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  69518. */
  69519. /**
  69520. * Defines how far from the source the light is impacting in scene units.
  69521. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  69522. */
  69523. range: number;
  69524. /**
  69525. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  69526. * of light.
  69527. */
  69528. private _photometricScale;
  69529. private _intensityMode;
  69530. /**
  69531. * Gets the photometric scale used to interpret the intensity.
  69532. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  69533. */
  69534. /**
  69535. * Sets the photometric scale used to interpret the intensity.
  69536. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  69537. */
  69538. intensityMode: number;
  69539. private _radius;
  69540. /**
  69541. * Gets the light radius used by PBR Materials to simulate soft area lights.
  69542. */
  69543. /**
  69544. * sets the light radius used by PBR Materials to simulate soft area lights.
  69545. */
  69546. radius: number;
  69547. private _renderPriority;
  69548. /**
  69549. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  69550. * exceeding the number allowed of the materials.
  69551. */
  69552. renderPriority: number;
  69553. private _shadowEnabled;
  69554. /**
  69555. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  69556. * the current shadow generator.
  69557. */
  69558. /**
  69559. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  69560. * the current shadow generator.
  69561. */
  69562. shadowEnabled: boolean;
  69563. private _includedOnlyMeshes;
  69564. /**
  69565. * Gets the only meshes impacted by this light.
  69566. */
  69567. /**
  69568. * Sets the only meshes impacted by this light.
  69569. */
  69570. includedOnlyMeshes: AbstractMesh[];
  69571. private _excludedMeshes;
  69572. /**
  69573. * Gets the meshes not impacted by this light.
  69574. */
  69575. /**
  69576. * Sets the meshes not impacted by this light.
  69577. */
  69578. excludedMeshes: AbstractMesh[];
  69579. private _excludeWithLayerMask;
  69580. /**
  69581. * Gets the layer id use to find what meshes are not impacted by the light.
  69582. * Inactive if 0
  69583. */
  69584. /**
  69585. * Sets the layer id use to find what meshes are not impacted by the light.
  69586. * Inactive if 0
  69587. */
  69588. excludeWithLayerMask: number;
  69589. private _includeOnlyWithLayerMask;
  69590. /**
  69591. * Gets the layer id use to find what meshes are impacted by the light.
  69592. * Inactive if 0
  69593. */
  69594. /**
  69595. * Sets the layer id use to find what meshes are impacted by the light.
  69596. * Inactive if 0
  69597. */
  69598. includeOnlyWithLayerMask: number;
  69599. private _lightmapMode;
  69600. /**
  69601. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  69602. */
  69603. /**
  69604. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  69605. */
  69606. lightmapMode: number;
  69607. /**
  69608. * Shadow generator associted to the light.
  69609. * @hidden Internal use only.
  69610. */
  69611. _shadowGenerator: Nullable<IShadowGenerator>;
  69612. /**
  69613. * @hidden Internal use only.
  69614. */
  69615. _excludedMeshesIds: string[];
  69616. /**
  69617. * @hidden Internal use only.
  69618. */
  69619. _includedOnlyMeshesIds: string[];
  69620. /**
  69621. * The current light unifom buffer.
  69622. * @hidden Internal use only.
  69623. */
  69624. _uniformBuffer: UniformBuffer;
  69625. /**
  69626. * Creates a Light object in the scene.
  69627. * Documentation : https://doc.babylonjs.com/babylon101/lights
  69628. * @param name The firendly name of the light
  69629. * @param scene The scene the light belongs too
  69630. */
  69631. constructor(name: string, scene: Scene);
  69632. protected abstract _buildUniformLayout(): void;
  69633. /**
  69634. * Sets the passed Effect "effect" with the Light information.
  69635. * @param effect The effect to update
  69636. * @param lightIndex The index of the light in the effect to update
  69637. * @returns The light
  69638. */
  69639. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  69640. /**
  69641. * Returns the string "Light".
  69642. * @returns the class name
  69643. */
  69644. getClassName(): string;
  69645. /** @hidden */
  69646. readonly _isLight: boolean;
  69647. /**
  69648. * Converts the light information to a readable string for debug purpose.
  69649. * @param fullDetails Supports for multiple levels of logging within scene loading
  69650. * @returns the human readable light info
  69651. */
  69652. toString(fullDetails?: boolean): string;
  69653. /** @hidden */
  69654. protected _syncParentEnabledState(): void;
  69655. /**
  69656. * Set the enabled state of this node.
  69657. * @param value - the new enabled state
  69658. */
  69659. setEnabled(value: boolean): void;
  69660. /**
  69661. * Returns the Light associated shadow generator if any.
  69662. * @return the associated shadow generator.
  69663. */
  69664. getShadowGenerator(): Nullable<IShadowGenerator>;
  69665. /**
  69666. * Returns a Vector3, the absolute light position in the World.
  69667. * @returns the world space position of the light
  69668. */
  69669. getAbsolutePosition(): Vector3;
  69670. /**
  69671. * Specifies if the light will affect the passed mesh.
  69672. * @param mesh The mesh to test against the light
  69673. * @return true the mesh is affected otherwise, false.
  69674. */
  69675. canAffectMesh(mesh: AbstractMesh): boolean;
  69676. /**
  69677. * Sort function to order lights for rendering.
  69678. * @param a First Light object to compare to second.
  69679. * @param b Second Light object to compare first.
  69680. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  69681. */
  69682. static CompareLightsPriority(a: Light, b: Light): number;
  69683. /**
  69684. * Releases resources associated with this node.
  69685. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  69686. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  69687. */
  69688. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  69689. /**
  69690. * Returns the light type ID (integer).
  69691. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  69692. */
  69693. getTypeID(): number;
  69694. /**
  69695. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  69696. * @returns the scaled intensity in intensity mode unit
  69697. */
  69698. getScaledIntensity(): number;
  69699. /**
  69700. * Returns a new Light object, named "name", from the current one.
  69701. * @param name The name of the cloned light
  69702. * @returns the new created light
  69703. */
  69704. clone(name: string): Nullable<Light>;
  69705. /**
  69706. * Serializes the current light into a Serialization object.
  69707. * @returns the serialized object.
  69708. */
  69709. serialize(): any;
  69710. /**
  69711. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  69712. * This new light is named "name" and added to the passed scene.
  69713. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  69714. * @param name The friendly name of the light
  69715. * @param scene The scene the new light will belong to
  69716. * @returns the constructor function
  69717. */
  69718. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  69719. /**
  69720. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  69721. * @param parsedLight The JSON representation of the light
  69722. * @param scene The scene to create the parsed light in
  69723. * @returns the created light after parsing
  69724. */
  69725. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  69726. private _hookArrayForExcluded;
  69727. private _hookArrayForIncludedOnly;
  69728. private _resyncMeshes;
  69729. /**
  69730. * Forces the meshes to update their light related information in their rendering used effects
  69731. * @hidden Internal Use Only
  69732. */
  69733. _markMeshesAsLightDirty(): void;
  69734. /**
  69735. * Recomputes the cached photometric scale if needed.
  69736. */
  69737. private _computePhotometricScale;
  69738. /**
  69739. * Returns the Photometric Scale according to the light type and intensity mode.
  69740. */
  69741. private _getPhotometricScale;
  69742. /**
  69743. * Reorder the light in the scene according to their defined priority.
  69744. * @hidden Internal Use Only
  69745. */
  69746. _reorderLightsInScene(): void;
  69747. /**
  69748. * Prepares the list of defines specific to the light type.
  69749. * @param defines the list of defines
  69750. * @param lightIndex defines the index of the light for the effect
  69751. */
  69752. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  69753. }
  69754. }
  69755. declare module BABYLON {
  69756. /**
  69757. * Interface used to define Action
  69758. */
  69759. export interface IAction {
  69760. /**
  69761. * Trigger for the action
  69762. */
  69763. trigger: number;
  69764. /** Options of the trigger */
  69765. triggerOptions: any;
  69766. /**
  69767. * Gets the trigger parameters
  69768. * @returns the trigger parameters
  69769. */
  69770. getTriggerParameter(): any;
  69771. /**
  69772. * Internal only - executes current action event
  69773. * @hidden
  69774. */
  69775. _executeCurrent(evt?: ActionEvent): void;
  69776. /**
  69777. * Serialize placeholder for child classes
  69778. * @param parent of child
  69779. * @returns the serialized object
  69780. */
  69781. serialize(parent: any): any;
  69782. /**
  69783. * Internal only
  69784. * @hidden
  69785. */
  69786. _prepare(): void;
  69787. /**
  69788. * Internal only - manager for action
  69789. * @hidden
  69790. */
  69791. _actionManager: AbstractActionManager;
  69792. }
  69793. /**
  69794. * The action to be carried out following a trigger
  69795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  69796. */
  69797. export class Action implements IAction {
  69798. /** the trigger, with or without parameters, for the action */
  69799. triggerOptions: any;
  69800. /**
  69801. * Trigger for the action
  69802. */
  69803. trigger: number;
  69804. /**
  69805. * Internal only - manager for action
  69806. * @hidden
  69807. */
  69808. _actionManager: ActionManager;
  69809. private _nextActiveAction;
  69810. private _child;
  69811. private _condition?;
  69812. private _triggerParameter;
  69813. /**
  69814. * An event triggered prior to action being executed.
  69815. */
  69816. onBeforeExecuteObservable: Observable<Action>;
  69817. /**
  69818. * Creates a new Action
  69819. * @param triggerOptions the trigger, with or without parameters, for the action
  69820. * @param condition an optional determinant of action
  69821. */
  69822. constructor(
  69823. /** the trigger, with or without parameters, for the action */
  69824. triggerOptions: any, condition?: Condition);
  69825. /**
  69826. * Internal only
  69827. * @hidden
  69828. */
  69829. _prepare(): void;
  69830. /**
  69831. * Gets the trigger parameters
  69832. * @returns the trigger parameters
  69833. */
  69834. getTriggerParameter(): any;
  69835. /**
  69836. * Internal only - executes current action event
  69837. * @hidden
  69838. */
  69839. _executeCurrent(evt?: ActionEvent): void;
  69840. /**
  69841. * Execute placeholder for child classes
  69842. * @param evt optional action event
  69843. */
  69844. execute(evt?: ActionEvent): void;
  69845. /**
  69846. * Skips to next active action
  69847. */
  69848. skipToNextActiveAction(): void;
  69849. /**
  69850. * Adds action to chain of actions, may be a DoNothingAction
  69851. * @param action defines the next action to execute
  69852. * @returns The action passed in
  69853. * @see https://www.babylonjs-playground.com/#1T30HR#0
  69854. */
  69855. then(action: Action): Action;
  69856. /**
  69857. * Internal only
  69858. * @hidden
  69859. */
  69860. _getProperty(propertyPath: string): string;
  69861. /**
  69862. * Internal only
  69863. * @hidden
  69864. */
  69865. _getEffectiveTarget(target: any, propertyPath: string): any;
  69866. /**
  69867. * Serialize placeholder for child classes
  69868. * @param parent of child
  69869. * @returns the serialized object
  69870. */
  69871. serialize(parent: any): any;
  69872. /**
  69873. * Internal only called by serialize
  69874. * @hidden
  69875. */
  69876. protected _serialize(serializedAction: any, parent?: any): any;
  69877. /**
  69878. * Internal only
  69879. * @hidden
  69880. */
  69881. static _SerializeValueAsString: (value: any) => string;
  69882. /**
  69883. * Internal only
  69884. * @hidden
  69885. */
  69886. static _GetTargetProperty: (target: Scene | Node) => {
  69887. name: string;
  69888. targetType: string;
  69889. value: string;
  69890. };
  69891. }
  69892. }
  69893. declare module BABYLON {
  69894. /**
  69895. * A Condition applied to an Action
  69896. */
  69897. export class Condition {
  69898. /**
  69899. * Internal only - manager for action
  69900. * @hidden
  69901. */
  69902. _actionManager: ActionManager;
  69903. /**
  69904. * Internal only
  69905. * @hidden
  69906. */
  69907. _evaluationId: number;
  69908. /**
  69909. * Internal only
  69910. * @hidden
  69911. */
  69912. _currentResult: boolean;
  69913. /**
  69914. * Creates a new Condition
  69915. * @param actionManager the manager of the action the condition is applied to
  69916. */
  69917. constructor(actionManager: ActionManager);
  69918. /**
  69919. * Check if the current condition is valid
  69920. * @returns a boolean
  69921. */
  69922. isValid(): boolean;
  69923. /**
  69924. * Internal only
  69925. * @hidden
  69926. */
  69927. _getProperty(propertyPath: string): string;
  69928. /**
  69929. * Internal only
  69930. * @hidden
  69931. */
  69932. _getEffectiveTarget(target: any, propertyPath: string): any;
  69933. /**
  69934. * Serialize placeholder for child classes
  69935. * @returns the serialized object
  69936. */
  69937. serialize(): any;
  69938. /**
  69939. * Internal only
  69940. * @hidden
  69941. */
  69942. protected _serialize(serializedCondition: any): any;
  69943. }
  69944. /**
  69945. * Defines specific conditional operators as extensions of Condition
  69946. */
  69947. export class ValueCondition extends Condition {
  69948. /** path to specify the property of the target the conditional operator uses */
  69949. propertyPath: string;
  69950. /** the value compared by the conditional operator against the current value of the property */
  69951. value: any;
  69952. /** the conditional operator, default ValueCondition.IsEqual */
  69953. operator: number;
  69954. /**
  69955. * Internal only
  69956. * @hidden
  69957. */
  69958. private static _IsEqual;
  69959. /**
  69960. * Internal only
  69961. * @hidden
  69962. */
  69963. private static _IsDifferent;
  69964. /**
  69965. * Internal only
  69966. * @hidden
  69967. */
  69968. private static _IsGreater;
  69969. /**
  69970. * Internal only
  69971. * @hidden
  69972. */
  69973. private static _IsLesser;
  69974. /**
  69975. * returns the number for IsEqual
  69976. */
  69977. static readonly IsEqual: number;
  69978. /**
  69979. * Returns the number for IsDifferent
  69980. */
  69981. static readonly IsDifferent: number;
  69982. /**
  69983. * Returns the number for IsGreater
  69984. */
  69985. static readonly IsGreater: number;
  69986. /**
  69987. * Returns the number for IsLesser
  69988. */
  69989. static readonly IsLesser: number;
  69990. /**
  69991. * Internal only The action manager for the condition
  69992. * @hidden
  69993. */
  69994. _actionManager: ActionManager;
  69995. /**
  69996. * Internal only
  69997. * @hidden
  69998. */
  69999. private _target;
  70000. /**
  70001. * Internal only
  70002. * @hidden
  70003. */
  70004. private _effectiveTarget;
  70005. /**
  70006. * Internal only
  70007. * @hidden
  70008. */
  70009. private _property;
  70010. /**
  70011. * Creates a new ValueCondition
  70012. * @param actionManager manager for the action the condition applies to
  70013. * @param target for the action
  70014. * @param propertyPath path to specify the property of the target the conditional operator uses
  70015. * @param value the value compared by the conditional operator against the current value of the property
  70016. * @param operator the conditional operator, default ValueCondition.IsEqual
  70017. */
  70018. constructor(actionManager: ActionManager, target: any,
  70019. /** path to specify the property of the target the conditional operator uses */
  70020. propertyPath: string,
  70021. /** the value compared by the conditional operator against the current value of the property */
  70022. value: any,
  70023. /** the conditional operator, default ValueCondition.IsEqual */
  70024. operator?: number);
  70025. /**
  70026. * Compares the given value with the property value for the specified conditional operator
  70027. * @returns the result of the comparison
  70028. */
  70029. isValid(): boolean;
  70030. /**
  70031. * Serialize the ValueCondition into a JSON compatible object
  70032. * @returns serialization object
  70033. */
  70034. serialize(): any;
  70035. /**
  70036. * Gets the name of the conditional operator for the ValueCondition
  70037. * @param operator the conditional operator
  70038. * @returns the name
  70039. */
  70040. static GetOperatorName(operator: number): string;
  70041. }
  70042. /**
  70043. * Defines a predicate condition as an extension of Condition
  70044. */
  70045. export class PredicateCondition extends Condition {
  70046. /** defines the predicate function used to validate the condition */
  70047. predicate: () => boolean;
  70048. /**
  70049. * Internal only - manager for action
  70050. * @hidden
  70051. */
  70052. _actionManager: ActionManager;
  70053. /**
  70054. * Creates a new PredicateCondition
  70055. * @param actionManager manager for the action the condition applies to
  70056. * @param predicate defines the predicate function used to validate the condition
  70057. */
  70058. constructor(actionManager: ActionManager,
  70059. /** defines the predicate function used to validate the condition */
  70060. predicate: () => boolean);
  70061. /**
  70062. * @returns the validity of the predicate condition
  70063. */
  70064. isValid(): boolean;
  70065. }
  70066. /**
  70067. * Defines a state condition as an extension of Condition
  70068. */
  70069. export class StateCondition extends Condition {
  70070. /** Value to compare with target state */
  70071. value: string;
  70072. /**
  70073. * Internal only - manager for action
  70074. * @hidden
  70075. */
  70076. _actionManager: ActionManager;
  70077. /**
  70078. * Internal only
  70079. * @hidden
  70080. */
  70081. private _target;
  70082. /**
  70083. * Creates a new StateCondition
  70084. * @param actionManager manager for the action the condition applies to
  70085. * @param target of the condition
  70086. * @param value to compare with target state
  70087. */
  70088. constructor(actionManager: ActionManager, target: any,
  70089. /** Value to compare with target state */
  70090. value: string);
  70091. /**
  70092. * Gets a boolean indicating if the current condition is met
  70093. * @returns the validity of the state
  70094. */
  70095. isValid(): boolean;
  70096. /**
  70097. * Serialize the StateCondition into a JSON compatible object
  70098. * @returns serialization object
  70099. */
  70100. serialize(): any;
  70101. }
  70102. }
  70103. declare module BABYLON {
  70104. /**
  70105. * This defines an action responsible to toggle a boolean once triggered.
  70106. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70107. */
  70108. export class SwitchBooleanAction extends Action {
  70109. /**
  70110. * The path to the boolean property in the target object
  70111. */
  70112. propertyPath: string;
  70113. private _target;
  70114. private _effectiveTarget;
  70115. private _property;
  70116. /**
  70117. * Instantiate the action
  70118. * @param triggerOptions defines the trigger options
  70119. * @param target defines the object containing the boolean
  70120. * @param propertyPath defines the path to the boolean property in the target object
  70121. * @param condition defines the trigger related conditions
  70122. */
  70123. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  70124. /** @hidden */
  70125. _prepare(): void;
  70126. /**
  70127. * Execute the action toggle the boolean value.
  70128. */
  70129. execute(): void;
  70130. /**
  70131. * Serializes the actions and its related information.
  70132. * @param parent defines the object to serialize in
  70133. * @returns the serialized object
  70134. */
  70135. serialize(parent: any): any;
  70136. }
  70137. /**
  70138. * This defines an action responsible to set a the state field of the target
  70139. * to a desired value once triggered.
  70140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70141. */
  70142. export class SetStateAction extends Action {
  70143. /**
  70144. * The value to store in the state field.
  70145. */
  70146. value: string;
  70147. private _target;
  70148. /**
  70149. * Instantiate the action
  70150. * @param triggerOptions defines the trigger options
  70151. * @param target defines the object containing the state property
  70152. * @param value defines the value to store in the state field
  70153. * @param condition defines the trigger related conditions
  70154. */
  70155. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  70156. /**
  70157. * Execute the action and store the value on the target state property.
  70158. */
  70159. execute(): void;
  70160. /**
  70161. * Serializes the actions and its related information.
  70162. * @param parent defines the object to serialize in
  70163. * @returns the serialized object
  70164. */
  70165. serialize(parent: any): any;
  70166. }
  70167. /**
  70168. * This defines an action responsible to set a property of the target
  70169. * to a desired value once triggered.
  70170. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70171. */
  70172. export class SetValueAction extends Action {
  70173. /**
  70174. * The path of the property to set in the target.
  70175. */
  70176. propertyPath: string;
  70177. /**
  70178. * The value to set in the property
  70179. */
  70180. value: any;
  70181. private _target;
  70182. private _effectiveTarget;
  70183. private _property;
  70184. /**
  70185. * Instantiate the action
  70186. * @param triggerOptions defines the trigger options
  70187. * @param target defines the object containing the property
  70188. * @param propertyPath defines the path of the property to set in the target
  70189. * @param value defines the value to set in the property
  70190. * @param condition defines the trigger related conditions
  70191. */
  70192. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70193. /** @hidden */
  70194. _prepare(): void;
  70195. /**
  70196. * Execute the action and set the targetted property to the desired value.
  70197. */
  70198. execute(): void;
  70199. /**
  70200. * Serializes the actions and its related information.
  70201. * @param parent defines the object to serialize in
  70202. * @returns the serialized object
  70203. */
  70204. serialize(parent: any): any;
  70205. }
  70206. /**
  70207. * This defines an action responsible to increment the target value
  70208. * to a desired value once triggered.
  70209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70210. */
  70211. export class IncrementValueAction extends Action {
  70212. /**
  70213. * The path of the property to increment in the target.
  70214. */
  70215. propertyPath: string;
  70216. /**
  70217. * The value we should increment the property by.
  70218. */
  70219. value: any;
  70220. private _target;
  70221. private _effectiveTarget;
  70222. private _property;
  70223. /**
  70224. * Instantiate the action
  70225. * @param triggerOptions defines the trigger options
  70226. * @param target defines the object containing the property
  70227. * @param propertyPath defines the path of the property to increment in the target
  70228. * @param value defines the value value we should increment the property by
  70229. * @param condition defines the trigger related conditions
  70230. */
  70231. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70232. /** @hidden */
  70233. _prepare(): void;
  70234. /**
  70235. * Execute the action and increment the target of the value amount.
  70236. */
  70237. execute(): void;
  70238. /**
  70239. * Serializes the actions and its related information.
  70240. * @param parent defines the object to serialize in
  70241. * @returns the serialized object
  70242. */
  70243. serialize(parent: any): any;
  70244. }
  70245. /**
  70246. * This defines an action responsible to start an animation once triggered.
  70247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70248. */
  70249. export class PlayAnimationAction extends Action {
  70250. /**
  70251. * Where the animation should start (animation frame)
  70252. */
  70253. from: number;
  70254. /**
  70255. * Where the animation should stop (animation frame)
  70256. */
  70257. to: number;
  70258. /**
  70259. * Define if the animation should loop or stop after the first play.
  70260. */
  70261. loop?: boolean;
  70262. private _target;
  70263. /**
  70264. * Instantiate the action
  70265. * @param triggerOptions defines the trigger options
  70266. * @param target defines the target animation or animation name
  70267. * @param from defines from where the animation should start (animation frame)
  70268. * @param end defines where the animation should stop (animation frame)
  70269. * @param loop defines if the animation should loop or stop after the first play
  70270. * @param condition defines the trigger related conditions
  70271. */
  70272. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  70273. /** @hidden */
  70274. _prepare(): void;
  70275. /**
  70276. * Execute the action and play the animation.
  70277. */
  70278. execute(): void;
  70279. /**
  70280. * Serializes the actions and its related information.
  70281. * @param parent defines the object to serialize in
  70282. * @returns the serialized object
  70283. */
  70284. serialize(parent: any): any;
  70285. }
  70286. /**
  70287. * This defines an action responsible to stop an animation once triggered.
  70288. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70289. */
  70290. export class StopAnimationAction extends Action {
  70291. private _target;
  70292. /**
  70293. * Instantiate the action
  70294. * @param triggerOptions defines the trigger options
  70295. * @param target defines the target animation or animation name
  70296. * @param condition defines the trigger related conditions
  70297. */
  70298. constructor(triggerOptions: any, target: any, condition?: Condition);
  70299. /** @hidden */
  70300. _prepare(): void;
  70301. /**
  70302. * Execute the action and stop the animation.
  70303. */
  70304. execute(): void;
  70305. /**
  70306. * Serializes the actions and its related information.
  70307. * @param parent defines the object to serialize in
  70308. * @returns the serialized object
  70309. */
  70310. serialize(parent: any): any;
  70311. }
  70312. /**
  70313. * This defines an action responsible that does nothing once triggered.
  70314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70315. */
  70316. export class DoNothingAction extends Action {
  70317. /**
  70318. * Instantiate the action
  70319. * @param triggerOptions defines the trigger options
  70320. * @param condition defines the trigger related conditions
  70321. */
  70322. constructor(triggerOptions?: any, condition?: Condition);
  70323. /**
  70324. * Execute the action and do nothing.
  70325. */
  70326. execute(): void;
  70327. /**
  70328. * Serializes the actions and its related information.
  70329. * @param parent defines the object to serialize in
  70330. * @returns the serialized object
  70331. */
  70332. serialize(parent: any): any;
  70333. }
  70334. /**
  70335. * This defines an action responsible to trigger several actions once triggered.
  70336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70337. */
  70338. export class CombineAction extends Action {
  70339. /**
  70340. * The list of aggregated animations to run.
  70341. */
  70342. children: Action[];
  70343. /**
  70344. * Instantiate the action
  70345. * @param triggerOptions defines the trigger options
  70346. * @param children defines the list of aggregated animations to run
  70347. * @param condition defines the trigger related conditions
  70348. */
  70349. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  70350. /** @hidden */
  70351. _prepare(): void;
  70352. /**
  70353. * Execute the action and executes all the aggregated actions.
  70354. */
  70355. execute(evt: ActionEvent): void;
  70356. /**
  70357. * Serializes the actions and its related information.
  70358. * @param parent defines the object to serialize in
  70359. * @returns the serialized object
  70360. */
  70361. serialize(parent: any): any;
  70362. }
  70363. /**
  70364. * This defines an action responsible to run code (external event) once triggered.
  70365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70366. */
  70367. export class ExecuteCodeAction extends Action {
  70368. /**
  70369. * The callback function to run.
  70370. */
  70371. func: (evt: ActionEvent) => void;
  70372. /**
  70373. * Instantiate the action
  70374. * @param triggerOptions defines the trigger options
  70375. * @param func defines the callback function to run
  70376. * @param condition defines the trigger related conditions
  70377. */
  70378. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  70379. /**
  70380. * Execute the action and run the attached code.
  70381. */
  70382. execute(evt: ActionEvent): void;
  70383. }
  70384. /**
  70385. * This defines an action responsible to set the parent property of the target once triggered.
  70386. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70387. */
  70388. export class SetParentAction extends Action {
  70389. private _parent;
  70390. private _target;
  70391. /**
  70392. * Instantiate the action
  70393. * @param triggerOptions defines the trigger options
  70394. * @param target defines the target containing the parent property
  70395. * @param parent defines from where the animation should start (animation frame)
  70396. * @param condition defines the trigger related conditions
  70397. */
  70398. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  70399. /** @hidden */
  70400. _prepare(): void;
  70401. /**
  70402. * Execute the action and set the parent property.
  70403. */
  70404. execute(): void;
  70405. /**
  70406. * Serializes the actions and its related information.
  70407. * @param parent defines the object to serialize in
  70408. * @returns the serialized object
  70409. */
  70410. serialize(parent: any): any;
  70411. }
  70412. }
  70413. declare module BABYLON {
  70414. /**
  70415. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  70416. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  70417. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70418. */
  70419. export class ActionManager extends AbstractActionManager {
  70420. /**
  70421. * Nothing
  70422. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70423. */
  70424. static readonly NothingTrigger: number;
  70425. /**
  70426. * On pick
  70427. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70428. */
  70429. static readonly OnPickTrigger: number;
  70430. /**
  70431. * On left pick
  70432. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70433. */
  70434. static readonly OnLeftPickTrigger: number;
  70435. /**
  70436. * On right pick
  70437. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70438. */
  70439. static readonly OnRightPickTrigger: number;
  70440. /**
  70441. * On center pick
  70442. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70443. */
  70444. static readonly OnCenterPickTrigger: number;
  70445. /**
  70446. * On pick down
  70447. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70448. */
  70449. static readonly OnPickDownTrigger: number;
  70450. /**
  70451. * On double pick
  70452. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70453. */
  70454. static readonly OnDoublePickTrigger: number;
  70455. /**
  70456. * On pick up
  70457. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70458. */
  70459. static readonly OnPickUpTrigger: number;
  70460. /**
  70461. * On pick out.
  70462. * This trigger will only be raised if you also declared a OnPickDown
  70463. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70464. */
  70465. static readonly OnPickOutTrigger: number;
  70466. /**
  70467. * On long press
  70468. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70469. */
  70470. static readonly OnLongPressTrigger: number;
  70471. /**
  70472. * On pointer over
  70473. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70474. */
  70475. static readonly OnPointerOverTrigger: number;
  70476. /**
  70477. * On pointer out
  70478. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70479. */
  70480. static readonly OnPointerOutTrigger: number;
  70481. /**
  70482. * On every frame
  70483. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70484. */
  70485. static readonly OnEveryFrameTrigger: number;
  70486. /**
  70487. * On intersection enter
  70488. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70489. */
  70490. static readonly OnIntersectionEnterTrigger: number;
  70491. /**
  70492. * On intersection exit
  70493. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70494. */
  70495. static readonly OnIntersectionExitTrigger: number;
  70496. /**
  70497. * On key down
  70498. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70499. */
  70500. static readonly OnKeyDownTrigger: number;
  70501. /**
  70502. * On key up
  70503. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70504. */
  70505. static readonly OnKeyUpTrigger: number;
  70506. private _scene;
  70507. /**
  70508. * Creates a new action manager
  70509. * @param scene defines the hosting scene
  70510. */
  70511. constructor(scene: Scene);
  70512. /**
  70513. * Releases all associated resources
  70514. */
  70515. dispose(): void;
  70516. /**
  70517. * Gets hosting scene
  70518. * @returns the hosting scene
  70519. */
  70520. getScene(): Scene;
  70521. /**
  70522. * Does this action manager handles actions of any of the given triggers
  70523. * @param triggers defines the triggers to be tested
  70524. * @return a boolean indicating whether one (or more) of the triggers is handled
  70525. */
  70526. hasSpecificTriggers(triggers: number[]): boolean;
  70527. /**
  70528. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  70529. * speed.
  70530. * @param triggerA defines the trigger to be tested
  70531. * @param triggerB defines the trigger to be tested
  70532. * @return a boolean indicating whether one (or more) of the triggers is handled
  70533. */
  70534. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  70535. /**
  70536. * Does this action manager handles actions of a given trigger
  70537. * @param trigger defines the trigger to be tested
  70538. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  70539. * @return whether the trigger is handled
  70540. */
  70541. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  70542. /**
  70543. * Does this action manager has pointer triggers
  70544. */
  70545. readonly hasPointerTriggers: boolean;
  70546. /**
  70547. * Does this action manager has pick triggers
  70548. */
  70549. readonly hasPickTriggers: boolean;
  70550. /**
  70551. * Registers an action to this action manager
  70552. * @param action defines the action to be registered
  70553. * @return the action amended (prepared) after registration
  70554. */
  70555. registerAction(action: IAction): Nullable<IAction>;
  70556. /**
  70557. * Unregisters an action to this action manager
  70558. * @param action defines the action to be unregistered
  70559. * @return a boolean indicating whether the action has been unregistered
  70560. */
  70561. unregisterAction(action: IAction): Boolean;
  70562. /**
  70563. * Process a specific trigger
  70564. * @param trigger defines the trigger to process
  70565. * @param evt defines the event details to be processed
  70566. */
  70567. processTrigger(trigger: number, evt?: IActionEvent): void;
  70568. /** @hidden */
  70569. _getEffectiveTarget(target: any, propertyPath: string): any;
  70570. /** @hidden */
  70571. _getProperty(propertyPath: string): string;
  70572. /**
  70573. * Serialize this manager to a JSON object
  70574. * @param name defines the property name to store this manager
  70575. * @returns a JSON representation of this manager
  70576. */
  70577. serialize(name: string): any;
  70578. /**
  70579. * Creates a new ActionManager from a JSON data
  70580. * @param parsedActions defines the JSON data to read from
  70581. * @param object defines the hosting mesh
  70582. * @param scene defines the hosting scene
  70583. */
  70584. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  70585. /**
  70586. * Get a trigger name by index
  70587. * @param trigger defines the trigger index
  70588. * @returns a trigger name
  70589. */
  70590. static GetTriggerName(trigger: number): string;
  70591. }
  70592. }
  70593. declare module BABYLON {
  70594. /**
  70595. * Class representing a ray with position and direction
  70596. */
  70597. export class Ray {
  70598. /** origin point */
  70599. origin: Vector3;
  70600. /** direction */
  70601. direction: Vector3;
  70602. /** length of the ray */
  70603. length: number;
  70604. private static readonly TmpVector3;
  70605. private _tmpRay;
  70606. /**
  70607. * Creates a new ray
  70608. * @param origin origin point
  70609. * @param direction direction
  70610. * @param length length of the ray
  70611. */
  70612. constructor(
  70613. /** origin point */
  70614. origin: Vector3,
  70615. /** direction */
  70616. direction: Vector3,
  70617. /** length of the ray */
  70618. length?: number);
  70619. /**
  70620. * Checks if the ray intersects a box
  70621. * @param minimum bound of the box
  70622. * @param maximum bound of the box
  70623. * @param intersectionTreshold extra extend to be added to the box in all direction
  70624. * @returns if the box was hit
  70625. */
  70626. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  70627. /**
  70628. * Checks if the ray intersects a box
  70629. * @param box the bounding box to check
  70630. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  70631. * @returns if the box was hit
  70632. */
  70633. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  70634. /**
  70635. * If the ray hits a sphere
  70636. * @param sphere the bounding sphere to check
  70637. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  70638. * @returns true if it hits the sphere
  70639. */
  70640. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  70641. /**
  70642. * If the ray hits a triange
  70643. * @param vertex0 triangle vertex
  70644. * @param vertex1 triangle vertex
  70645. * @param vertex2 triangle vertex
  70646. * @returns intersection information if hit
  70647. */
  70648. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  70649. /**
  70650. * Checks if ray intersects a plane
  70651. * @param plane the plane to check
  70652. * @returns the distance away it was hit
  70653. */
  70654. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  70655. /**
  70656. * Checks if ray intersects a mesh
  70657. * @param mesh the mesh to check
  70658. * @param fastCheck if only the bounding box should checked
  70659. * @returns picking info of the intersecton
  70660. */
  70661. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  70662. /**
  70663. * Checks if ray intersects a mesh
  70664. * @param meshes the meshes to check
  70665. * @param fastCheck if only the bounding box should checked
  70666. * @param results array to store result in
  70667. * @returns Array of picking infos
  70668. */
  70669. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  70670. private _comparePickingInfo;
  70671. private static smallnum;
  70672. private static rayl;
  70673. /**
  70674. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  70675. * @param sega the first point of the segment to test the intersection against
  70676. * @param segb the second point of the segment to test the intersection against
  70677. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  70678. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  70679. */
  70680. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  70681. /**
  70682. * Update the ray from viewport position
  70683. * @param x position
  70684. * @param y y position
  70685. * @param viewportWidth viewport width
  70686. * @param viewportHeight viewport height
  70687. * @param world world matrix
  70688. * @param view view matrix
  70689. * @param projection projection matrix
  70690. * @returns this ray updated
  70691. */
  70692. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  70693. /**
  70694. * Creates a ray with origin and direction of 0,0,0
  70695. * @returns the new ray
  70696. */
  70697. static Zero(): Ray;
  70698. /**
  70699. * Creates a new ray from screen space and viewport
  70700. * @param x position
  70701. * @param y y position
  70702. * @param viewportWidth viewport width
  70703. * @param viewportHeight viewport height
  70704. * @param world world matrix
  70705. * @param view view matrix
  70706. * @param projection projection matrix
  70707. * @returns new ray
  70708. */
  70709. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  70710. /**
  70711. * 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
  70712. * transformed to the given world matrix.
  70713. * @param origin The origin point
  70714. * @param end The end point
  70715. * @param world a matrix to transform the ray to. Default is the identity matrix.
  70716. * @returns the new ray
  70717. */
  70718. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  70719. /**
  70720. * Transforms a ray by a matrix
  70721. * @param ray ray to transform
  70722. * @param matrix matrix to apply
  70723. * @returns the resulting new ray
  70724. */
  70725. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  70726. /**
  70727. * Transforms a ray by a matrix
  70728. * @param ray ray to transform
  70729. * @param matrix matrix to apply
  70730. * @param result ray to store result in
  70731. */
  70732. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  70733. /**
  70734. * Unproject a ray from screen space to object space
  70735. * @param sourceX defines the screen space x coordinate to use
  70736. * @param sourceY defines the screen space y coordinate to use
  70737. * @param viewportWidth defines the current width of the viewport
  70738. * @param viewportHeight defines the current height of the viewport
  70739. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70740. * @param view defines the view matrix to use
  70741. * @param projection defines the projection matrix to use
  70742. */
  70743. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  70744. }
  70745. /**
  70746. * Type used to define predicate used to select faces when a mesh intersection is detected
  70747. */
  70748. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  70749. interface Scene {
  70750. /** @hidden */
  70751. _tempPickingRay: Nullable<Ray>;
  70752. /** @hidden */
  70753. _cachedRayForTransform: Ray;
  70754. /** @hidden */
  70755. _pickWithRayInverseMatrix: Matrix;
  70756. /** @hidden */
  70757. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  70758. /** @hidden */
  70759. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  70760. }
  70761. }
  70762. declare module BABYLON {
  70763. /**
  70764. * Groups all the scene component constants in one place to ease maintenance.
  70765. * @hidden
  70766. */
  70767. export class SceneComponentConstants {
  70768. static readonly NAME_EFFECTLAYER: string;
  70769. static readonly NAME_LAYER: string;
  70770. static readonly NAME_LENSFLARESYSTEM: string;
  70771. static readonly NAME_BOUNDINGBOXRENDERER: string;
  70772. static readonly NAME_PARTICLESYSTEM: string;
  70773. static readonly NAME_GAMEPAD: string;
  70774. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  70775. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  70776. static readonly NAME_DEPTHRENDERER: string;
  70777. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  70778. static readonly NAME_SPRITE: string;
  70779. static readonly NAME_OUTLINERENDERER: string;
  70780. static readonly NAME_PROCEDURALTEXTURE: string;
  70781. static readonly NAME_SHADOWGENERATOR: string;
  70782. static readonly NAME_OCTREE: string;
  70783. static readonly NAME_PHYSICSENGINE: string;
  70784. static readonly NAME_AUDIO: string;
  70785. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  70786. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  70787. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  70788. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  70789. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  70790. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  70791. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  70792. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  70793. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  70794. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  70795. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  70796. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  70797. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  70798. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  70799. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  70800. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  70801. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  70802. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  70803. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  70804. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  70805. static readonly STEP_AFTERRENDER_AUDIO: number;
  70806. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  70807. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  70808. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  70809. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  70810. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  70811. static readonly STEP_POINTERMOVE_SPRITE: number;
  70812. static readonly STEP_POINTERDOWN_SPRITE: number;
  70813. static readonly STEP_POINTERUP_SPRITE: number;
  70814. }
  70815. /**
  70816. * This represents a scene component.
  70817. *
  70818. * This is used to decouple the dependency the scene is having on the different workloads like
  70819. * layers, post processes...
  70820. */
  70821. export interface ISceneComponent {
  70822. /**
  70823. * The name of the component. Each component must have a unique name.
  70824. */
  70825. name: string;
  70826. /**
  70827. * The scene the component belongs to.
  70828. */
  70829. scene: Scene;
  70830. /**
  70831. * Register the component to one instance of a scene.
  70832. */
  70833. register(): void;
  70834. /**
  70835. * Rebuilds the elements related to this component in case of
  70836. * context lost for instance.
  70837. */
  70838. rebuild(): void;
  70839. /**
  70840. * Disposes the component and the associated ressources.
  70841. */
  70842. dispose(): void;
  70843. }
  70844. /**
  70845. * This represents a SERIALIZABLE scene component.
  70846. *
  70847. * This extends Scene Component to add Serialization methods on top.
  70848. */
  70849. export interface ISceneSerializableComponent extends ISceneComponent {
  70850. /**
  70851. * Adds all the element from the container to the scene
  70852. * @param container the container holding the elements
  70853. */
  70854. addFromContainer(container: AbstractScene): void;
  70855. /**
  70856. * Removes all the elements in the container from the scene
  70857. * @param container contains the elements to remove
  70858. * @param dispose if the removed element should be disposed (default: false)
  70859. */
  70860. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  70861. /**
  70862. * Serializes the component data to the specified json object
  70863. * @param serializationObject The object to serialize to
  70864. */
  70865. serialize(serializationObject: any): void;
  70866. }
  70867. /**
  70868. * Strong typing of a Mesh related stage step action
  70869. */
  70870. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  70871. /**
  70872. * Strong typing of a Evaluate Sub Mesh related stage step action
  70873. */
  70874. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  70875. /**
  70876. * Strong typing of a Active Mesh related stage step action
  70877. */
  70878. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  70879. /**
  70880. * Strong typing of a Camera related stage step action
  70881. */
  70882. export type CameraStageAction = (camera: Camera) => void;
  70883. /**
  70884. * Strong typing of a Render Target related stage step action
  70885. */
  70886. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  70887. /**
  70888. * Strong typing of a RenderingGroup related stage step action
  70889. */
  70890. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  70891. /**
  70892. * Strong typing of a Mesh Render related stage step action
  70893. */
  70894. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  70895. /**
  70896. * Strong typing of a simple stage step action
  70897. */
  70898. export type SimpleStageAction = () => void;
  70899. /**
  70900. * Strong typing of a render target action.
  70901. */
  70902. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  70903. /**
  70904. * Strong typing of a pointer move action.
  70905. */
  70906. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  70907. /**
  70908. * Strong typing of a pointer up/down action.
  70909. */
  70910. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  70911. /**
  70912. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  70913. * @hidden
  70914. */
  70915. export class Stage<T extends Function> extends Array<{
  70916. index: number;
  70917. component: ISceneComponent;
  70918. action: T;
  70919. }> {
  70920. /**
  70921. * Hide ctor from the rest of the world.
  70922. * @param items The items to add.
  70923. */
  70924. private constructor();
  70925. /**
  70926. * Creates a new Stage.
  70927. * @returns A new instance of a Stage
  70928. */
  70929. static Create<T extends Function>(): Stage<T>;
  70930. /**
  70931. * Registers a step in an ordered way in the targeted stage.
  70932. * @param index Defines the position to register the step in
  70933. * @param component Defines the component attached to the step
  70934. * @param action Defines the action to launch during the step
  70935. */
  70936. registerStep(index: number, component: ISceneComponent, action: T): void;
  70937. /**
  70938. * Clears all the steps from the stage.
  70939. */
  70940. clear(): void;
  70941. }
  70942. }
  70943. declare module BABYLON {
  70944. interface Scene {
  70945. /** @hidden */
  70946. _pointerOverSprite: Nullable<Sprite>;
  70947. /** @hidden */
  70948. _pickedDownSprite: Nullable<Sprite>;
  70949. /** @hidden */
  70950. _tempSpritePickingRay: Nullable<Ray>;
  70951. /**
  70952. * All of the sprite managers added to this scene
  70953. * @see http://doc.babylonjs.com/babylon101/sprites
  70954. */
  70955. spriteManagers: Array<ISpriteManager>;
  70956. /**
  70957. * An event triggered when sprites rendering is about to start
  70958. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70959. */
  70960. onBeforeSpritesRenderingObservable: Observable<Scene>;
  70961. /**
  70962. * An event triggered when sprites rendering is done
  70963. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70964. */
  70965. onAfterSpritesRenderingObservable: Observable<Scene>;
  70966. /** @hidden */
  70967. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70968. /** Launch a ray to try to pick a sprite in the scene
  70969. * @param x position on screen
  70970. * @param y position on screen
  70971. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  70972. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  70973. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  70974. * @returns a PickingInfo
  70975. */
  70976. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70977. /** Use the given ray to pick a sprite in the scene
  70978. * @param ray The ray (in world space) to use to pick meshes
  70979. * @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
  70980. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  70981. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  70982. * @returns a PickingInfo
  70983. */
  70984. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70985. /**
  70986. * Force the sprite under the pointer
  70987. * @param sprite defines the sprite to use
  70988. */
  70989. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  70990. /**
  70991. * Gets the sprite under the pointer
  70992. * @returns a Sprite or null if no sprite is under the pointer
  70993. */
  70994. getPointerOverSprite(): Nullable<Sprite>;
  70995. }
  70996. /**
  70997. * Defines the sprite scene component responsible to manage sprites
  70998. * in a given scene.
  70999. */
  71000. export class SpriteSceneComponent implements ISceneComponent {
  71001. /**
  71002. * The component name helpfull to identify the component in the list of scene components.
  71003. */
  71004. readonly name: string;
  71005. /**
  71006. * The scene the component belongs to.
  71007. */
  71008. scene: Scene;
  71009. /** @hidden */
  71010. private _spritePredicate;
  71011. /**
  71012. * Creates a new instance of the component for the given scene
  71013. * @param scene Defines the scene to register the component in
  71014. */
  71015. constructor(scene: Scene);
  71016. /**
  71017. * Registers the component in a given scene
  71018. */
  71019. register(): void;
  71020. /**
  71021. * Rebuilds the elements related to this component in case of
  71022. * context lost for instance.
  71023. */
  71024. rebuild(): void;
  71025. /**
  71026. * Disposes the component and the associated ressources.
  71027. */
  71028. dispose(): void;
  71029. private _pickSpriteButKeepRay;
  71030. private _pointerMove;
  71031. private _pointerDown;
  71032. private _pointerUp;
  71033. }
  71034. }
  71035. declare module BABYLON {
  71036. /** @hidden */
  71037. export var fogFragmentDeclaration: {
  71038. name: string;
  71039. shader: string;
  71040. };
  71041. }
  71042. declare module BABYLON {
  71043. /** @hidden */
  71044. export var fogFragment: {
  71045. name: string;
  71046. shader: string;
  71047. };
  71048. }
  71049. declare module BABYLON {
  71050. /** @hidden */
  71051. export var spritesPixelShader: {
  71052. name: string;
  71053. shader: string;
  71054. };
  71055. }
  71056. declare module BABYLON {
  71057. /** @hidden */
  71058. export var fogVertexDeclaration: {
  71059. name: string;
  71060. shader: string;
  71061. };
  71062. }
  71063. declare module BABYLON {
  71064. /** @hidden */
  71065. export var spritesVertexShader: {
  71066. name: string;
  71067. shader: string;
  71068. };
  71069. }
  71070. declare module BABYLON {
  71071. /**
  71072. * Defines the minimum interface to fullfil in order to be a sprite manager.
  71073. */
  71074. export interface ISpriteManager extends IDisposable {
  71075. /**
  71076. * Restricts the camera to viewing objects with the same layerMask.
  71077. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  71078. */
  71079. layerMask: number;
  71080. /**
  71081. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  71082. */
  71083. isPickable: boolean;
  71084. /**
  71085. * Specifies the rendering group id for this mesh (0 by default)
  71086. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  71087. */
  71088. renderingGroupId: number;
  71089. /**
  71090. * Defines the list of sprites managed by the manager.
  71091. */
  71092. sprites: Array<Sprite>;
  71093. /**
  71094. * Tests the intersection of a sprite with a specific ray.
  71095. * @param ray The ray we are sending to test the collision
  71096. * @param camera The camera space we are sending rays in
  71097. * @param predicate A predicate allowing excluding sprites from the list of object to test
  71098. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  71099. * @returns picking info or null.
  71100. */
  71101. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71102. /**
  71103. * Renders the list of sprites on screen.
  71104. */
  71105. render(): void;
  71106. }
  71107. /**
  71108. * Class used to manage multiple sprites on the same spritesheet
  71109. * @see http://doc.babylonjs.com/babylon101/sprites
  71110. */
  71111. export class SpriteManager implements ISpriteManager {
  71112. /** defines the manager's name */
  71113. name: string;
  71114. /** Gets the list of sprites */
  71115. sprites: Sprite[];
  71116. /** Gets or sets the rendering group id (0 by default) */
  71117. renderingGroupId: number;
  71118. /** Gets or sets camera layer mask */
  71119. layerMask: number;
  71120. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  71121. fogEnabled: boolean;
  71122. /** Gets or sets a boolean indicating if the sprites are pickable */
  71123. isPickable: boolean;
  71124. /** Defines the default width of a cell in the spritesheet */
  71125. cellWidth: number;
  71126. /** Defines the default height of a cell in the spritesheet */
  71127. cellHeight: number;
  71128. /**
  71129. * An event triggered when the manager is disposed.
  71130. */
  71131. onDisposeObservable: Observable<SpriteManager>;
  71132. private _onDisposeObserver;
  71133. /**
  71134. * Callback called when the manager is disposed
  71135. */
  71136. onDispose: () => void;
  71137. private _capacity;
  71138. private _spriteTexture;
  71139. private _epsilon;
  71140. private _scene;
  71141. private _vertexData;
  71142. private _buffer;
  71143. private _vertexBuffers;
  71144. private _indexBuffer;
  71145. private _effectBase;
  71146. private _effectFog;
  71147. /**
  71148. * Gets or sets the spritesheet texture
  71149. */
  71150. texture: Texture;
  71151. /**
  71152. * Creates a new sprite manager
  71153. * @param name defines the manager's name
  71154. * @param imgUrl defines the sprite sheet url
  71155. * @param capacity defines the maximum allowed number of sprites
  71156. * @param cellSize defines the size of a sprite cell
  71157. * @param scene defines the hosting scene
  71158. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71159. * @param samplingMode defines the smapling mode to use with spritesheet
  71160. */
  71161. constructor(
  71162. /** defines the manager's name */
  71163. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  71164. private _appendSpriteVertex;
  71165. /**
  71166. * Intersects the sprites with a ray
  71167. * @param ray defines the ray to intersect with
  71168. * @param camera defines the current active camera
  71169. * @param predicate defines a predicate used to select candidate sprites
  71170. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  71171. * @returns null if no hit or a PickingInfo
  71172. */
  71173. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71174. /**
  71175. * Render all child sprites
  71176. */
  71177. render(): void;
  71178. /**
  71179. * Release associated resources
  71180. */
  71181. dispose(): void;
  71182. }
  71183. }
  71184. declare module BABYLON {
  71185. /**
  71186. * Class used to represent a sprite
  71187. * @see http://doc.babylonjs.com/babylon101/sprites
  71188. */
  71189. export class Sprite {
  71190. /** defines the name */
  71191. name: string;
  71192. /** Gets or sets the current world position */
  71193. position: Vector3;
  71194. /** Gets or sets the main color */
  71195. color: Color4;
  71196. /** Gets or sets the width */
  71197. width: number;
  71198. /** Gets or sets the height */
  71199. height: number;
  71200. /** Gets or sets rotation angle */
  71201. angle: number;
  71202. /** Gets or sets the cell index in the sprite sheet */
  71203. cellIndex: number;
  71204. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  71205. invertU: number;
  71206. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  71207. invertV: number;
  71208. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  71209. disposeWhenFinishedAnimating: boolean;
  71210. /** Gets the list of attached animations */
  71211. animations: Animation[];
  71212. /** Gets or sets a boolean indicating if the sprite can be picked */
  71213. isPickable: boolean;
  71214. /**
  71215. * Gets or sets the associated action manager
  71216. */
  71217. actionManager: Nullable<ActionManager>;
  71218. private _animationStarted;
  71219. private _loopAnimation;
  71220. private _fromIndex;
  71221. private _toIndex;
  71222. private _delay;
  71223. private _direction;
  71224. private _manager;
  71225. private _time;
  71226. private _onAnimationEnd;
  71227. /**
  71228. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  71229. */
  71230. isVisible: boolean;
  71231. /**
  71232. * Gets or sets the sprite size
  71233. */
  71234. size: number;
  71235. /**
  71236. * Creates a new Sprite
  71237. * @param name defines the name
  71238. * @param manager defines the manager
  71239. */
  71240. constructor(
  71241. /** defines the name */
  71242. name: string, manager: ISpriteManager);
  71243. /**
  71244. * Starts an animation
  71245. * @param from defines the initial key
  71246. * @param to defines the end key
  71247. * @param loop defines if the animation must loop
  71248. * @param delay defines the start delay (in ms)
  71249. * @param onAnimationEnd defines a callback to call when animation ends
  71250. */
  71251. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  71252. /** Stops current animation (if any) */
  71253. stopAnimation(): void;
  71254. /** @hidden */
  71255. _animate(deltaTime: number): void;
  71256. /** Release associated resources */
  71257. dispose(): void;
  71258. }
  71259. }
  71260. declare module BABYLON {
  71261. /**
  71262. * Information about the result of picking within a scene
  71263. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  71264. */
  71265. export class PickingInfo {
  71266. /** @hidden */
  71267. _pickingUnavailable: boolean;
  71268. /**
  71269. * If the pick collided with an object
  71270. */
  71271. hit: boolean;
  71272. /**
  71273. * Distance away where the pick collided
  71274. */
  71275. distance: number;
  71276. /**
  71277. * The location of pick collision
  71278. */
  71279. pickedPoint: Nullable<Vector3>;
  71280. /**
  71281. * The mesh corresponding the the pick collision
  71282. */
  71283. pickedMesh: Nullable<AbstractMesh>;
  71284. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  71285. bu: number;
  71286. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  71287. bv: number;
  71288. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  71289. faceId: number;
  71290. /** Id of the the submesh that was picked */
  71291. subMeshId: number;
  71292. /** If a sprite was picked, this will be the sprite the pick collided with */
  71293. pickedSprite: Nullable<Sprite>;
  71294. /**
  71295. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  71296. */
  71297. originMesh: Nullable<AbstractMesh>;
  71298. /**
  71299. * The ray that was used to perform the picking.
  71300. */
  71301. ray: Nullable<Ray>;
  71302. /**
  71303. * Gets the normal correspodning to the face the pick collided with
  71304. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  71305. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  71306. * @returns The normal correspodning to the face the pick collided with
  71307. */
  71308. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  71309. /**
  71310. * Gets the texture coordinates of where the pick occured
  71311. * @returns the vector containing the coordnates of the texture
  71312. */
  71313. getTextureCoordinates(): Nullable<Vector2>;
  71314. }
  71315. }
  71316. declare module BABYLON {
  71317. /**
  71318. * Gather the list of pointer event types as constants.
  71319. */
  71320. export class PointerEventTypes {
  71321. /**
  71322. * 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.
  71323. */
  71324. static readonly POINTERDOWN: number;
  71325. /**
  71326. * The pointerup event is fired when a pointer is no longer active.
  71327. */
  71328. static readonly POINTERUP: number;
  71329. /**
  71330. * The pointermove event is fired when a pointer changes coordinates.
  71331. */
  71332. static readonly POINTERMOVE: number;
  71333. /**
  71334. * The pointerwheel event is fired when a mouse wheel has been rotated.
  71335. */
  71336. static readonly POINTERWHEEL: number;
  71337. /**
  71338. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  71339. */
  71340. static readonly POINTERPICK: number;
  71341. /**
  71342. * The pointertap event is fired when a the object has been touched and released without drag.
  71343. */
  71344. static readonly POINTERTAP: number;
  71345. /**
  71346. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  71347. */
  71348. static readonly POINTERDOUBLETAP: number;
  71349. }
  71350. /**
  71351. * Base class of pointer info types.
  71352. */
  71353. export class PointerInfoBase {
  71354. /**
  71355. * Defines the type of event (PointerEventTypes)
  71356. */
  71357. type: number;
  71358. /**
  71359. * Defines the related dom event
  71360. */
  71361. event: PointerEvent | MouseWheelEvent;
  71362. /**
  71363. * Instantiates the base class of pointers info.
  71364. * @param type Defines the type of event (PointerEventTypes)
  71365. * @param event Defines the related dom event
  71366. */
  71367. constructor(
  71368. /**
  71369. * Defines the type of event (PointerEventTypes)
  71370. */
  71371. type: number,
  71372. /**
  71373. * Defines the related dom event
  71374. */
  71375. event: PointerEvent | MouseWheelEvent);
  71376. }
  71377. /**
  71378. * This class is used to store pointer related info for the onPrePointerObservable event.
  71379. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  71380. */
  71381. export class PointerInfoPre extends PointerInfoBase {
  71382. /**
  71383. * Ray from a pointer if availible (eg. 6dof controller)
  71384. */
  71385. ray: Nullable<Ray>;
  71386. /**
  71387. * Defines the local position of the pointer on the canvas.
  71388. */
  71389. localPosition: Vector2;
  71390. /**
  71391. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  71392. */
  71393. skipOnPointerObservable: boolean;
  71394. /**
  71395. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  71396. * @param type Defines the type of event (PointerEventTypes)
  71397. * @param event Defines the related dom event
  71398. * @param localX Defines the local x coordinates of the pointer when the event occured
  71399. * @param localY Defines the local y coordinates of the pointer when the event occured
  71400. */
  71401. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  71402. }
  71403. /**
  71404. * This type contains all the data related to a pointer event in Babylon.js.
  71405. * 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.
  71406. */
  71407. export class PointerInfo extends PointerInfoBase {
  71408. /**
  71409. * Defines the picking info associated to the info (if any)\
  71410. */
  71411. pickInfo: Nullable<PickingInfo>;
  71412. /**
  71413. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  71414. * @param type Defines the type of event (PointerEventTypes)
  71415. * @param event Defines the related dom event
  71416. * @param pickInfo Defines the picking info associated to the info (if any)\
  71417. */
  71418. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  71419. /**
  71420. * Defines the picking info associated to the info (if any)\
  71421. */
  71422. pickInfo: Nullable<PickingInfo>);
  71423. }
  71424. /**
  71425. * Data relating to a touch event on the screen.
  71426. */
  71427. export interface PointerTouch {
  71428. /**
  71429. * X coordinate of touch.
  71430. */
  71431. x: number;
  71432. /**
  71433. * Y coordinate of touch.
  71434. */
  71435. y: number;
  71436. /**
  71437. * Id of touch. Unique for each finger.
  71438. */
  71439. pointerId: number;
  71440. /**
  71441. * Event type passed from DOM.
  71442. */
  71443. type: any;
  71444. }
  71445. }
  71446. declare module BABYLON {
  71447. /**
  71448. * Manage the mouse inputs to control the movement of a free camera.
  71449. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71450. */
  71451. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  71452. /**
  71453. * Define if touch is enabled in the mouse input
  71454. */
  71455. touchEnabled: boolean;
  71456. /**
  71457. * Defines the camera the input is attached to.
  71458. */
  71459. camera: FreeCamera;
  71460. /**
  71461. * Defines the buttons associated with the input to handle camera move.
  71462. */
  71463. buttons: number[];
  71464. /**
  71465. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  71466. */
  71467. angularSensibility: number;
  71468. private _pointerInput;
  71469. private _onMouseMove;
  71470. private _observer;
  71471. private previousPosition;
  71472. /**
  71473. * Observable for when a pointer move event occurs containing the move offset
  71474. */
  71475. onPointerMovedObservable: Observable<{
  71476. offsetX: number;
  71477. offsetY: number;
  71478. }>;
  71479. /**
  71480. * @hidden
  71481. * If the camera should be rotated automatically based on pointer movement
  71482. */
  71483. _allowCameraRotation: boolean;
  71484. /**
  71485. * Manage the mouse inputs to control the movement of a free camera.
  71486. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71487. * @param touchEnabled Defines if touch is enabled or not
  71488. */
  71489. constructor(
  71490. /**
  71491. * Define if touch is enabled in the mouse input
  71492. */
  71493. touchEnabled?: boolean);
  71494. /**
  71495. * Attach the input controls to a specific dom element to get the input from.
  71496. * @param element Defines the element the controls should be listened from
  71497. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71498. */
  71499. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71500. /**
  71501. * Called on JS contextmenu event.
  71502. * Override this method to provide functionality.
  71503. */
  71504. protected onContextMenu(evt: PointerEvent): void;
  71505. /**
  71506. * Detach the current controls from the specified dom element.
  71507. * @param element Defines the element to stop listening the inputs from
  71508. */
  71509. detachControl(element: Nullable<HTMLElement>): void;
  71510. /**
  71511. * Gets the class name of the current intput.
  71512. * @returns the class name
  71513. */
  71514. getClassName(): string;
  71515. /**
  71516. * Get the friendly name associated with the input class.
  71517. * @returns the input friendly name
  71518. */
  71519. getSimpleName(): string;
  71520. }
  71521. }
  71522. declare module BABYLON {
  71523. /**
  71524. * Manage the touch inputs to control the movement of a free camera.
  71525. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71526. */
  71527. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  71528. /**
  71529. * Defines the camera the input is attached to.
  71530. */
  71531. camera: FreeCamera;
  71532. /**
  71533. * Defines the touch sensibility for rotation.
  71534. * The higher the faster.
  71535. */
  71536. touchAngularSensibility: number;
  71537. /**
  71538. * Defines the touch sensibility for move.
  71539. * The higher the faster.
  71540. */
  71541. touchMoveSensibility: number;
  71542. private _offsetX;
  71543. private _offsetY;
  71544. private _pointerPressed;
  71545. private _pointerInput;
  71546. private _observer;
  71547. private _onLostFocus;
  71548. /**
  71549. * Attach the input controls to a specific dom element to get the input from.
  71550. * @param element Defines the element the controls should be listened from
  71551. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71552. */
  71553. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71554. /**
  71555. * Detach the current controls from the specified dom element.
  71556. * @param element Defines the element to stop listening the inputs from
  71557. */
  71558. detachControl(element: Nullable<HTMLElement>): void;
  71559. /**
  71560. * Update the current camera state depending on the inputs that have been used this frame.
  71561. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71562. */
  71563. checkInputs(): void;
  71564. /**
  71565. * Gets the class name of the current intput.
  71566. * @returns the class name
  71567. */
  71568. getClassName(): string;
  71569. /**
  71570. * Get the friendly name associated with the input class.
  71571. * @returns the input friendly name
  71572. */
  71573. getSimpleName(): string;
  71574. }
  71575. }
  71576. declare module BABYLON {
  71577. /**
  71578. * Default Inputs manager for the FreeCamera.
  71579. * It groups all the default supported inputs for ease of use.
  71580. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71581. */
  71582. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  71583. /**
  71584. * @hidden
  71585. */
  71586. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  71587. /**
  71588. * @hidden
  71589. */
  71590. _mouseInput: Nullable<FreeCameraMouseInput>;
  71591. /**
  71592. * Instantiates a new FreeCameraInputsManager.
  71593. * @param camera Defines the camera the inputs belong to
  71594. */
  71595. constructor(camera: FreeCamera);
  71596. /**
  71597. * Add keyboard input support to the input manager.
  71598. * @returns the current input manager
  71599. */
  71600. addKeyboard(): FreeCameraInputsManager;
  71601. /**
  71602. * Add mouse input support to the input manager.
  71603. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  71604. * @returns the current input manager
  71605. */
  71606. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  71607. /**
  71608. * Removes the mouse input support from the manager
  71609. * @returns the current input manager
  71610. */
  71611. removeMouse(): FreeCameraInputsManager;
  71612. /**
  71613. * Add touch input support to the input manager.
  71614. * @returns the current input manager
  71615. */
  71616. addTouch(): FreeCameraInputsManager;
  71617. }
  71618. }
  71619. declare module BABYLON {
  71620. /**
  71621. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  71622. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  71623. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  71624. */
  71625. export class FreeCamera extends TargetCamera {
  71626. /**
  71627. * Define the collision ellipsoid of the camera.
  71628. * This is helpful to simulate a camera body like the player body around the camera
  71629. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  71630. */
  71631. ellipsoid: Vector3;
  71632. /**
  71633. * Define an offset for the position of the ellipsoid around the camera.
  71634. * This can be helpful to determine the center of the body near the gravity center of the body
  71635. * instead of its head.
  71636. */
  71637. ellipsoidOffset: Vector3;
  71638. /**
  71639. * Enable or disable collisions of the camera with the rest of the scene objects.
  71640. */
  71641. checkCollisions: boolean;
  71642. /**
  71643. * Enable or disable gravity on the camera.
  71644. */
  71645. applyGravity: boolean;
  71646. /**
  71647. * Define the input manager associated to the camera.
  71648. */
  71649. inputs: FreeCameraInputsManager;
  71650. /**
  71651. * Gets the input sensibility for a mouse input. (default is 2000.0)
  71652. * Higher values reduce sensitivity.
  71653. */
  71654. /**
  71655. * Sets the input sensibility for a mouse input. (default is 2000.0)
  71656. * Higher values reduce sensitivity.
  71657. */
  71658. angularSensibility: number;
  71659. /**
  71660. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  71661. */
  71662. keysUp: number[];
  71663. /**
  71664. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  71665. */
  71666. keysDown: number[];
  71667. /**
  71668. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  71669. */
  71670. keysLeft: number[];
  71671. /**
  71672. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  71673. */
  71674. keysRight: number[];
  71675. /**
  71676. * Event raised when the camera collide with a mesh in the scene.
  71677. */
  71678. onCollide: (collidedMesh: AbstractMesh) => void;
  71679. private _collider;
  71680. private _needMoveForGravity;
  71681. private _oldPosition;
  71682. private _diffPosition;
  71683. private _newPosition;
  71684. /** @hidden */
  71685. _localDirection: Vector3;
  71686. /** @hidden */
  71687. _transformedDirection: Vector3;
  71688. /**
  71689. * Instantiates a Free Camera.
  71690. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  71691. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  71692. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  71693. * @param name Define the name of the camera in the scene
  71694. * @param position Define the start position of the camera in the scene
  71695. * @param scene Define the scene the camera belongs to
  71696. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  71697. */
  71698. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  71699. /**
  71700. * Attached controls to the current camera.
  71701. * @param element Defines the element the controls should be listened from
  71702. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71703. */
  71704. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71705. /**
  71706. * Detach the current controls from the camera.
  71707. * The camera will stop reacting to inputs.
  71708. * @param element Defines the element to stop listening the inputs from
  71709. */
  71710. detachControl(element: HTMLElement): void;
  71711. private _collisionMask;
  71712. /**
  71713. * Define a collision mask to limit the list of object the camera can collide with
  71714. */
  71715. collisionMask: number;
  71716. /** @hidden */
  71717. _collideWithWorld(displacement: Vector3): void;
  71718. private _onCollisionPositionChange;
  71719. /** @hidden */
  71720. _checkInputs(): void;
  71721. /** @hidden */
  71722. _decideIfNeedsToMove(): boolean;
  71723. /** @hidden */
  71724. _updatePosition(): void;
  71725. /**
  71726. * Destroy the camera and release the current resources hold by it.
  71727. */
  71728. dispose(): void;
  71729. /**
  71730. * Gets the current object class name.
  71731. * @return the class name
  71732. */
  71733. getClassName(): string;
  71734. }
  71735. }
  71736. declare module BABYLON {
  71737. /**
  71738. * Represents a gamepad control stick position
  71739. */
  71740. export class StickValues {
  71741. /**
  71742. * The x component of the control stick
  71743. */
  71744. x: number;
  71745. /**
  71746. * The y component of the control stick
  71747. */
  71748. y: number;
  71749. /**
  71750. * Initializes the gamepad x and y control stick values
  71751. * @param x The x component of the gamepad control stick value
  71752. * @param y The y component of the gamepad control stick value
  71753. */
  71754. constructor(
  71755. /**
  71756. * The x component of the control stick
  71757. */
  71758. x: number,
  71759. /**
  71760. * The y component of the control stick
  71761. */
  71762. y: number);
  71763. }
  71764. /**
  71765. * An interface which manages callbacks for gamepad button changes
  71766. */
  71767. export interface GamepadButtonChanges {
  71768. /**
  71769. * Called when a gamepad has been changed
  71770. */
  71771. changed: boolean;
  71772. /**
  71773. * Called when a gamepad press event has been triggered
  71774. */
  71775. pressChanged: boolean;
  71776. /**
  71777. * Called when a touch event has been triggered
  71778. */
  71779. touchChanged: boolean;
  71780. /**
  71781. * Called when a value has changed
  71782. */
  71783. valueChanged: boolean;
  71784. }
  71785. /**
  71786. * Represents a gamepad
  71787. */
  71788. export class Gamepad {
  71789. /**
  71790. * The id of the gamepad
  71791. */
  71792. id: string;
  71793. /**
  71794. * The index of the gamepad
  71795. */
  71796. index: number;
  71797. /**
  71798. * The browser gamepad
  71799. */
  71800. browserGamepad: any;
  71801. /**
  71802. * Specifies what type of gamepad this represents
  71803. */
  71804. type: number;
  71805. private _leftStick;
  71806. private _rightStick;
  71807. /** @hidden */
  71808. _isConnected: boolean;
  71809. private _leftStickAxisX;
  71810. private _leftStickAxisY;
  71811. private _rightStickAxisX;
  71812. private _rightStickAxisY;
  71813. /**
  71814. * Triggered when the left control stick has been changed
  71815. */
  71816. private _onleftstickchanged;
  71817. /**
  71818. * Triggered when the right control stick has been changed
  71819. */
  71820. private _onrightstickchanged;
  71821. /**
  71822. * Represents a gamepad controller
  71823. */
  71824. static GAMEPAD: number;
  71825. /**
  71826. * Represents a generic controller
  71827. */
  71828. static GENERIC: number;
  71829. /**
  71830. * Represents an XBox controller
  71831. */
  71832. static XBOX: number;
  71833. /**
  71834. * Represents a pose-enabled controller
  71835. */
  71836. static POSE_ENABLED: number;
  71837. /**
  71838. * Specifies whether the left control stick should be Y-inverted
  71839. */
  71840. protected _invertLeftStickY: boolean;
  71841. /**
  71842. * Specifies if the gamepad has been connected
  71843. */
  71844. readonly isConnected: boolean;
  71845. /**
  71846. * Initializes the gamepad
  71847. * @param id The id of the gamepad
  71848. * @param index The index of the gamepad
  71849. * @param browserGamepad The browser gamepad
  71850. * @param leftStickX The x component of the left joystick
  71851. * @param leftStickY The y component of the left joystick
  71852. * @param rightStickX The x component of the right joystick
  71853. * @param rightStickY The y component of the right joystick
  71854. */
  71855. constructor(
  71856. /**
  71857. * The id of the gamepad
  71858. */
  71859. id: string,
  71860. /**
  71861. * The index of the gamepad
  71862. */
  71863. index: number,
  71864. /**
  71865. * The browser gamepad
  71866. */
  71867. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  71868. /**
  71869. * Callback triggered when the left joystick has changed
  71870. * @param callback
  71871. */
  71872. onleftstickchanged(callback: (values: StickValues) => void): void;
  71873. /**
  71874. * Callback triggered when the right joystick has changed
  71875. * @param callback
  71876. */
  71877. onrightstickchanged(callback: (values: StickValues) => void): void;
  71878. /**
  71879. * Gets the left joystick
  71880. */
  71881. /**
  71882. * Sets the left joystick values
  71883. */
  71884. leftStick: StickValues;
  71885. /**
  71886. * Gets the right joystick
  71887. */
  71888. /**
  71889. * Sets the right joystick value
  71890. */
  71891. rightStick: StickValues;
  71892. /**
  71893. * Updates the gamepad joystick positions
  71894. */
  71895. update(): void;
  71896. /**
  71897. * Disposes the gamepad
  71898. */
  71899. dispose(): void;
  71900. }
  71901. /**
  71902. * Represents a generic gamepad
  71903. */
  71904. export class GenericPad extends Gamepad {
  71905. private _buttons;
  71906. private _onbuttondown;
  71907. private _onbuttonup;
  71908. /**
  71909. * Observable triggered when a button has been pressed
  71910. */
  71911. onButtonDownObservable: Observable<number>;
  71912. /**
  71913. * Observable triggered when a button has been released
  71914. */
  71915. onButtonUpObservable: Observable<number>;
  71916. /**
  71917. * Callback triggered when a button has been pressed
  71918. * @param callback Called when a button has been pressed
  71919. */
  71920. onbuttondown(callback: (buttonPressed: number) => void): void;
  71921. /**
  71922. * Callback triggered when a button has been released
  71923. * @param callback Called when a button has been released
  71924. */
  71925. onbuttonup(callback: (buttonReleased: number) => void): void;
  71926. /**
  71927. * Initializes the generic gamepad
  71928. * @param id The id of the generic gamepad
  71929. * @param index The index of the generic gamepad
  71930. * @param browserGamepad The browser gamepad
  71931. */
  71932. constructor(id: string, index: number, browserGamepad: any);
  71933. private _setButtonValue;
  71934. /**
  71935. * Updates the generic gamepad
  71936. */
  71937. update(): void;
  71938. /**
  71939. * Disposes the generic gamepad
  71940. */
  71941. dispose(): void;
  71942. }
  71943. }
  71944. declare module BABYLON {
  71945. /**
  71946. * Defines the types of pose enabled controllers that are supported
  71947. */
  71948. export enum PoseEnabledControllerType {
  71949. /**
  71950. * HTC Vive
  71951. */
  71952. VIVE = 0,
  71953. /**
  71954. * Oculus Rift
  71955. */
  71956. OCULUS = 1,
  71957. /**
  71958. * Windows mixed reality
  71959. */
  71960. WINDOWS = 2,
  71961. /**
  71962. * Samsung gear VR
  71963. */
  71964. GEAR_VR = 3,
  71965. /**
  71966. * Google Daydream
  71967. */
  71968. DAYDREAM = 4,
  71969. /**
  71970. * Generic
  71971. */
  71972. GENERIC = 5
  71973. }
  71974. /**
  71975. * Defines the MutableGamepadButton interface for the state of a gamepad button
  71976. */
  71977. export interface MutableGamepadButton {
  71978. /**
  71979. * Value of the button/trigger
  71980. */
  71981. value: number;
  71982. /**
  71983. * If the button/trigger is currently touched
  71984. */
  71985. touched: boolean;
  71986. /**
  71987. * If the button/trigger is currently pressed
  71988. */
  71989. pressed: boolean;
  71990. }
  71991. /**
  71992. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  71993. * @hidden
  71994. */
  71995. export interface ExtendedGamepadButton extends GamepadButton {
  71996. /**
  71997. * If the button/trigger is currently pressed
  71998. */
  71999. readonly pressed: boolean;
  72000. /**
  72001. * If the button/trigger is currently touched
  72002. */
  72003. readonly touched: boolean;
  72004. /**
  72005. * Value of the button/trigger
  72006. */
  72007. readonly value: number;
  72008. }
  72009. /** @hidden */
  72010. export interface _GamePadFactory {
  72011. /**
  72012. * Returns wether or not the current gamepad can be created for this type of controller.
  72013. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72014. * @returns true if it can be created, otherwise false
  72015. */
  72016. canCreate(gamepadInfo: any): boolean;
  72017. /**
  72018. * Creates a new instance of the Gamepad.
  72019. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72020. * @returns the new gamepad instance
  72021. */
  72022. create(gamepadInfo: any): Gamepad;
  72023. }
  72024. /**
  72025. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72026. */
  72027. export class PoseEnabledControllerHelper {
  72028. /** @hidden */
  72029. static _ControllerFactories: _GamePadFactory[];
  72030. /** @hidden */
  72031. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  72032. /**
  72033. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72034. * @param vrGamepad the gamepad to initialized
  72035. * @returns a vr controller of the type the gamepad identified as
  72036. */
  72037. static InitiateController(vrGamepad: any): Gamepad;
  72038. }
  72039. /**
  72040. * Defines the PoseEnabledController object that contains state of a vr capable controller
  72041. */
  72042. export class PoseEnabledController extends Gamepad implements PoseControlled {
  72043. private _deviceRoomPosition;
  72044. private _deviceRoomRotationQuaternion;
  72045. /**
  72046. * The device position in babylon space
  72047. */
  72048. devicePosition: Vector3;
  72049. /**
  72050. * The device rotation in babylon space
  72051. */
  72052. deviceRotationQuaternion: Quaternion;
  72053. /**
  72054. * The scale factor of the device in babylon space
  72055. */
  72056. deviceScaleFactor: number;
  72057. /**
  72058. * (Likely devicePosition should be used instead) The device position in its room space
  72059. */
  72060. position: Vector3;
  72061. /**
  72062. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  72063. */
  72064. rotationQuaternion: Quaternion;
  72065. /**
  72066. * The type of controller (Eg. Windows mixed reality)
  72067. */
  72068. controllerType: PoseEnabledControllerType;
  72069. protected _calculatedPosition: Vector3;
  72070. private _calculatedRotation;
  72071. /**
  72072. * The raw pose from the device
  72073. */
  72074. rawPose: DevicePose;
  72075. private _trackPosition;
  72076. private _maxRotationDistFromHeadset;
  72077. private _draggedRoomRotation;
  72078. /**
  72079. * @hidden
  72080. */
  72081. _disableTrackPosition(fixedPosition: Vector3): void;
  72082. /**
  72083. * Internal, the mesh attached to the controller
  72084. * @hidden
  72085. */
  72086. _mesh: Nullable<AbstractMesh>;
  72087. private _poseControlledCamera;
  72088. private _leftHandSystemQuaternion;
  72089. /**
  72090. * Internal, matrix used to convert room space to babylon space
  72091. * @hidden
  72092. */
  72093. _deviceToWorld: Matrix;
  72094. /**
  72095. * Node to be used when casting a ray from the controller
  72096. * @hidden
  72097. */
  72098. _pointingPoseNode: Nullable<TransformNode>;
  72099. /**
  72100. * Name of the child mesh that can be used to cast a ray from the controller
  72101. */
  72102. static readonly POINTING_POSE: string;
  72103. /**
  72104. * Creates a new PoseEnabledController from a gamepad
  72105. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  72106. */
  72107. constructor(browserGamepad: any);
  72108. private _workingMatrix;
  72109. /**
  72110. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  72111. */
  72112. update(): void;
  72113. /**
  72114. * Updates only the pose device and mesh without doing any button event checking
  72115. */
  72116. protected _updatePoseAndMesh(): void;
  72117. /**
  72118. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  72119. * @param poseData raw pose fromthe device
  72120. */
  72121. updateFromDevice(poseData: DevicePose): void;
  72122. /**
  72123. * @hidden
  72124. */
  72125. _meshAttachedObservable: Observable<AbstractMesh>;
  72126. /**
  72127. * Attaches a mesh to the controller
  72128. * @param mesh the mesh to be attached
  72129. */
  72130. attachToMesh(mesh: AbstractMesh): void;
  72131. /**
  72132. * Attaches the controllers mesh to a camera
  72133. * @param camera the camera the mesh should be attached to
  72134. */
  72135. attachToPoseControlledCamera(camera: TargetCamera): void;
  72136. /**
  72137. * Disposes of the controller
  72138. */
  72139. dispose(): void;
  72140. /**
  72141. * The mesh that is attached to the controller
  72142. */
  72143. readonly mesh: Nullable<AbstractMesh>;
  72144. /**
  72145. * Gets the ray of the controller in the direction the controller is pointing
  72146. * @param length the length the resulting ray should be
  72147. * @returns a ray in the direction the controller is pointing
  72148. */
  72149. getForwardRay(length?: number): Ray;
  72150. }
  72151. }
  72152. declare module BABYLON {
  72153. /**
  72154. * Defines the WebVRController object that represents controllers tracked in 3D space
  72155. */
  72156. export abstract class WebVRController extends PoseEnabledController {
  72157. /**
  72158. * Internal, the default controller model for the controller
  72159. */
  72160. protected _defaultModel: AbstractMesh;
  72161. /**
  72162. * Fired when the trigger state has changed
  72163. */
  72164. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  72165. /**
  72166. * Fired when the main button state has changed
  72167. */
  72168. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72169. /**
  72170. * Fired when the secondary button state has changed
  72171. */
  72172. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72173. /**
  72174. * Fired when the pad state has changed
  72175. */
  72176. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  72177. /**
  72178. * Fired when controllers stick values have changed
  72179. */
  72180. onPadValuesChangedObservable: Observable<StickValues>;
  72181. /**
  72182. * Array of button availible on the controller
  72183. */
  72184. protected _buttons: Array<MutableGamepadButton>;
  72185. private _onButtonStateChange;
  72186. /**
  72187. * Fired when a controller button's state has changed
  72188. * @param callback the callback containing the button that was modified
  72189. */
  72190. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  72191. /**
  72192. * X and Y axis corrisponding to the controllers joystick
  72193. */
  72194. pad: StickValues;
  72195. /**
  72196. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  72197. */
  72198. hand: string;
  72199. /**
  72200. * The default controller model for the controller
  72201. */
  72202. readonly defaultModel: AbstractMesh;
  72203. /**
  72204. * Creates a new WebVRController from a gamepad
  72205. * @param vrGamepad the gamepad that the WebVRController should be created from
  72206. */
  72207. constructor(vrGamepad: any);
  72208. /**
  72209. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  72210. */
  72211. update(): void;
  72212. /**
  72213. * Function to be called when a button is modified
  72214. */
  72215. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  72216. /**
  72217. * Loads a mesh and attaches it to the controller
  72218. * @param scene the scene the mesh should be added to
  72219. * @param meshLoaded callback for when the mesh has been loaded
  72220. */
  72221. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  72222. private _setButtonValue;
  72223. private _changes;
  72224. private _checkChanges;
  72225. /**
  72226. * Disposes of th webVRCOntroller
  72227. */
  72228. dispose(): void;
  72229. }
  72230. }
  72231. declare module BABYLON {
  72232. /**
  72233. * The HemisphericLight simulates the ambient environment light,
  72234. * so the passed direction is the light reflection direction, not the incoming direction.
  72235. */
  72236. export class HemisphericLight extends Light {
  72237. /**
  72238. * The groundColor is the light in the opposite direction to the one specified during creation.
  72239. * 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.
  72240. */
  72241. groundColor: Color3;
  72242. /**
  72243. * The light reflection direction, not the incoming direction.
  72244. */
  72245. direction: Vector3;
  72246. /**
  72247. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  72248. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  72249. * The HemisphericLight can't cast shadows.
  72250. * Documentation : https://doc.babylonjs.com/babylon101/lights
  72251. * @param name The friendly name of the light
  72252. * @param direction The direction of the light reflection
  72253. * @param scene The scene the light belongs to
  72254. */
  72255. constructor(name: string, direction: Vector3, scene: Scene);
  72256. protected _buildUniformLayout(): void;
  72257. /**
  72258. * Returns the string "HemisphericLight".
  72259. * @return The class name
  72260. */
  72261. getClassName(): string;
  72262. /**
  72263. * Sets the HemisphericLight direction towards the passed target (Vector3).
  72264. * Returns the updated direction.
  72265. * @param target The target the direction should point to
  72266. * @return The computed direction
  72267. */
  72268. setDirectionToTarget(target: Vector3): Vector3;
  72269. /**
  72270. * Returns the shadow generator associated to the light.
  72271. * @returns Always null for hemispheric lights because it does not support shadows.
  72272. */
  72273. getShadowGenerator(): Nullable<IShadowGenerator>;
  72274. /**
  72275. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  72276. * @param effect The effect to update
  72277. * @param lightIndex The index of the light in the effect to update
  72278. * @returns The hemispheric light
  72279. */
  72280. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  72281. /**
  72282. * Computes the world matrix of the node
  72283. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  72284. * @param useWasUpdatedFlag defines a reserved property
  72285. * @returns the world matrix
  72286. */
  72287. computeWorldMatrix(): Matrix;
  72288. /**
  72289. * Returns the integer 3.
  72290. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  72291. */
  72292. getTypeID(): number;
  72293. /**
  72294. * Prepares the list of defines specific to the light type.
  72295. * @param defines the list of defines
  72296. * @param lightIndex defines the index of the light for the effect
  72297. */
  72298. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  72299. }
  72300. }
  72301. declare module BABYLON {
  72302. /** @hidden */
  72303. export var vrMultiviewToSingleviewPixelShader: {
  72304. name: string;
  72305. shader: string;
  72306. };
  72307. }
  72308. declare module BABYLON {
  72309. /**
  72310. * Renders to multiple views with a single draw call
  72311. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  72312. */
  72313. export class MultiviewRenderTarget extends RenderTargetTexture {
  72314. /**
  72315. * Creates a multiview render target
  72316. * @param scene scene used with the render target
  72317. * @param size the size of the render target (used for each view)
  72318. */
  72319. constructor(scene: Scene, size?: number | {
  72320. width: number;
  72321. height: number;
  72322. } | {
  72323. ratio: number;
  72324. });
  72325. /**
  72326. * @hidden
  72327. * @param faceIndex the face index, if its a cube texture
  72328. */
  72329. _bindFrameBuffer(faceIndex?: number): void;
  72330. /**
  72331. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  72332. * @returns the view count
  72333. */
  72334. getViewCount(): number;
  72335. }
  72336. }
  72337. declare module BABYLON {
  72338. interface Engine {
  72339. /**
  72340. * Creates a new multiview render target
  72341. * @param width defines the width of the texture
  72342. * @param height defines the height of the texture
  72343. * @returns the created multiview texture
  72344. */
  72345. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  72346. /**
  72347. * Binds a multiview framebuffer to be drawn to
  72348. * @param multiviewTexture texture to bind
  72349. */
  72350. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  72351. }
  72352. interface Camera {
  72353. /**
  72354. * @hidden
  72355. * 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)
  72356. */
  72357. _useMultiviewToSingleView: boolean;
  72358. /**
  72359. * @hidden
  72360. * 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)
  72361. */
  72362. _multiviewTexture: Nullable<RenderTargetTexture>;
  72363. /**
  72364. * @hidden
  72365. * ensures the multiview texture of the camera exists and has the specified width/height
  72366. * @param width height to set on the multiview texture
  72367. * @param height width to set on the multiview texture
  72368. */
  72369. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  72370. }
  72371. interface Scene {
  72372. /** @hidden */
  72373. _transformMatrixR: Matrix;
  72374. /** @hidden */
  72375. _multiviewSceneUbo: Nullable<UniformBuffer>;
  72376. /** @hidden */
  72377. _createMultiviewUbo(): void;
  72378. /** @hidden */
  72379. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  72380. /** @hidden */
  72381. _renderMultiviewToSingleView(camera: Camera): void;
  72382. }
  72383. }
  72384. declare module BABYLON {
  72385. /**
  72386. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  72387. * This will not be used for webXR as it supports displaying texture arrays directly
  72388. */
  72389. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  72390. /**
  72391. * Initializes a VRMultiviewToSingleview
  72392. * @param name name of the post process
  72393. * @param camera camera to be applied to
  72394. * @param scaleFactor scaling factor to the size of the output texture
  72395. */
  72396. constructor(name: string, camera: Camera, scaleFactor: number);
  72397. }
  72398. }
  72399. declare module BABYLON {
  72400. /**
  72401. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  72402. * IMPORTANT!! The data is right-hand data.
  72403. * @export
  72404. * @interface DevicePose
  72405. */
  72406. export interface DevicePose {
  72407. /**
  72408. * The position of the device, values in array are [x,y,z].
  72409. */
  72410. readonly position: Nullable<Float32Array>;
  72411. /**
  72412. * The linearVelocity of the device, values in array are [x,y,z].
  72413. */
  72414. readonly linearVelocity: Nullable<Float32Array>;
  72415. /**
  72416. * The linearAcceleration of the device, values in array are [x,y,z].
  72417. */
  72418. readonly linearAcceleration: Nullable<Float32Array>;
  72419. /**
  72420. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  72421. */
  72422. readonly orientation: Nullable<Float32Array>;
  72423. /**
  72424. * The angularVelocity of the device, values in array are [x,y,z].
  72425. */
  72426. readonly angularVelocity: Nullable<Float32Array>;
  72427. /**
  72428. * The angularAcceleration of the device, values in array are [x,y,z].
  72429. */
  72430. readonly angularAcceleration: Nullable<Float32Array>;
  72431. }
  72432. /**
  72433. * Interface representing a pose controlled object in Babylon.
  72434. * A pose controlled object has both regular pose values as well as pose values
  72435. * from an external device such as a VR head mounted display
  72436. */
  72437. export interface PoseControlled {
  72438. /**
  72439. * The position of the object in babylon space.
  72440. */
  72441. position: Vector3;
  72442. /**
  72443. * The rotation quaternion of the object in babylon space.
  72444. */
  72445. rotationQuaternion: Quaternion;
  72446. /**
  72447. * The position of the device in babylon space.
  72448. */
  72449. devicePosition?: Vector3;
  72450. /**
  72451. * The rotation quaternion of the device in babylon space.
  72452. */
  72453. deviceRotationQuaternion: Quaternion;
  72454. /**
  72455. * The raw pose coming from the device.
  72456. */
  72457. rawPose: Nullable<DevicePose>;
  72458. /**
  72459. * The scale of the device to be used when translating from device space to babylon space.
  72460. */
  72461. deviceScaleFactor: number;
  72462. /**
  72463. * Updates the poseControlled values based on the input device pose.
  72464. * @param poseData the pose data to update the object with
  72465. */
  72466. updateFromDevice(poseData: DevicePose): void;
  72467. }
  72468. /**
  72469. * Set of options to customize the webVRCamera
  72470. */
  72471. export interface WebVROptions {
  72472. /**
  72473. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  72474. */
  72475. trackPosition?: boolean;
  72476. /**
  72477. * Sets the scale of the vrDevice in babylon space. (default: 1)
  72478. */
  72479. positionScale?: number;
  72480. /**
  72481. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  72482. */
  72483. displayName?: string;
  72484. /**
  72485. * Should the native controller meshes be initialized. (default: true)
  72486. */
  72487. controllerMeshes?: boolean;
  72488. /**
  72489. * Creating a default HemiLight only on controllers. (default: true)
  72490. */
  72491. defaultLightingOnControllers?: boolean;
  72492. /**
  72493. * If you don't want to use the default VR button of the helper. (default: false)
  72494. */
  72495. useCustomVRButton?: boolean;
  72496. /**
  72497. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  72498. */
  72499. customVRButton?: HTMLButtonElement;
  72500. /**
  72501. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  72502. */
  72503. rayLength?: number;
  72504. /**
  72505. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  72506. */
  72507. defaultHeight?: number;
  72508. /**
  72509. * If multiview should be used if availible (default: false)
  72510. */
  72511. useMultiview?: boolean;
  72512. }
  72513. /**
  72514. * This represents a WebVR camera.
  72515. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  72516. * @example http://doc.babylonjs.com/how_to/webvr_camera
  72517. */
  72518. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  72519. private webVROptions;
  72520. /**
  72521. * @hidden
  72522. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  72523. */
  72524. _vrDevice: any;
  72525. /**
  72526. * The rawPose of the vrDevice.
  72527. */
  72528. rawPose: Nullable<DevicePose>;
  72529. private _onVREnabled;
  72530. private _specsVersion;
  72531. private _attached;
  72532. private _frameData;
  72533. protected _descendants: Array<Node>;
  72534. private _deviceRoomPosition;
  72535. /** @hidden */
  72536. _deviceRoomRotationQuaternion: Quaternion;
  72537. private _standingMatrix;
  72538. /**
  72539. * Represents device position in babylon space.
  72540. */
  72541. devicePosition: Vector3;
  72542. /**
  72543. * Represents device rotation in babylon space.
  72544. */
  72545. deviceRotationQuaternion: Quaternion;
  72546. /**
  72547. * The scale of the device to be used when translating from device space to babylon space.
  72548. */
  72549. deviceScaleFactor: number;
  72550. private _deviceToWorld;
  72551. private _worldToDevice;
  72552. /**
  72553. * References to the webVR controllers for the vrDevice.
  72554. */
  72555. controllers: Array<WebVRController>;
  72556. /**
  72557. * Emits an event when a controller is attached.
  72558. */
  72559. onControllersAttachedObservable: Observable<WebVRController[]>;
  72560. /**
  72561. * Emits an event when a controller's mesh has been loaded;
  72562. */
  72563. onControllerMeshLoadedObservable: Observable<WebVRController>;
  72564. /**
  72565. * Emits an event when the HMD's pose has been updated.
  72566. */
  72567. onPoseUpdatedFromDeviceObservable: Observable<any>;
  72568. private _poseSet;
  72569. /**
  72570. * If the rig cameras be used as parent instead of this camera.
  72571. */
  72572. rigParenting: boolean;
  72573. private _lightOnControllers;
  72574. private _defaultHeight?;
  72575. /**
  72576. * Instantiates a WebVRFreeCamera.
  72577. * @param name The name of the WebVRFreeCamera
  72578. * @param position The starting anchor position for the camera
  72579. * @param scene The scene the camera belongs to
  72580. * @param webVROptions a set of customizable options for the webVRCamera
  72581. */
  72582. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  72583. /**
  72584. * Gets the device distance from the ground in meters.
  72585. * @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.
  72586. */
  72587. deviceDistanceToRoomGround(): number;
  72588. /**
  72589. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  72590. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  72591. */
  72592. useStandingMatrix(callback?: (bool: boolean) => void): void;
  72593. /**
  72594. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  72595. * @returns A promise with a boolean set to if the standing matrix is supported.
  72596. */
  72597. useStandingMatrixAsync(): Promise<boolean>;
  72598. /**
  72599. * Disposes the camera
  72600. */
  72601. dispose(): void;
  72602. /**
  72603. * Gets a vrController by name.
  72604. * @param name The name of the controller to retreive
  72605. * @returns the controller matching the name specified or null if not found
  72606. */
  72607. getControllerByName(name: string): Nullable<WebVRController>;
  72608. private _leftController;
  72609. /**
  72610. * The controller corrisponding to the users left hand.
  72611. */
  72612. readonly leftController: Nullable<WebVRController>;
  72613. private _rightController;
  72614. /**
  72615. * The controller corrisponding to the users right hand.
  72616. */
  72617. readonly rightController: Nullable<WebVRController>;
  72618. /**
  72619. * Casts a ray forward from the vrCamera's gaze.
  72620. * @param length Length of the ray (default: 100)
  72621. * @returns the ray corrisponding to the gaze
  72622. */
  72623. getForwardRay(length?: number): Ray;
  72624. /**
  72625. * @hidden
  72626. * Updates the camera based on device's frame data
  72627. */
  72628. _checkInputs(): void;
  72629. /**
  72630. * Updates the poseControlled values based on the input device pose.
  72631. * @param poseData Pose coming from the device
  72632. */
  72633. updateFromDevice(poseData: DevicePose): void;
  72634. private _htmlElementAttached;
  72635. private _detachIfAttached;
  72636. /**
  72637. * WebVR's attach control will start broadcasting frames to the device.
  72638. * Note that in certain browsers (chrome for example) this function must be called
  72639. * within a user-interaction callback. Example:
  72640. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  72641. *
  72642. * @param element html element to attach the vrDevice to
  72643. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  72644. */
  72645. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72646. /**
  72647. * Detaches the camera from the html element and disables VR
  72648. *
  72649. * @param element html element to detach from
  72650. */
  72651. detachControl(element: HTMLElement): void;
  72652. /**
  72653. * @returns the name of this class
  72654. */
  72655. getClassName(): string;
  72656. /**
  72657. * Calls resetPose on the vrDisplay
  72658. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  72659. */
  72660. resetToCurrentRotation(): void;
  72661. /**
  72662. * @hidden
  72663. * Updates the rig cameras (left and right eye)
  72664. */
  72665. _updateRigCameras(): void;
  72666. private _workingVector;
  72667. private _oneVector;
  72668. private _workingMatrix;
  72669. private updateCacheCalled;
  72670. private _correctPositionIfNotTrackPosition;
  72671. /**
  72672. * @hidden
  72673. * Updates the cached values of the camera
  72674. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  72675. */
  72676. _updateCache(ignoreParentClass?: boolean): void;
  72677. /**
  72678. * @hidden
  72679. * Get current device position in babylon world
  72680. */
  72681. _computeDevicePosition(): void;
  72682. /**
  72683. * Updates the current device position and rotation in the babylon world
  72684. */
  72685. update(): void;
  72686. /**
  72687. * @hidden
  72688. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  72689. * @returns an identity matrix
  72690. */
  72691. _getViewMatrix(): Matrix;
  72692. private _tmpMatrix;
  72693. /**
  72694. * This function is called by the two RIG cameras.
  72695. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  72696. * @hidden
  72697. */
  72698. _getWebVRViewMatrix(): Matrix;
  72699. /** @hidden */
  72700. _getWebVRProjectionMatrix(): Matrix;
  72701. private _onGamepadConnectedObserver;
  72702. private _onGamepadDisconnectedObserver;
  72703. private _updateCacheWhenTrackingDisabledObserver;
  72704. /**
  72705. * Initializes the controllers and their meshes
  72706. */
  72707. initControllers(): void;
  72708. }
  72709. }
  72710. declare module BABYLON {
  72711. /**
  72712. * Size options for a post process
  72713. */
  72714. export type PostProcessOptions = {
  72715. width: number;
  72716. height: number;
  72717. };
  72718. /**
  72719. * PostProcess can be used to apply a shader to a texture after it has been rendered
  72720. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72721. */
  72722. export class PostProcess {
  72723. /** Name of the PostProcess. */
  72724. name: string;
  72725. /**
  72726. * Gets or sets the unique id of the post process
  72727. */
  72728. uniqueId: number;
  72729. /**
  72730. * Width of the texture to apply the post process on
  72731. */
  72732. width: number;
  72733. /**
  72734. * Height of the texture to apply the post process on
  72735. */
  72736. height: number;
  72737. /**
  72738. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  72739. * @hidden
  72740. */
  72741. _outputTexture: Nullable<InternalTexture>;
  72742. /**
  72743. * Sampling mode used by the shader
  72744. * See https://doc.babylonjs.com/classes/3.1/texture
  72745. */
  72746. renderTargetSamplingMode: number;
  72747. /**
  72748. * Clear color to use when screen clearing
  72749. */
  72750. clearColor: Color4;
  72751. /**
  72752. * If the buffer needs to be cleared before applying the post process. (default: true)
  72753. * Should be set to false if shader will overwrite all previous pixels.
  72754. */
  72755. autoClear: boolean;
  72756. /**
  72757. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  72758. */
  72759. alphaMode: number;
  72760. /**
  72761. * Sets the setAlphaBlendConstants of the babylon engine
  72762. */
  72763. alphaConstants: Color4;
  72764. /**
  72765. * Animations to be used for the post processing
  72766. */
  72767. animations: Animation[];
  72768. /**
  72769. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  72770. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  72771. */
  72772. enablePixelPerfectMode: boolean;
  72773. /**
  72774. * Force the postprocess to be applied without taking in account viewport
  72775. */
  72776. forceFullscreenViewport: boolean;
  72777. /**
  72778. * List of inspectable custom properties (used by the Inspector)
  72779. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72780. */
  72781. inspectableCustomProperties: IInspectable[];
  72782. /**
  72783. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  72784. *
  72785. * | Value | Type | Description |
  72786. * | ----- | ----------------------------------- | ----------- |
  72787. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  72788. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  72789. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  72790. *
  72791. */
  72792. scaleMode: number;
  72793. /**
  72794. * Force textures to be a power of two (default: false)
  72795. */
  72796. alwaysForcePOT: boolean;
  72797. private _samples;
  72798. /**
  72799. * Number of sample textures (default: 1)
  72800. */
  72801. samples: number;
  72802. /**
  72803. * Modify the scale of the post process to be the same as the viewport (default: false)
  72804. */
  72805. adaptScaleToCurrentViewport: boolean;
  72806. private _camera;
  72807. private _scene;
  72808. private _engine;
  72809. private _options;
  72810. private _reusable;
  72811. private _textureType;
  72812. /**
  72813. * Smart array of input and output textures for the post process.
  72814. * @hidden
  72815. */
  72816. _textures: SmartArray<InternalTexture>;
  72817. /**
  72818. * The index in _textures that corresponds to the output texture.
  72819. * @hidden
  72820. */
  72821. _currentRenderTextureInd: number;
  72822. private _effect;
  72823. private _samplers;
  72824. private _fragmentUrl;
  72825. private _vertexUrl;
  72826. private _parameters;
  72827. private _scaleRatio;
  72828. protected _indexParameters: any;
  72829. private _shareOutputWithPostProcess;
  72830. private _texelSize;
  72831. private _forcedOutputTexture;
  72832. /**
  72833. * Returns the fragment url or shader name used in the post process.
  72834. * @returns the fragment url or name in the shader store.
  72835. */
  72836. getEffectName(): string;
  72837. /**
  72838. * An event triggered when the postprocess is activated.
  72839. */
  72840. onActivateObservable: Observable<Camera>;
  72841. private _onActivateObserver;
  72842. /**
  72843. * A function that is added to the onActivateObservable
  72844. */
  72845. onActivate: Nullable<(camera: Camera) => void>;
  72846. /**
  72847. * An event triggered when the postprocess changes its size.
  72848. */
  72849. onSizeChangedObservable: Observable<PostProcess>;
  72850. private _onSizeChangedObserver;
  72851. /**
  72852. * A function that is added to the onSizeChangedObservable
  72853. */
  72854. onSizeChanged: (postProcess: PostProcess) => void;
  72855. /**
  72856. * An event triggered when the postprocess applies its effect.
  72857. */
  72858. onApplyObservable: Observable<Effect>;
  72859. private _onApplyObserver;
  72860. /**
  72861. * A function that is added to the onApplyObservable
  72862. */
  72863. onApply: (effect: Effect) => void;
  72864. /**
  72865. * An event triggered before rendering the postprocess
  72866. */
  72867. onBeforeRenderObservable: Observable<Effect>;
  72868. private _onBeforeRenderObserver;
  72869. /**
  72870. * A function that is added to the onBeforeRenderObservable
  72871. */
  72872. onBeforeRender: (effect: Effect) => void;
  72873. /**
  72874. * An event triggered after rendering the postprocess
  72875. */
  72876. onAfterRenderObservable: Observable<Effect>;
  72877. private _onAfterRenderObserver;
  72878. /**
  72879. * A function that is added to the onAfterRenderObservable
  72880. */
  72881. onAfterRender: (efect: Effect) => void;
  72882. /**
  72883. * 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
  72884. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  72885. */
  72886. inputTexture: InternalTexture;
  72887. /**
  72888. * Gets the camera which post process is applied to.
  72889. * @returns The camera the post process is applied to.
  72890. */
  72891. getCamera(): Camera;
  72892. /**
  72893. * Gets the texel size of the postprocess.
  72894. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  72895. */
  72896. readonly texelSize: Vector2;
  72897. /**
  72898. * Creates a new instance PostProcess
  72899. * @param name The name of the PostProcess.
  72900. * @param fragmentUrl The url of the fragment shader to be used.
  72901. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  72902. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  72903. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  72904. * @param camera The camera to apply the render pass to.
  72905. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72906. * @param engine The engine which the post process will be applied. (default: current engine)
  72907. * @param reusable If the post process can be reused on the same frame. (default: false)
  72908. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  72909. * @param textureType Type of textures used when performing the post process. (default: 0)
  72910. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  72911. * @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
  72912. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  72913. */
  72914. constructor(
  72915. /** Name of the PostProcess. */
  72916. 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);
  72917. /**
  72918. * Gets a string idenfifying the name of the class
  72919. * @returns "PostProcess" string
  72920. */
  72921. getClassName(): string;
  72922. /**
  72923. * Gets the engine which this post process belongs to.
  72924. * @returns The engine the post process was enabled with.
  72925. */
  72926. getEngine(): Engine;
  72927. /**
  72928. * The effect that is created when initializing the post process.
  72929. * @returns The created effect corrisponding the the postprocess.
  72930. */
  72931. getEffect(): Effect;
  72932. /**
  72933. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  72934. * @param postProcess The post process to share the output with.
  72935. * @returns This post process.
  72936. */
  72937. shareOutputWith(postProcess: PostProcess): PostProcess;
  72938. /**
  72939. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  72940. * This should be called if the post process that shares output with this post process is disabled/disposed.
  72941. */
  72942. useOwnOutput(): void;
  72943. /**
  72944. * Updates the effect with the current post process compile time values and recompiles the shader.
  72945. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72946. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72947. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72948. * @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
  72949. * @param onCompiled Called when the shader has been compiled.
  72950. * @param onError Called if there is an error when compiling a shader.
  72951. */
  72952. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72953. /**
  72954. * The post process is reusable if it can be used multiple times within one frame.
  72955. * @returns If the post process is reusable
  72956. */
  72957. isReusable(): boolean;
  72958. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  72959. markTextureDirty(): void;
  72960. /**
  72961. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  72962. * 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.
  72963. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  72964. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  72965. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  72966. * @returns The target texture that was bound to be written to.
  72967. */
  72968. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  72969. /**
  72970. * If the post process is supported.
  72971. */
  72972. readonly isSupported: boolean;
  72973. /**
  72974. * The aspect ratio of the output texture.
  72975. */
  72976. readonly aspectRatio: number;
  72977. /**
  72978. * Get a value indicating if the post-process is ready to be used
  72979. * @returns true if the post-process is ready (shader is compiled)
  72980. */
  72981. isReady(): boolean;
  72982. /**
  72983. * Binds all textures and uniforms to the shader, this will be run on every pass.
  72984. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  72985. */
  72986. apply(): Nullable<Effect>;
  72987. private _disposeTextures;
  72988. /**
  72989. * Disposes the post process.
  72990. * @param camera The camera to dispose the post process on.
  72991. */
  72992. dispose(camera?: Camera): void;
  72993. }
  72994. }
  72995. declare module BABYLON {
  72996. /**
  72997. * PostProcessManager is used to manage one or more post processes or post process pipelines
  72998. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72999. */
  73000. export class PostProcessManager {
  73001. private _scene;
  73002. private _indexBuffer;
  73003. private _vertexBuffers;
  73004. /**
  73005. * Creates a new instance PostProcess
  73006. * @param scene The scene that the post process is associated with.
  73007. */
  73008. constructor(scene: Scene);
  73009. private _prepareBuffers;
  73010. private _buildIndexBuffer;
  73011. /**
  73012. * Rebuilds the vertex buffers of the manager.
  73013. * @hidden
  73014. */
  73015. _rebuild(): void;
  73016. /**
  73017. * Prepares a frame to be run through a post process.
  73018. * @param sourceTexture The input texture to the post procesess. (default: null)
  73019. * @param postProcesses An array of post processes to be run. (default: null)
  73020. * @returns True if the post processes were able to be run.
  73021. * @hidden
  73022. */
  73023. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  73024. /**
  73025. * Manually render a set of post processes to a texture.
  73026. * @param postProcesses An array of post processes to be run.
  73027. * @param targetTexture The target texture to render to.
  73028. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  73029. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  73030. * @param lodLevel defines which lod of the texture to render to
  73031. */
  73032. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  73033. /**
  73034. * Finalize the result of the output of the postprocesses.
  73035. * @param doNotPresent If true the result will not be displayed to the screen.
  73036. * @param targetTexture The target texture to render to.
  73037. * @param faceIndex The index of the face to bind the target texture to.
  73038. * @param postProcesses The array of post processes to render.
  73039. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  73040. * @hidden
  73041. */
  73042. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  73043. /**
  73044. * Disposes of the post process manager.
  73045. */
  73046. dispose(): void;
  73047. }
  73048. }
  73049. declare module BABYLON {
  73050. interface AbstractScene {
  73051. /**
  73052. * The list of layers (background and foreground) of the scene
  73053. */
  73054. layers: Array<Layer>;
  73055. }
  73056. /**
  73057. * Defines the layer scene component responsible to manage any layers
  73058. * in a given scene.
  73059. */
  73060. export class LayerSceneComponent implements ISceneComponent {
  73061. /**
  73062. * The component name helpfull to identify the component in the list of scene components.
  73063. */
  73064. readonly name: string;
  73065. /**
  73066. * The scene the component belongs to.
  73067. */
  73068. scene: Scene;
  73069. private _engine;
  73070. /**
  73071. * Creates a new instance of the component for the given scene
  73072. * @param scene Defines the scene to register the component in
  73073. */
  73074. constructor(scene: Scene);
  73075. /**
  73076. * Registers the component in a given scene
  73077. */
  73078. register(): void;
  73079. /**
  73080. * Rebuilds the elements related to this component in case of
  73081. * context lost for instance.
  73082. */
  73083. rebuild(): void;
  73084. /**
  73085. * Disposes the component and the associated ressources.
  73086. */
  73087. dispose(): void;
  73088. private _draw;
  73089. private _drawCameraPredicate;
  73090. private _drawCameraBackground;
  73091. private _drawCameraForeground;
  73092. private _drawRenderTargetPredicate;
  73093. private _drawRenderTargetBackground;
  73094. private _drawRenderTargetForeground;
  73095. }
  73096. }
  73097. declare module BABYLON {
  73098. /** @hidden */
  73099. export var layerPixelShader: {
  73100. name: string;
  73101. shader: string;
  73102. };
  73103. }
  73104. declare module BABYLON {
  73105. /** @hidden */
  73106. export var layerVertexShader: {
  73107. name: string;
  73108. shader: string;
  73109. };
  73110. }
  73111. declare module BABYLON {
  73112. /**
  73113. * This represents a full screen 2d layer.
  73114. * This can be useful to display a picture in the background of your scene for instance.
  73115. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73116. */
  73117. export class Layer {
  73118. /**
  73119. * Define the name of the layer.
  73120. */
  73121. name: string;
  73122. /**
  73123. * Define the texture the layer should display.
  73124. */
  73125. texture: Nullable<Texture>;
  73126. /**
  73127. * Is the layer in background or foreground.
  73128. */
  73129. isBackground: boolean;
  73130. /**
  73131. * Define the color of the layer (instead of texture).
  73132. */
  73133. color: Color4;
  73134. /**
  73135. * Define the scale of the layer in order to zoom in out of the texture.
  73136. */
  73137. scale: Vector2;
  73138. /**
  73139. * Define an offset for the layer in order to shift the texture.
  73140. */
  73141. offset: Vector2;
  73142. /**
  73143. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  73144. */
  73145. alphaBlendingMode: number;
  73146. /**
  73147. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  73148. * Alpha test will not mix with the background color in case of transparency.
  73149. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  73150. */
  73151. alphaTest: boolean;
  73152. /**
  73153. * Define a mask to restrict the layer to only some of the scene cameras.
  73154. */
  73155. layerMask: number;
  73156. /**
  73157. * Define the list of render target the layer is visible into.
  73158. */
  73159. renderTargetTextures: RenderTargetTexture[];
  73160. /**
  73161. * Define if the layer is only used in renderTarget or if it also
  73162. * renders in the main frame buffer of the canvas.
  73163. */
  73164. renderOnlyInRenderTargetTextures: boolean;
  73165. private _scene;
  73166. private _vertexBuffers;
  73167. private _indexBuffer;
  73168. private _effect;
  73169. private _alphaTestEffect;
  73170. /**
  73171. * An event triggered when the layer is disposed.
  73172. */
  73173. onDisposeObservable: Observable<Layer>;
  73174. private _onDisposeObserver;
  73175. /**
  73176. * Back compatibility with callback before the onDisposeObservable existed.
  73177. * The set callback will be triggered when the layer has been disposed.
  73178. */
  73179. onDispose: () => void;
  73180. /**
  73181. * An event triggered before rendering the scene
  73182. */
  73183. onBeforeRenderObservable: Observable<Layer>;
  73184. private _onBeforeRenderObserver;
  73185. /**
  73186. * Back compatibility with callback before the onBeforeRenderObservable existed.
  73187. * The set callback will be triggered just before rendering the layer.
  73188. */
  73189. onBeforeRender: () => void;
  73190. /**
  73191. * An event triggered after rendering the scene
  73192. */
  73193. onAfterRenderObservable: Observable<Layer>;
  73194. private _onAfterRenderObserver;
  73195. /**
  73196. * Back compatibility with callback before the onAfterRenderObservable existed.
  73197. * The set callback will be triggered just after rendering the layer.
  73198. */
  73199. onAfterRender: () => void;
  73200. /**
  73201. * Instantiates a new layer.
  73202. * This represents a full screen 2d layer.
  73203. * This can be useful to display a picture in the background of your scene for instance.
  73204. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73205. * @param name Define the name of the layer in the scene
  73206. * @param imgUrl Define the url of the texture to display in the layer
  73207. * @param scene Define the scene the layer belongs to
  73208. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  73209. * @param color Defines a color for the layer
  73210. */
  73211. constructor(
  73212. /**
  73213. * Define the name of the layer.
  73214. */
  73215. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  73216. private _createIndexBuffer;
  73217. /** @hidden */
  73218. _rebuild(): void;
  73219. /**
  73220. * Renders the layer in the scene.
  73221. */
  73222. render(): void;
  73223. /**
  73224. * Disposes and releases the associated ressources.
  73225. */
  73226. dispose(): void;
  73227. }
  73228. }
  73229. declare module BABYLON {
  73230. interface AbstractScene {
  73231. /**
  73232. * The list of procedural textures added to the scene
  73233. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73234. */
  73235. proceduralTextures: Array<ProceduralTexture>;
  73236. }
  73237. /**
  73238. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  73239. * in a given scene.
  73240. */
  73241. export class ProceduralTextureSceneComponent implements ISceneComponent {
  73242. /**
  73243. * The component name helpfull to identify the component in the list of scene components.
  73244. */
  73245. readonly name: string;
  73246. /**
  73247. * The scene the component belongs to.
  73248. */
  73249. scene: Scene;
  73250. /**
  73251. * Creates a new instance of the component for the given scene
  73252. * @param scene Defines the scene to register the component in
  73253. */
  73254. constructor(scene: Scene);
  73255. /**
  73256. * Registers the component in a given scene
  73257. */
  73258. register(): void;
  73259. /**
  73260. * Rebuilds the elements related to this component in case of
  73261. * context lost for instance.
  73262. */
  73263. rebuild(): void;
  73264. /**
  73265. * Disposes the component and the associated ressources.
  73266. */
  73267. dispose(): void;
  73268. private _beforeClear;
  73269. }
  73270. }
  73271. declare module BABYLON {
  73272. /** @hidden */
  73273. export var proceduralVertexShader: {
  73274. name: string;
  73275. shader: string;
  73276. };
  73277. }
  73278. declare module BABYLON {
  73279. /**
  73280. * 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.
  73281. * This is the base class of any Procedural texture and contains most of the shareable code.
  73282. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73283. */
  73284. export class ProceduralTexture extends Texture {
  73285. isCube: boolean;
  73286. /**
  73287. * Define if the texture is enabled or not (disabled texture will not render)
  73288. */
  73289. isEnabled: boolean;
  73290. /**
  73291. * Define if the texture must be cleared before rendering (default is true)
  73292. */
  73293. autoClear: boolean;
  73294. /**
  73295. * Callback called when the texture is generated
  73296. */
  73297. onGenerated: () => void;
  73298. /**
  73299. * Event raised when the texture is generated
  73300. */
  73301. onGeneratedObservable: Observable<ProceduralTexture>;
  73302. /** @hidden */
  73303. _generateMipMaps: boolean;
  73304. /** @hidden **/
  73305. _effect: Effect;
  73306. /** @hidden */
  73307. _textures: {
  73308. [key: string]: Texture;
  73309. };
  73310. private _size;
  73311. private _currentRefreshId;
  73312. private _refreshRate;
  73313. private _vertexBuffers;
  73314. private _indexBuffer;
  73315. private _uniforms;
  73316. private _samplers;
  73317. private _fragment;
  73318. private _floats;
  73319. private _ints;
  73320. private _floatsArrays;
  73321. private _colors3;
  73322. private _colors4;
  73323. private _vectors2;
  73324. private _vectors3;
  73325. private _matrices;
  73326. private _fallbackTexture;
  73327. private _fallbackTextureUsed;
  73328. private _engine;
  73329. private _cachedDefines;
  73330. private _contentUpdateId;
  73331. private _contentData;
  73332. /**
  73333. * Instantiates a new procedural texture.
  73334. * 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.
  73335. * This is the base class of any Procedural texture and contains most of the shareable code.
  73336. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73337. * @param name Define the name of the texture
  73338. * @param size Define the size of the texture to create
  73339. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  73340. * @param scene Define the scene the texture belongs to
  73341. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  73342. * @param generateMipMaps Define if the texture should creates mip maps or not
  73343. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  73344. */
  73345. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  73346. /**
  73347. * The effect that is created when initializing the post process.
  73348. * @returns The created effect corrisponding the the postprocess.
  73349. */
  73350. getEffect(): Effect;
  73351. /**
  73352. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  73353. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  73354. */
  73355. getContent(): Nullable<ArrayBufferView>;
  73356. private _createIndexBuffer;
  73357. /** @hidden */
  73358. _rebuild(): void;
  73359. /**
  73360. * Resets the texture in order to recreate its associated resources.
  73361. * This can be called in case of context loss
  73362. */
  73363. reset(): void;
  73364. protected _getDefines(): string;
  73365. /**
  73366. * Is the texture ready to be used ? (rendered at least once)
  73367. * @returns true if ready, otherwise, false.
  73368. */
  73369. isReady(): boolean;
  73370. /**
  73371. * Resets the refresh counter of the texture and start bak from scratch.
  73372. * Could be useful to regenerate the texture if it is setup to render only once.
  73373. */
  73374. resetRefreshCounter(): void;
  73375. /**
  73376. * Set the fragment shader to use in order to render the texture.
  73377. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  73378. */
  73379. setFragment(fragment: any): void;
  73380. /**
  73381. * Define the refresh rate of the texture or the rendering frequency.
  73382. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  73383. */
  73384. refreshRate: number;
  73385. /** @hidden */
  73386. _shouldRender(): boolean;
  73387. /**
  73388. * Get the size the texture is rendering at.
  73389. * @returns the size (texture is always squared)
  73390. */
  73391. getRenderSize(): number;
  73392. /**
  73393. * Resize the texture to new value.
  73394. * @param size Define the new size the texture should have
  73395. * @param generateMipMaps Define whether the new texture should create mip maps
  73396. */
  73397. resize(size: number, generateMipMaps: boolean): void;
  73398. private _checkUniform;
  73399. /**
  73400. * Set a texture in the shader program used to render.
  73401. * @param name Define the name of the uniform samplers as defined in the shader
  73402. * @param texture Define the texture to bind to this sampler
  73403. * @return the texture itself allowing "fluent" like uniform updates
  73404. */
  73405. setTexture(name: string, texture: Texture): ProceduralTexture;
  73406. /**
  73407. * Set a float in the shader.
  73408. * @param name Define the name of the uniform as defined in the shader
  73409. * @param value Define the value to give to the uniform
  73410. * @return the texture itself allowing "fluent" like uniform updates
  73411. */
  73412. setFloat(name: string, value: number): ProceduralTexture;
  73413. /**
  73414. * Set a int in the shader.
  73415. * @param name Define the name of the uniform as defined in the shader
  73416. * @param value Define the value to give to the uniform
  73417. * @return the texture itself allowing "fluent" like uniform updates
  73418. */
  73419. setInt(name: string, value: number): ProceduralTexture;
  73420. /**
  73421. * Set an array of floats in the shader.
  73422. * @param name Define the name of the uniform as defined in the shader
  73423. * @param value Define the value to give to the uniform
  73424. * @return the texture itself allowing "fluent" like uniform updates
  73425. */
  73426. setFloats(name: string, value: number[]): ProceduralTexture;
  73427. /**
  73428. * Set a vec3 in the shader from a Color3.
  73429. * @param name Define the name of the uniform as defined in the shader
  73430. * @param value Define the value to give to the uniform
  73431. * @return the texture itself allowing "fluent" like uniform updates
  73432. */
  73433. setColor3(name: string, value: Color3): ProceduralTexture;
  73434. /**
  73435. * Set a vec4 in the shader from a Color4.
  73436. * @param name Define the name of the uniform as defined in the shader
  73437. * @param value Define the value to give to the uniform
  73438. * @return the texture itself allowing "fluent" like uniform updates
  73439. */
  73440. setColor4(name: string, value: Color4): ProceduralTexture;
  73441. /**
  73442. * Set a vec2 in the shader from a Vector2.
  73443. * @param name Define the name of the uniform as defined in the shader
  73444. * @param value Define the value to give to the uniform
  73445. * @return the texture itself allowing "fluent" like uniform updates
  73446. */
  73447. setVector2(name: string, value: Vector2): ProceduralTexture;
  73448. /**
  73449. * Set a vec3 in the shader from a Vector3.
  73450. * @param name Define the name of the uniform as defined in the shader
  73451. * @param value Define the value to give to the uniform
  73452. * @return the texture itself allowing "fluent" like uniform updates
  73453. */
  73454. setVector3(name: string, value: Vector3): ProceduralTexture;
  73455. /**
  73456. * Set a mat4 in the shader from a MAtrix.
  73457. * @param name Define the name of the uniform as defined in the shader
  73458. * @param value Define the value to give to the uniform
  73459. * @return the texture itself allowing "fluent" like uniform updates
  73460. */
  73461. setMatrix(name: string, value: Matrix): ProceduralTexture;
  73462. /**
  73463. * Render the texture to its associated render target.
  73464. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  73465. */
  73466. render(useCameraPostProcess?: boolean): void;
  73467. /**
  73468. * Clone the texture.
  73469. * @returns the cloned texture
  73470. */
  73471. clone(): ProceduralTexture;
  73472. /**
  73473. * Dispose the texture and release its asoociated resources.
  73474. */
  73475. dispose(): void;
  73476. }
  73477. }
  73478. declare module BABYLON {
  73479. /**
  73480. * This represents the base class for particle system in Babylon.
  73481. * 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.
  73482. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  73483. * @example https://doc.babylonjs.com/babylon101/particles
  73484. */
  73485. export class BaseParticleSystem {
  73486. /**
  73487. * Source color is added to the destination color without alpha affecting the result
  73488. */
  73489. static BLENDMODE_ONEONE: number;
  73490. /**
  73491. * Blend current color and particle color using particle’s alpha
  73492. */
  73493. static BLENDMODE_STANDARD: number;
  73494. /**
  73495. * Add current color and particle color multiplied by particle’s alpha
  73496. */
  73497. static BLENDMODE_ADD: number;
  73498. /**
  73499. * Multiply current color with particle color
  73500. */
  73501. static BLENDMODE_MULTIPLY: number;
  73502. /**
  73503. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  73504. */
  73505. static BLENDMODE_MULTIPLYADD: number;
  73506. /**
  73507. * List of animations used by the particle system.
  73508. */
  73509. animations: Animation[];
  73510. /**
  73511. * The id of the Particle system.
  73512. */
  73513. id: string;
  73514. /**
  73515. * The friendly name of the Particle system.
  73516. */
  73517. name: string;
  73518. /**
  73519. * The rendering group used by the Particle system to chose when to render.
  73520. */
  73521. renderingGroupId: number;
  73522. /**
  73523. * The emitter represents the Mesh or position we are attaching the particle system to.
  73524. */
  73525. emitter: Nullable<AbstractMesh | Vector3>;
  73526. /**
  73527. * The maximum number of particles to emit per frame
  73528. */
  73529. emitRate: number;
  73530. /**
  73531. * If you want to launch only a few particles at once, that can be done, as well.
  73532. */
  73533. manualEmitCount: number;
  73534. /**
  73535. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  73536. */
  73537. updateSpeed: number;
  73538. /**
  73539. * The amount of time the particle system is running (depends of the overall update speed).
  73540. */
  73541. targetStopDuration: number;
  73542. /**
  73543. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73544. */
  73545. disposeOnStop: boolean;
  73546. /**
  73547. * Minimum power of emitting particles.
  73548. */
  73549. minEmitPower: number;
  73550. /**
  73551. * Maximum power of emitting particles.
  73552. */
  73553. maxEmitPower: number;
  73554. /**
  73555. * Minimum life time of emitting particles.
  73556. */
  73557. minLifeTime: number;
  73558. /**
  73559. * Maximum life time of emitting particles.
  73560. */
  73561. maxLifeTime: number;
  73562. /**
  73563. * Minimum Size of emitting particles.
  73564. */
  73565. minSize: number;
  73566. /**
  73567. * Maximum Size of emitting particles.
  73568. */
  73569. maxSize: number;
  73570. /**
  73571. * Minimum scale of emitting particles on X axis.
  73572. */
  73573. minScaleX: number;
  73574. /**
  73575. * Maximum scale of emitting particles on X axis.
  73576. */
  73577. maxScaleX: number;
  73578. /**
  73579. * Minimum scale of emitting particles on Y axis.
  73580. */
  73581. minScaleY: number;
  73582. /**
  73583. * Maximum scale of emitting particles on Y axis.
  73584. */
  73585. maxScaleY: number;
  73586. /**
  73587. * Gets or sets the minimal initial rotation in radians.
  73588. */
  73589. minInitialRotation: number;
  73590. /**
  73591. * Gets or sets the maximal initial rotation in radians.
  73592. */
  73593. maxInitialRotation: number;
  73594. /**
  73595. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73596. */
  73597. minAngularSpeed: number;
  73598. /**
  73599. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73600. */
  73601. maxAngularSpeed: number;
  73602. /**
  73603. * The texture used to render each particle. (this can be a spritesheet)
  73604. */
  73605. particleTexture: Nullable<Texture>;
  73606. /**
  73607. * The layer mask we are rendering the particles through.
  73608. */
  73609. layerMask: number;
  73610. /**
  73611. * This can help using your own shader to render the particle system.
  73612. * The according effect will be created
  73613. */
  73614. customShader: any;
  73615. /**
  73616. * By default particle system starts as soon as they are created. This prevents the
  73617. * automatic start to happen and let you decide when to start emitting particles.
  73618. */
  73619. preventAutoStart: boolean;
  73620. private _noiseTexture;
  73621. /**
  73622. * Gets or sets a texture used to add random noise to particle positions
  73623. */
  73624. noiseTexture: Nullable<ProceduralTexture>;
  73625. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  73626. noiseStrength: Vector3;
  73627. /**
  73628. * Callback triggered when the particle animation is ending.
  73629. */
  73630. onAnimationEnd: Nullable<() => void>;
  73631. /**
  73632. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  73633. */
  73634. blendMode: number;
  73635. /**
  73636. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  73637. * to override the particles.
  73638. */
  73639. forceDepthWrite: boolean;
  73640. /** 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 */
  73641. preWarmCycles: number;
  73642. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  73643. preWarmStepOffset: number;
  73644. /**
  73645. * 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)
  73646. */
  73647. spriteCellChangeSpeed: number;
  73648. /**
  73649. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  73650. */
  73651. startSpriteCellID: number;
  73652. /**
  73653. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  73654. */
  73655. endSpriteCellID: number;
  73656. /**
  73657. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  73658. */
  73659. spriteCellWidth: number;
  73660. /**
  73661. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  73662. */
  73663. spriteCellHeight: number;
  73664. /**
  73665. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  73666. */
  73667. spriteRandomStartCell: boolean;
  73668. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  73669. translationPivot: Vector2;
  73670. /** @hidden */
  73671. protected _isAnimationSheetEnabled: boolean;
  73672. /**
  73673. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  73674. */
  73675. beginAnimationOnStart: boolean;
  73676. /**
  73677. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  73678. */
  73679. beginAnimationFrom: number;
  73680. /**
  73681. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  73682. */
  73683. beginAnimationTo: number;
  73684. /**
  73685. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  73686. */
  73687. beginAnimationLoop: boolean;
  73688. /**
  73689. * Gets or sets a world offset applied to all particles
  73690. */
  73691. worldOffset: Vector3;
  73692. /**
  73693. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  73694. */
  73695. isAnimationSheetEnabled: boolean;
  73696. /**
  73697. * Get hosting scene
  73698. * @returns the scene
  73699. */
  73700. getScene(): Scene;
  73701. /**
  73702. * You can use gravity if you want to give an orientation to your particles.
  73703. */
  73704. gravity: Vector3;
  73705. protected _colorGradients: Nullable<Array<ColorGradient>>;
  73706. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  73707. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  73708. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  73709. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  73710. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  73711. protected _dragGradients: Nullable<Array<FactorGradient>>;
  73712. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  73713. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  73714. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  73715. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  73716. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  73717. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  73718. /**
  73719. * Defines the delay in milliseconds before starting the system (0 by default)
  73720. */
  73721. startDelay: number;
  73722. /**
  73723. * Gets the current list of drag gradients.
  73724. * You must use addDragGradient and removeDragGradient to udpate this list
  73725. * @returns the list of drag gradients
  73726. */
  73727. getDragGradients(): Nullable<Array<FactorGradient>>;
  73728. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  73729. limitVelocityDamping: number;
  73730. /**
  73731. * Gets the current list of limit velocity gradients.
  73732. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73733. * @returns the list of limit velocity gradients
  73734. */
  73735. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73736. /**
  73737. * Gets the current list of color gradients.
  73738. * You must use addColorGradient and removeColorGradient to udpate this list
  73739. * @returns the list of color gradients
  73740. */
  73741. getColorGradients(): Nullable<Array<ColorGradient>>;
  73742. /**
  73743. * Gets the current list of size gradients.
  73744. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73745. * @returns the list of size gradients
  73746. */
  73747. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73748. /**
  73749. * Gets the current list of color remap gradients.
  73750. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73751. * @returns the list of color remap gradients
  73752. */
  73753. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73754. /**
  73755. * Gets the current list of alpha remap gradients.
  73756. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73757. * @returns the list of alpha remap gradients
  73758. */
  73759. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73760. /**
  73761. * Gets the current list of life time gradients.
  73762. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  73763. * @returns the list of life time gradients
  73764. */
  73765. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  73766. /**
  73767. * Gets the current list of angular speed gradients.
  73768. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73769. * @returns the list of angular speed gradients
  73770. */
  73771. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73772. /**
  73773. * Gets the current list of velocity gradients.
  73774. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73775. * @returns the list of velocity gradients
  73776. */
  73777. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73778. /**
  73779. * Gets the current list of start size gradients.
  73780. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  73781. * @returns the list of start size gradients
  73782. */
  73783. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  73784. /**
  73785. * Gets the current list of emit rate gradients.
  73786. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73787. * @returns the list of emit rate gradients
  73788. */
  73789. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73790. /**
  73791. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73792. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73793. */
  73794. direction1: Vector3;
  73795. /**
  73796. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73797. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73798. */
  73799. direction2: Vector3;
  73800. /**
  73801. * 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.
  73802. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73803. */
  73804. minEmitBox: Vector3;
  73805. /**
  73806. * 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.
  73807. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73808. */
  73809. maxEmitBox: Vector3;
  73810. /**
  73811. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  73812. */
  73813. color1: Color4;
  73814. /**
  73815. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  73816. */
  73817. color2: Color4;
  73818. /**
  73819. * Color the particle will have at the end of its lifetime
  73820. */
  73821. colorDead: Color4;
  73822. /**
  73823. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  73824. */
  73825. textureMask: Color4;
  73826. /**
  73827. * The particle emitter type defines the emitter used by the particle system.
  73828. * It can be for example box, sphere, or cone...
  73829. */
  73830. particleEmitterType: IParticleEmitterType;
  73831. /** @hidden */
  73832. _isSubEmitter: boolean;
  73833. /**
  73834. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73835. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73836. */
  73837. billboardMode: number;
  73838. protected _isBillboardBased: boolean;
  73839. /**
  73840. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  73841. */
  73842. isBillboardBased: boolean;
  73843. /**
  73844. * The scene the particle system belongs to.
  73845. */
  73846. protected _scene: Scene;
  73847. /**
  73848. * Local cache of defines for image processing.
  73849. */
  73850. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  73851. /**
  73852. * Default configuration related to image processing available in the standard Material.
  73853. */
  73854. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  73855. /**
  73856. * Gets the image processing configuration used either in this material.
  73857. */
  73858. /**
  73859. * Sets the Default image processing configuration used either in the this material.
  73860. *
  73861. * If sets to null, the scene one is in use.
  73862. */
  73863. imageProcessingConfiguration: ImageProcessingConfiguration;
  73864. /**
  73865. * Attaches a new image processing configuration to the Standard Material.
  73866. * @param configuration
  73867. */
  73868. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  73869. /** @hidden */
  73870. protected _reset(): void;
  73871. /** @hidden */
  73872. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  73873. /**
  73874. * Instantiates a particle system.
  73875. * 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.
  73876. * @param name The name of the particle system
  73877. */
  73878. constructor(name: string);
  73879. /**
  73880. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73881. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73882. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73883. * @returns the emitter
  73884. */
  73885. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73886. /**
  73887. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73888. * @param radius The radius of the hemisphere to emit from
  73889. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73890. * @returns the emitter
  73891. */
  73892. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  73893. /**
  73894. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73895. * @param radius The radius of the sphere to emit from
  73896. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73897. * @returns the emitter
  73898. */
  73899. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  73900. /**
  73901. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73902. * @param radius The radius of the sphere to emit from
  73903. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73904. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73905. * @returns the emitter
  73906. */
  73907. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  73908. /**
  73909. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73910. * @param radius The radius of the emission cylinder
  73911. * @param height The height of the emission cylinder
  73912. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73913. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73914. * @returns the emitter
  73915. */
  73916. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  73917. /**
  73918. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73919. * @param radius The radius of the cylinder to emit from
  73920. * @param height The height of the emission cylinder
  73921. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73922. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73923. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73924. * @returns the emitter
  73925. */
  73926. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  73927. /**
  73928. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73929. * @param radius The radius of the cone to emit from
  73930. * @param angle The base angle of the cone
  73931. * @returns the emitter
  73932. */
  73933. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  73934. /**
  73935. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73936. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73937. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73938. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73939. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73940. * @returns the emitter
  73941. */
  73942. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73943. }
  73944. }
  73945. declare module BABYLON {
  73946. /**
  73947. * Type of sub emitter
  73948. */
  73949. export enum SubEmitterType {
  73950. /**
  73951. * Attached to the particle over it's lifetime
  73952. */
  73953. ATTACHED = 0,
  73954. /**
  73955. * Created when the particle dies
  73956. */
  73957. END = 1
  73958. }
  73959. /**
  73960. * Sub emitter class used to emit particles from an existing particle
  73961. */
  73962. export class SubEmitter {
  73963. /**
  73964. * the particle system to be used by the sub emitter
  73965. */
  73966. particleSystem: ParticleSystem;
  73967. /**
  73968. * Type of the submitter (Default: END)
  73969. */
  73970. type: SubEmitterType;
  73971. /**
  73972. * 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)
  73973. * Note: This only is supported when using an emitter of type Mesh
  73974. */
  73975. inheritDirection: boolean;
  73976. /**
  73977. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  73978. */
  73979. inheritedVelocityAmount: number;
  73980. /**
  73981. * Creates a sub emitter
  73982. * @param particleSystem the particle system to be used by the sub emitter
  73983. */
  73984. constructor(
  73985. /**
  73986. * the particle system to be used by the sub emitter
  73987. */
  73988. particleSystem: ParticleSystem);
  73989. /**
  73990. * Clones the sub emitter
  73991. * @returns the cloned sub emitter
  73992. */
  73993. clone(): SubEmitter;
  73994. /**
  73995. * Serialize current object to a JSON object
  73996. * @returns the serialized object
  73997. */
  73998. serialize(): any;
  73999. /** @hidden */
  74000. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  74001. /**
  74002. * Creates a new SubEmitter from a serialized JSON version
  74003. * @param serializationObject defines the JSON object to read from
  74004. * @param scene defines the hosting scene
  74005. * @param rootUrl defines the rootUrl for data loading
  74006. * @returns a new SubEmitter
  74007. */
  74008. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  74009. /** Release associated resources */
  74010. dispose(): void;
  74011. }
  74012. }
  74013. declare module BABYLON {
  74014. /** @hidden */
  74015. export var clipPlaneFragmentDeclaration: {
  74016. name: string;
  74017. shader: string;
  74018. };
  74019. }
  74020. declare module BABYLON {
  74021. /** @hidden */
  74022. export var imageProcessingDeclaration: {
  74023. name: string;
  74024. shader: string;
  74025. };
  74026. }
  74027. declare module BABYLON {
  74028. /** @hidden */
  74029. export var imageProcessingFunctions: {
  74030. name: string;
  74031. shader: string;
  74032. };
  74033. }
  74034. declare module BABYLON {
  74035. /** @hidden */
  74036. export var clipPlaneFragment: {
  74037. name: string;
  74038. shader: string;
  74039. };
  74040. }
  74041. declare module BABYLON {
  74042. /** @hidden */
  74043. export var particlesPixelShader: {
  74044. name: string;
  74045. shader: string;
  74046. };
  74047. }
  74048. declare module BABYLON {
  74049. /** @hidden */
  74050. export var clipPlaneVertexDeclaration: {
  74051. name: string;
  74052. shader: string;
  74053. };
  74054. }
  74055. declare module BABYLON {
  74056. /** @hidden */
  74057. export var clipPlaneVertex: {
  74058. name: string;
  74059. shader: string;
  74060. };
  74061. }
  74062. declare module BABYLON {
  74063. /** @hidden */
  74064. export var particlesVertexShader: {
  74065. name: string;
  74066. shader: string;
  74067. };
  74068. }
  74069. declare module BABYLON {
  74070. /**
  74071. * This represents a particle system in Babylon.
  74072. * 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.
  74073. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74074. * @example https://doc.babylonjs.com/babylon101/particles
  74075. */
  74076. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  74077. /**
  74078. * Billboard mode will only apply to Y axis
  74079. */
  74080. static readonly BILLBOARDMODE_Y: number;
  74081. /**
  74082. * Billboard mode will apply to all axes
  74083. */
  74084. static readonly BILLBOARDMODE_ALL: number;
  74085. /**
  74086. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74087. */
  74088. static readonly BILLBOARDMODE_STRETCHED: number;
  74089. /**
  74090. * This function can be defined to provide custom update for active particles.
  74091. * This function will be called instead of regular update (age, position, color, etc.).
  74092. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  74093. */
  74094. updateFunction: (particles: Particle[]) => void;
  74095. private _emitterWorldMatrix;
  74096. /**
  74097. * This function can be defined to specify initial direction for every new particle.
  74098. * It by default use the emitterType defined function
  74099. */
  74100. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  74101. /**
  74102. * This function can be defined to specify initial position for every new particle.
  74103. * It by default use the emitterType defined function
  74104. */
  74105. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  74106. /**
  74107. * @hidden
  74108. */
  74109. _inheritedVelocityOffset: Vector3;
  74110. /**
  74111. * An event triggered when the system is disposed
  74112. */
  74113. onDisposeObservable: Observable<ParticleSystem>;
  74114. private _onDisposeObserver;
  74115. /**
  74116. * Sets a callback that will be triggered when the system is disposed
  74117. */
  74118. onDispose: () => void;
  74119. private _particles;
  74120. private _epsilon;
  74121. private _capacity;
  74122. private _stockParticles;
  74123. private _newPartsExcess;
  74124. private _vertexData;
  74125. private _vertexBuffer;
  74126. private _vertexBuffers;
  74127. private _spriteBuffer;
  74128. private _indexBuffer;
  74129. private _effect;
  74130. private _customEffect;
  74131. private _cachedDefines;
  74132. private _scaledColorStep;
  74133. private _colorDiff;
  74134. private _scaledDirection;
  74135. private _scaledGravity;
  74136. private _currentRenderId;
  74137. private _alive;
  74138. private _useInstancing;
  74139. private _started;
  74140. private _stopped;
  74141. private _actualFrame;
  74142. private _scaledUpdateSpeed;
  74143. private _vertexBufferSize;
  74144. /** @hidden */
  74145. _currentEmitRateGradient: Nullable<FactorGradient>;
  74146. /** @hidden */
  74147. _currentEmitRate1: number;
  74148. /** @hidden */
  74149. _currentEmitRate2: number;
  74150. /** @hidden */
  74151. _currentStartSizeGradient: Nullable<FactorGradient>;
  74152. /** @hidden */
  74153. _currentStartSize1: number;
  74154. /** @hidden */
  74155. _currentStartSize2: number;
  74156. private readonly _rawTextureWidth;
  74157. private _rampGradientsTexture;
  74158. private _useRampGradients;
  74159. /** Gets or sets a boolean indicating that ramp gradients must be used
  74160. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74161. */
  74162. useRampGradients: boolean;
  74163. /**
  74164. * 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.
  74165. * 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: [])
  74166. */
  74167. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  74168. private _subEmitters;
  74169. /**
  74170. * @hidden
  74171. * If the particle systems emitter should be disposed when the particle system is disposed
  74172. */
  74173. _disposeEmitterOnDispose: boolean;
  74174. /**
  74175. * The current active Sub-systems, this property is used by the root particle system only.
  74176. */
  74177. activeSubSystems: Array<ParticleSystem>;
  74178. private _rootParticleSystem;
  74179. /**
  74180. * Gets the current list of active particles
  74181. */
  74182. readonly particles: Particle[];
  74183. /**
  74184. * Returns the string "ParticleSystem"
  74185. * @returns a string containing the class name
  74186. */
  74187. getClassName(): string;
  74188. /**
  74189. * Instantiates a particle system.
  74190. * 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.
  74191. * @param name The name of the particle system
  74192. * @param capacity The max number of particles alive at the same time
  74193. * @param scene The scene the particle system belongs to
  74194. * @param customEffect a custom effect used to change the way particles are rendered by default
  74195. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  74196. * @param epsilon Offset used to render the particles
  74197. */
  74198. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  74199. private _addFactorGradient;
  74200. private _removeFactorGradient;
  74201. /**
  74202. * Adds a new life time gradient
  74203. * @param gradient defines the gradient to use (between 0 and 1)
  74204. * @param factor defines the life time factor to affect to the specified gradient
  74205. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74206. * @returns the current particle system
  74207. */
  74208. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74209. /**
  74210. * Remove a specific life time gradient
  74211. * @param gradient defines the gradient to remove
  74212. * @returns the current particle system
  74213. */
  74214. removeLifeTimeGradient(gradient: number): IParticleSystem;
  74215. /**
  74216. * Adds a new size gradient
  74217. * @param gradient defines the gradient to use (between 0 and 1)
  74218. * @param factor defines the size factor to affect to the specified gradient
  74219. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74220. * @returns the current particle system
  74221. */
  74222. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74223. /**
  74224. * Remove a specific size gradient
  74225. * @param gradient defines the gradient to remove
  74226. * @returns the current particle system
  74227. */
  74228. removeSizeGradient(gradient: number): IParticleSystem;
  74229. /**
  74230. * Adds a new color remap gradient
  74231. * @param gradient defines the gradient to use (between 0 and 1)
  74232. * @param min defines the color remap minimal range
  74233. * @param max defines the color remap maximal range
  74234. * @returns the current particle system
  74235. */
  74236. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74237. /**
  74238. * Remove a specific color remap gradient
  74239. * @param gradient defines the gradient to remove
  74240. * @returns the current particle system
  74241. */
  74242. removeColorRemapGradient(gradient: number): IParticleSystem;
  74243. /**
  74244. * Adds a new alpha remap gradient
  74245. * @param gradient defines the gradient to use (between 0 and 1)
  74246. * @param min defines the alpha remap minimal range
  74247. * @param max defines the alpha remap maximal range
  74248. * @returns the current particle system
  74249. */
  74250. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74251. /**
  74252. * Remove a specific alpha remap gradient
  74253. * @param gradient defines the gradient to remove
  74254. * @returns the current particle system
  74255. */
  74256. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  74257. /**
  74258. * Adds a new angular speed gradient
  74259. * @param gradient defines the gradient to use (between 0 and 1)
  74260. * @param factor defines the angular speed to affect to the specified gradient
  74261. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74262. * @returns the current particle system
  74263. */
  74264. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74265. /**
  74266. * Remove a specific angular speed gradient
  74267. * @param gradient defines the gradient to remove
  74268. * @returns the current particle system
  74269. */
  74270. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  74271. /**
  74272. * Adds a new velocity gradient
  74273. * @param gradient defines the gradient to use (between 0 and 1)
  74274. * @param factor defines the velocity to affect to the specified gradient
  74275. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74276. * @returns the current particle system
  74277. */
  74278. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74279. /**
  74280. * Remove a specific velocity gradient
  74281. * @param gradient defines the gradient to remove
  74282. * @returns the current particle system
  74283. */
  74284. removeVelocityGradient(gradient: number): IParticleSystem;
  74285. /**
  74286. * Adds a new limit velocity gradient
  74287. * @param gradient defines the gradient to use (between 0 and 1)
  74288. * @param factor defines the limit velocity value to affect to the specified gradient
  74289. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74290. * @returns the current particle system
  74291. */
  74292. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74293. /**
  74294. * Remove a specific limit velocity gradient
  74295. * @param gradient defines the gradient to remove
  74296. * @returns the current particle system
  74297. */
  74298. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  74299. /**
  74300. * Adds a new drag gradient
  74301. * @param gradient defines the gradient to use (between 0 and 1)
  74302. * @param factor defines the drag value to affect to the specified gradient
  74303. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74304. * @returns the current particle system
  74305. */
  74306. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74307. /**
  74308. * Remove a specific drag gradient
  74309. * @param gradient defines the gradient to remove
  74310. * @returns the current particle system
  74311. */
  74312. removeDragGradient(gradient: number): IParticleSystem;
  74313. /**
  74314. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  74315. * @param gradient defines the gradient to use (between 0 and 1)
  74316. * @param factor defines the emit rate value to affect to the specified gradient
  74317. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74318. * @returns the current particle system
  74319. */
  74320. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74321. /**
  74322. * Remove a specific emit rate gradient
  74323. * @param gradient defines the gradient to remove
  74324. * @returns the current particle system
  74325. */
  74326. removeEmitRateGradient(gradient: number): IParticleSystem;
  74327. /**
  74328. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  74329. * @param gradient defines the gradient to use (between 0 and 1)
  74330. * @param factor defines the start size value to affect to the specified gradient
  74331. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74332. * @returns the current particle system
  74333. */
  74334. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74335. /**
  74336. * Remove a specific start size gradient
  74337. * @param gradient defines the gradient to remove
  74338. * @returns the current particle system
  74339. */
  74340. removeStartSizeGradient(gradient: number): IParticleSystem;
  74341. private _createRampGradientTexture;
  74342. /**
  74343. * Gets the current list of ramp gradients.
  74344. * You must use addRampGradient and removeRampGradient to udpate this list
  74345. * @returns the list of ramp gradients
  74346. */
  74347. getRampGradients(): Nullable<Array<Color3Gradient>>;
  74348. /**
  74349. * Adds a new ramp gradient used to remap particle colors
  74350. * @param gradient defines the gradient to use (between 0 and 1)
  74351. * @param color defines the color to affect to the specified gradient
  74352. * @returns the current particle system
  74353. */
  74354. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  74355. /**
  74356. * Remove a specific ramp gradient
  74357. * @param gradient defines the gradient to remove
  74358. * @returns the current particle system
  74359. */
  74360. removeRampGradient(gradient: number): ParticleSystem;
  74361. /**
  74362. * Adds a new color gradient
  74363. * @param gradient defines the gradient to use (between 0 and 1)
  74364. * @param color1 defines the color to affect to the specified gradient
  74365. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  74366. * @returns this particle system
  74367. */
  74368. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  74369. /**
  74370. * Remove a specific color gradient
  74371. * @param gradient defines the gradient to remove
  74372. * @returns this particle system
  74373. */
  74374. removeColorGradient(gradient: number): IParticleSystem;
  74375. private _fetchR;
  74376. protected _reset(): void;
  74377. private _resetEffect;
  74378. private _createVertexBuffers;
  74379. private _createIndexBuffer;
  74380. /**
  74381. * Gets the maximum number of particles active at the same time.
  74382. * @returns The max number of active particles.
  74383. */
  74384. getCapacity(): number;
  74385. /**
  74386. * Gets whether there are still active particles in the system.
  74387. * @returns True if it is alive, otherwise false.
  74388. */
  74389. isAlive(): boolean;
  74390. /**
  74391. * Gets if the system has been started. (Note: this will still be true after stop is called)
  74392. * @returns True if it has been started, otherwise false.
  74393. */
  74394. isStarted(): boolean;
  74395. private _prepareSubEmitterInternalArray;
  74396. /**
  74397. * Starts the particle system and begins to emit
  74398. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  74399. */
  74400. start(delay?: number): void;
  74401. /**
  74402. * Stops the particle system.
  74403. * @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.
  74404. */
  74405. stop(stopSubEmitters?: boolean): void;
  74406. /**
  74407. * Remove all active particles
  74408. */
  74409. reset(): void;
  74410. /**
  74411. * @hidden (for internal use only)
  74412. */
  74413. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  74414. /**
  74415. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  74416. * Its lifetime will start back at 0.
  74417. */
  74418. recycleParticle: (particle: Particle) => void;
  74419. private _stopSubEmitters;
  74420. private _createParticle;
  74421. private _removeFromRoot;
  74422. private _emitFromParticle;
  74423. private _update;
  74424. /** @hidden */
  74425. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  74426. /** @hidden */
  74427. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  74428. /** @hidden */
  74429. private _getEffect;
  74430. /**
  74431. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  74432. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  74433. */
  74434. animate(preWarmOnly?: boolean): void;
  74435. private _appendParticleVertices;
  74436. /**
  74437. * Rebuilds the particle system.
  74438. */
  74439. rebuild(): void;
  74440. /**
  74441. * Is this system ready to be used/rendered
  74442. * @return true if the system is ready
  74443. */
  74444. isReady(): boolean;
  74445. private _render;
  74446. /**
  74447. * Renders the particle system in its current state.
  74448. * @returns the current number of particles
  74449. */
  74450. render(): number;
  74451. /**
  74452. * Disposes the particle system and free the associated resources
  74453. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  74454. */
  74455. dispose(disposeTexture?: boolean): void;
  74456. /**
  74457. * Clones the particle system.
  74458. * @param name The name of the cloned object
  74459. * @param newEmitter The new emitter to use
  74460. * @returns the cloned particle system
  74461. */
  74462. clone(name: string, newEmitter: any): ParticleSystem;
  74463. /**
  74464. * Serializes the particle system to a JSON object.
  74465. * @returns the JSON object
  74466. */
  74467. serialize(): any;
  74468. /** @hidden */
  74469. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  74470. /** @hidden */
  74471. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  74472. /**
  74473. * Parses a JSON object to create a particle system.
  74474. * @param parsedParticleSystem The JSON object to parse
  74475. * @param scene The scene to create the particle system in
  74476. * @param rootUrl The root url to use to load external dependencies like texture
  74477. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  74478. * @returns the Parsed particle system
  74479. */
  74480. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  74481. }
  74482. }
  74483. declare module BABYLON {
  74484. /**
  74485. * A particle represents one of the element emitted by a particle system.
  74486. * This is mainly define by its coordinates, direction, velocity and age.
  74487. */
  74488. export class Particle {
  74489. /**
  74490. * The particle system the particle belongs to.
  74491. */
  74492. particleSystem: ParticleSystem;
  74493. private static _Count;
  74494. /**
  74495. * Unique ID of the particle
  74496. */
  74497. id: number;
  74498. /**
  74499. * The world position of the particle in the scene.
  74500. */
  74501. position: Vector3;
  74502. /**
  74503. * The world direction of the particle in the scene.
  74504. */
  74505. direction: Vector3;
  74506. /**
  74507. * The color of the particle.
  74508. */
  74509. color: Color4;
  74510. /**
  74511. * The color change of the particle per step.
  74512. */
  74513. colorStep: Color4;
  74514. /**
  74515. * Defines how long will the life of the particle be.
  74516. */
  74517. lifeTime: number;
  74518. /**
  74519. * The current age of the particle.
  74520. */
  74521. age: number;
  74522. /**
  74523. * The current size of the particle.
  74524. */
  74525. size: number;
  74526. /**
  74527. * The current scale of the particle.
  74528. */
  74529. scale: Vector2;
  74530. /**
  74531. * The current angle of the particle.
  74532. */
  74533. angle: number;
  74534. /**
  74535. * Defines how fast is the angle changing.
  74536. */
  74537. angularSpeed: number;
  74538. /**
  74539. * Defines the cell index used by the particle to be rendered from a sprite.
  74540. */
  74541. cellIndex: number;
  74542. /**
  74543. * The information required to support color remapping
  74544. */
  74545. remapData: Vector4;
  74546. /** @hidden */
  74547. _randomCellOffset?: number;
  74548. /** @hidden */
  74549. _initialDirection: Nullable<Vector3>;
  74550. /** @hidden */
  74551. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  74552. /** @hidden */
  74553. _initialStartSpriteCellID: number;
  74554. /** @hidden */
  74555. _initialEndSpriteCellID: number;
  74556. /** @hidden */
  74557. _currentColorGradient: Nullable<ColorGradient>;
  74558. /** @hidden */
  74559. _currentColor1: Color4;
  74560. /** @hidden */
  74561. _currentColor2: Color4;
  74562. /** @hidden */
  74563. _currentSizeGradient: Nullable<FactorGradient>;
  74564. /** @hidden */
  74565. _currentSize1: number;
  74566. /** @hidden */
  74567. _currentSize2: number;
  74568. /** @hidden */
  74569. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  74570. /** @hidden */
  74571. _currentAngularSpeed1: number;
  74572. /** @hidden */
  74573. _currentAngularSpeed2: number;
  74574. /** @hidden */
  74575. _currentVelocityGradient: Nullable<FactorGradient>;
  74576. /** @hidden */
  74577. _currentVelocity1: number;
  74578. /** @hidden */
  74579. _currentVelocity2: number;
  74580. /** @hidden */
  74581. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  74582. /** @hidden */
  74583. _currentLimitVelocity1: number;
  74584. /** @hidden */
  74585. _currentLimitVelocity2: number;
  74586. /** @hidden */
  74587. _currentDragGradient: Nullable<FactorGradient>;
  74588. /** @hidden */
  74589. _currentDrag1: number;
  74590. /** @hidden */
  74591. _currentDrag2: number;
  74592. /** @hidden */
  74593. _randomNoiseCoordinates1: Vector3;
  74594. /** @hidden */
  74595. _randomNoiseCoordinates2: Vector3;
  74596. /**
  74597. * Creates a new instance Particle
  74598. * @param particleSystem the particle system the particle belongs to
  74599. */
  74600. constructor(
  74601. /**
  74602. * The particle system the particle belongs to.
  74603. */
  74604. particleSystem: ParticleSystem);
  74605. private updateCellInfoFromSystem;
  74606. /**
  74607. * Defines how the sprite cell index is updated for the particle
  74608. */
  74609. updateCellIndex(): void;
  74610. /** @hidden */
  74611. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  74612. /** @hidden */
  74613. _inheritParticleInfoToSubEmitters(): void;
  74614. /** @hidden */
  74615. _reset(): void;
  74616. /**
  74617. * Copy the properties of particle to another one.
  74618. * @param other the particle to copy the information to.
  74619. */
  74620. copyTo(other: Particle): void;
  74621. }
  74622. }
  74623. declare module BABYLON {
  74624. /**
  74625. * Particle emitter represents a volume emitting particles.
  74626. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  74627. */
  74628. export interface IParticleEmitterType {
  74629. /**
  74630. * Called by the particle System when the direction is computed for the created particle.
  74631. * @param worldMatrix is the world matrix of the particle system
  74632. * @param directionToUpdate is the direction vector to update with the result
  74633. * @param particle is the particle we are computed the direction for
  74634. */
  74635. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74636. /**
  74637. * Called by the particle System when the position is computed for the created particle.
  74638. * @param worldMatrix is the world matrix of the particle system
  74639. * @param positionToUpdate is the position vector to update with the result
  74640. * @param particle is the particle we are computed the position for
  74641. */
  74642. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74643. /**
  74644. * Clones the current emitter and returns a copy of it
  74645. * @returns the new emitter
  74646. */
  74647. clone(): IParticleEmitterType;
  74648. /**
  74649. * Called by the GPUParticleSystem to setup the update shader
  74650. * @param effect defines the update shader
  74651. */
  74652. applyToShader(effect: Effect): void;
  74653. /**
  74654. * Returns a string to use to update the GPU particles update shader
  74655. * @returns the effect defines string
  74656. */
  74657. getEffectDefines(): string;
  74658. /**
  74659. * Returns a string representing the class name
  74660. * @returns a string containing the class name
  74661. */
  74662. getClassName(): string;
  74663. /**
  74664. * Serializes the particle system to a JSON object.
  74665. * @returns the JSON object
  74666. */
  74667. serialize(): any;
  74668. /**
  74669. * Parse properties from a JSON object
  74670. * @param serializationObject defines the JSON object
  74671. */
  74672. parse(serializationObject: any): void;
  74673. }
  74674. }
  74675. declare module BABYLON {
  74676. /**
  74677. * Particle emitter emitting particles from the inside of a box.
  74678. * It emits the particles randomly between 2 given directions.
  74679. */
  74680. export class BoxParticleEmitter implements IParticleEmitterType {
  74681. /**
  74682. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74683. */
  74684. direction1: Vector3;
  74685. /**
  74686. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74687. */
  74688. direction2: Vector3;
  74689. /**
  74690. * 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.
  74691. */
  74692. minEmitBox: Vector3;
  74693. /**
  74694. * 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.
  74695. */
  74696. maxEmitBox: Vector3;
  74697. /**
  74698. * Creates a new instance BoxParticleEmitter
  74699. */
  74700. constructor();
  74701. /**
  74702. * Called by the particle System when the direction is computed for the created particle.
  74703. * @param worldMatrix is the world matrix of the particle system
  74704. * @param directionToUpdate is the direction vector to update with the result
  74705. * @param particle is the particle we are computed the direction for
  74706. */
  74707. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74708. /**
  74709. * Called by the particle System when the position is computed for the created particle.
  74710. * @param worldMatrix is the world matrix of the particle system
  74711. * @param positionToUpdate is the position vector to update with the result
  74712. * @param particle is the particle we are computed the position for
  74713. */
  74714. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74715. /**
  74716. * Clones the current emitter and returns a copy of it
  74717. * @returns the new emitter
  74718. */
  74719. clone(): BoxParticleEmitter;
  74720. /**
  74721. * Called by the GPUParticleSystem to setup the update shader
  74722. * @param effect defines the update shader
  74723. */
  74724. applyToShader(effect: Effect): void;
  74725. /**
  74726. * Returns a string to use to update the GPU particles update shader
  74727. * @returns a string containng the defines string
  74728. */
  74729. getEffectDefines(): string;
  74730. /**
  74731. * Returns the string "BoxParticleEmitter"
  74732. * @returns a string containing the class name
  74733. */
  74734. getClassName(): string;
  74735. /**
  74736. * Serializes the particle system to a JSON object.
  74737. * @returns the JSON object
  74738. */
  74739. serialize(): any;
  74740. /**
  74741. * Parse properties from a JSON object
  74742. * @param serializationObject defines the JSON object
  74743. */
  74744. parse(serializationObject: any): void;
  74745. }
  74746. }
  74747. declare module BABYLON {
  74748. /**
  74749. * Particle emitter emitting particles from the inside of a cone.
  74750. * It emits the particles alongside the cone volume from the base to the particle.
  74751. * The emission direction might be randomized.
  74752. */
  74753. export class ConeParticleEmitter implements IParticleEmitterType {
  74754. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  74755. directionRandomizer: number;
  74756. private _radius;
  74757. private _angle;
  74758. private _height;
  74759. /**
  74760. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  74761. */
  74762. radiusRange: number;
  74763. /**
  74764. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  74765. */
  74766. heightRange: number;
  74767. /**
  74768. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  74769. */
  74770. emitFromSpawnPointOnly: boolean;
  74771. /**
  74772. * Gets or sets the radius of the emission cone
  74773. */
  74774. radius: number;
  74775. /**
  74776. * Gets or sets the angle of the emission cone
  74777. */
  74778. angle: number;
  74779. private _buildHeight;
  74780. /**
  74781. * Creates a new instance ConeParticleEmitter
  74782. * @param radius the radius of the emission cone (1 by default)
  74783. * @param angle the cone base angle (PI by default)
  74784. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  74785. */
  74786. constructor(radius?: number, angle?: number,
  74787. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  74788. directionRandomizer?: number);
  74789. /**
  74790. * Called by the particle System when the direction is computed for the created particle.
  74791. * @param worldMatrix is the world matrix of the particle system
  74792. * @param directionToUpdate is the direction vector to update with the result
  74793. * @param particle is the particle we are computed the direction for
  74794. */
  74795. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74796. /**
  74797. * Called by the particle System when the position is computed for the created particle.
  74798. * @param worldMatrix is the world matrix of the particle system
  74799. * @param positionToUpdate is the position vector to update with the result
  74800. * @param particle is the particle we are computed the position for
  74801. */
  74802. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74803. /**
  74804. * Clones the current emitter and returns a copy of it
  74805. * @returns the new emitter
  74806. */
  74807. clone(): ConeParticleEmitter;
  74808. /**
  74809. * Called by the GPUParticleSystem to setup the update shader
  74810. * @param effect defines the update shader
  74811. */
  74812. applyToShader(effect: Effect): void;
  74813. /**
  74814. * Returns a string to use to update the GPU particles update shader
  74815. * @returns a string containng the defines string
  74816. */
  74817. getEffectDefines(): string;
  74818. /**
  74819. * Returns the string "ConeParticleEmitter"
  74820. * @returns a string containing the class name
  74821. */
  74822. getClassName(): string;
  74823. /**
  74824. * Serializes the particle system to a JSON object.
  74825. * @returns the JSON object
  74826. */
  74827. serialize(): any;
  74828. /**
  74829. * Parse properties from a JSON object
  74830. * @param serializationObject defines the JSON object
  74831. */
  74832. parse(serializationObject: any): void;
  74833. }
  74834. }
  74835. declare module BABYLON {
  74836. /**
  74837. * Particle emitter emitting particles from the inside of a cylinder.
  74838. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  74839. */
  74840. export class CylinderParticleEmitter implements IParticleEmitterType {
  74841. /**
  74842. * The radius of the emission cylinder.
  74843. */
  74844. radius: number;
  74845. /**
  74846. * The height of the emission cylinder.
  74847. */
  74848. height: number;
  74849. /**
  74850. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74851. */
  74852. radiusRange: number;
  74853. /**
  74854. * How much to randomize the particle direction [0-1].
  74855. */
  74856. directionRandomizer: number;
  74857. /**
  74858. * Creates a new instance CylinderParticleEmitter
  74859. * @param radius the radius of the emission cylinder (1 by default)
  74860. * @param height the height of the emission cylinder (1 by default)
  74861. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74862. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74863. */
  74864. constructor(
  74865. /**
  74866. * The radius of the emission cylinder.
  74867. */
  74868. radius?: number,
  74869. /**
  74870. * The height of the emission cylinder.
  74871. */
  74872. height?: number,
  74873. /**
  74874. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74875. */
  74876. radiusRange?: number,
  74877. /**
  74878. * How much to randomize the particle direction [0-1].
  74879. */
  74880. directionRandomizer?: number);
  74881. /**
  74882. * Called by the particle System when the direction is computed for the created particle.
  74883. * @param worldMatrix is the world matrix of the particle system
  74884. * @param directionToUpdate is the direction vector to update with the result
  74885. * @param particle is the particle we are computed the direction for
  74886. */
  74887. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74888. /**
  74889. * Called by the particle System when the position is computed for the created particle.
  74890. * @param worldMatrix is the world matrix of the particle system
  74891. * @param positionToUpdate is the position vector to update with the result
  74892. * @param particle is the particle we are computed the position for
  74893. */
  74894. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74895. /**
  74896. * Clones the current emitter and returns a copy of it
  74897. * @returns the new emitter
  74898. */
  74899. clone(): CylinderParticleEmitter;
  74900. /**
  74901. * Called by the GPUParticleSystem to setup the update shader
  74902. * @param effect defines the update shader
  74903. */
  74904. applyToShader(effect: Effect): void;
  74905. /**
  74906. * Returns a string to use to update the GPU particles update shader
  74907. * @returns a string containng the defines string
  74908. */
  74909. getEffectDefines(): string;
  74910. /**
  74911. * Returns the string "CylinderParticleEmitter"
  74912. * @returns a string containing the class name
  74913. */
  74914. getClassName(): string;
  74915. /**
  74916. * Serializes the particle system to a JSON object.
  74917. * @returns the JSON object
  74918. */
  74919. serialize(): any;
  74920. /**
  74921. * Parse properties from a JSON object
  74922. * @param serializationObject defines the JSON object
  74923. */
  74924. parse(serializationObject: any): void;
  74925. }
  74926. /**
  74927. * Particle emitter emitting particles from the inside of a cylinder.
  74928. * It emits the particles randomly between two vectors.
  74929. */
  74930. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  74931. /**
  74932. * The min limit of the emission direction.
  74933. */
  74934. direction1: Vector3;
  74935. /**
  74936. * The max limit of the emission direction.
  74937. */
  74938. direction2: Vector3;
  74939. /**
  74940. * Creates a new instance CylinderDirectedParticleEmitter
  74941. * @param radius the radius of the emission cylinder (1 by default)
  74942. * @param height the height of the emission cylinder (1 by default)
  74943. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74944. * @param direction1 the min limit of the emission direction (up vector by default)
  74945. * @param direction2 the max limit of the emission direction (up vector by default)
  74946. */
  74947. constructor(radius?: number, height?: number, radiusRange?: number,
  74948. /**
  74949. * The min limit of the emission direction.
  74950. */
  74951. direction1?: Vector3,
  74952. /**
  74953. * The max limit of the emission direction.
  74954. */
  74955. direction2?: Vector3);
  74956. /**
  74957. * Called by the particle System when the direction is computed for the created particle.
  74958. * @param worldMatrix is the world matrix of the particle system
  74959. * @param directionToUpdate is the direction vector to update with the result
  74960. * @param particle is the particle we are computed the direction for
  74961. */
  74962. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74963. /**
  74964. * Clones the current emitter and returns a copy of it
  74965. * @returns the new emitter
  74966. */
  74967. clone(): CylinderDirectedParticleEmitter;
  74968. /**
  74969. * Called by the GPUParticleSystem to setup the update shader
  74970. * @param effect defines the update shader
  74971. */
  74972. applyToShader(effect: Effect): void;
  74973. /**
  74974. * Returns a string to use to update the GPU particles update shader
  74975. * @returns a string containng the defines string
  74976. */
  74977. getEffectDefines(): string;
  74978. /**
  74979. * Returns the string "CylinderDirectedParticleEmitter"
  74980. * @returns a string containing the class name
  74981. */
  74982. getClassName(): string;
  74983. /**
  74984. * Serializes the particle system to a JSON object.
  74985. * @returns the JSON object
  74986. */
  74987. serialize(): any;
  74988. /**
  74989. * Parse properties from a JSON object
  74990. * @param serializationObject defines the JSON object
  74991. */
  74992. parse(serializationObject: any): void;
  74993. }
  74994. }
  74995. declare module BABYLON {
  74996. /**
  74997. * Particle emitter emitting particles from the inside of a hemisphere.
  74998. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  74999. */
  75000. export class HemisphericParticleEmitter implements IParticleEmitterType {
  75001. /**
  75002. * The radius of the emission hemisphere.
  75003. */
  75004. radius: number;
  75005. /**
  75006. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75007. */
  75008. radiusRange: number;
  75009. /**
  75010. * How much to randomize the particle direction [0-1].
  75011. */
  75012. directionRandomizer: number;
  75013. /**
  75014. * Creates a new instance HemisphericParticleEmitter
  75015. * @param radius the radius of the emission hemisphere (1 by default)
  75016. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75017. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75018. */
  75019. constructor(
  75020. /**
  75021. * The radius of the emission hemisphere.
  75022. */
  75023. radius?: number,
  75024. /**
  75025. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75026. */
  75027. radiusRange?: number,
  75028. /**
  75029. * How much to randomize the particle direction [0-1].
  75030. */
  75031. directionRandomizer?: number);
  75032. /**
  75033. * Called by the particle System when the direction is computed for the created particle.
  75034. * @param worldMatrix is the world matrix of the particle system
  75035. * @param directionToUpdate is the direction vector to update with the result
  75036. * @param particle is the particle we are computed the direction for
  75037. */
  75038. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75039. /**
  75040. * Called by the particle System when the position is computed for the created particle.
  75041. * @param worldMatrix is the world matrix of the particle system
  75042. * @param positionToUpdate is the position vector to update with the result
  75043. * @param particle is the particle we are computed the position for
  75044. */
  75045. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75046. /**
  75047. * Clones the current emitter and returns a copy of it
  75048. * @returns the new emitter
  75049. */
  75050. clone(): HemisphericParticleEmitter;
  75051. /**
  75052. * Called by the GPUParticleSystem to setup the update shader
  75053. * @param effect defines the update shader
  75054. */
  75055. applyToShader(effect: Effect): void;
  75056. /**
  75057. * Returns a string to use to update the GPU particles update shader
  75058. * @returns a string containng the defines string
  75059. */
  75060. getEffectDefines(): string;
  75061. /**
  75062. * Returns the string "HemisphericParticleEmitter"
  75063. * @returns a string containing the class name
  75064. */
  75065. getClassName(): string;
  75066. /**
  75067. * Serializes the particle system to a JSON object.
  75068. * @returns the JSON object
  75069. */
  75070. serialize(): any;
  75071. /**
  75072. * Parse properties from a JSON object
  75073. * @param serializationObject defines the JSON object
  75074. */
  75075. parse(serializationObject: any): void;
  75076. }
  75077. }
  75078. declare module BABYLON {
  75079. /**
  75080. * Particle emitter emitting particles from a point.
  75081. * It emits the particles randomly between 2 given directions.
  75082. */
  75083. export class PointParticleEmitter implements IParticleEmitterType {
  75084. /**
  75085. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75086. */
  75087. direction1: Vector3;
  75088. /**
  75089. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75090. */
  75091. direction2: Vector3;
  75092. /**
  75093. * Creates a new instance PointParticleEmitter
  75094. */
  75095. constructor();
  75096. /**
  75097. * Called by the particle System when the direction is computed for the created particle.
  75098. * @param worldMatrix is the world matrix of the particle system
  75099. * @param directionToUpdate is the direction vector to update with the result
  75100. * @param particle is the particle we are computed the direction for
  75101. */
  75102. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75103. /**
  75104. * Called by the particle System when the position is computed for the created particle.
  75105. * @param worldMatrix is the world matrix of the particle system
  75106. * @param positionToUpdate is the position vector to update with the result
  75107. * @param particle is the particle we are computed the position for
  75108. */
  75109. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75110. /**
  75111. * Clones the current emitter and returns a copy of it
  75112. * @returns the new emitter
  75113. */
  75114. clone(): PointParticleEmitter;
  75115. /**
  75116. * Called by the GPUParticleSystem to setup the update shader
  75117. * @param effect defines the update shader
  75118. */
  75119. applyToShader(effect: Effect): void;
  75120. /**
  75121. * Returns a string to use to update the GPU particles update shader
  75122. * @returns a string containng the defines string
  75123. */
  75124. getEffectDefines(): string;
  75125. /**
  75126. * Returns the string "PointParticleEmitter"
  75127. * @returns a string containing the class name
  75128. */
  75129. getClassName(): string;
  75130. /**
  75131. * Serializes the particle system to a JSON object.
  75132. * @returns the JSON object
  75133. */
  75134. serialize(): any;
  75135. /**
  75136. * Parse properties from a JSON object
  75137. * @param serializationObject defines the JSON object
  75138. */
  75139. parse(serializationObject: any): void;
  75140. }
  75141. }
  75142. declare module BABYLON {
  75143. /**
  75144. * Particle emitter emitting particles from the inside of a sphere.
  75145. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  75146. */
  75147. export class SphereParticleEmitter implements IParticleEmitterType {
  75148. /**
  75149. * The radius of the emission sphere.
  75150. */
  75151. radius: number;
  75152. /**
  75153. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75154. */
  75155. radiusRange: number;
  75156. /**
  75157. * How much to randomize the particle direction [0-1].
  75158. */
  75159. directionRandomizer: number;
  75160. /**
  75161. * Creates a new instance SphereParticleEmitter
  75162. * @param radius the radius of the emission sphere (1 by default)
  75163. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75164. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75165. */
  75166. constructor(
  75167. /**
  75168. * The radius of the emission sphere.
  75169. */
  75170. radius?: number,
  75171. /**
  75172. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75173. */
  75174. radiusRange?: number,
  75175. /**
  75176. * How much to randomize the particle direction [0-1].
  75177. */
  75178. directionRandomizer?: number);
  75179. /**
  75180. * Called by the particle System when the direction is computed for the created particle.
  75181. * @param worldMatrix is the world matrix of the particle system
  75182. * @param directionToUpdate is the direction vector to update with the result
  75183. * @param particle is the particle we are computed the direction for
  75184. */
  75185. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75186. /**
  75187. * Called by the particle System when the position is computed for the created particle.
  75188. * @param worldMatrix is the world matrix of the particle system
  75189. * @param positionToUpdate is the position vector to update with the result
  75190. * @param particle is the particle we are computed the position for
  75191. */
  75192. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75193. /**
  75194. * Clones the current emitter and returns a copy of it
  75195. * @returns the new emitter
  75196. */
  75197. clone(): SphereParticleEmitter;
  75198. /**
  75199. * Called by the GPUParticleSystem to setup the update shader
  75200. * @param effect defines the update shader
  75201. */
  75202. applyToShader(effect: Effect): void;
  75203. /**
  75204. * Returns a string to use to update the GPU particles update shader
  75205. * @returns a string containng the defines string
  75206. */
  75207. getEffectDefines(): string;
  75208. /**
  75209. * Returns the string "SphereParticleEmitter"
  75210. * @returns a string containing the class name
  75211. */
  75212. getClassName(): string;
  75213. /**
  75214. * Serializes the particle system to a JSON object.
  75215. * @returns the JSON object
  75216. */
  75217. serialize(): any;
  75218. /**
  75219. * Parse properties from a JSON object
  75220. * @param serializationObject defines the JSON object
  75221. */
  75222. parse(serializationObject: any): void;
  75223. }
  75224. /**
  75225. * Particle emitter emitting particles from the inside of a sphere.
  75226. * It emits the particles randomly between two vectors.
  75227. */
  75228. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  75229. /**
  75230. * The min limit of the emission direction.
  75231. */
  75232. direction1: Vector3;
  75233. /**
  75234. * The max limit of the emission direction.
  75235. */
  75236. direction2: Vector3;
  75237. /**
  75238. * Creates a new instance SphereDirectedParticleEmitter
  75239. * @param radius the radius of the emission sphere (1 by default)
  75240. * @param direction1 the min limit of the emission direction (up vector by default)
  75241. * @param direction2 the max limit of the emission direction (up vector by default)
  75242. */
  75243. constructor(radius?: number,
  75244. /**
  75245. * The min limit of the emission direction.
  75246. */
  75247. direction1?: Vector3,
  75248. /**
  75249. * The max limit of the emission direction.
  75250. */
  75251. direction2?: Vector3);
  75252. /**
  75253. * Called by the particle System when the direction is computed for the created particle.
  75254. * @param worldMatrix is the world matrix of the particle system
  75255. * @param directionToUpdate is the direction vector to update with the result
  75256. * @param particle is the particle we are computed the direction for
  75257. */
  75258. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75259. /**
  75260. * Clones the current emitter and returns a copy of it
  75261. * @returns the new emitter
  75262. */
  75263. clone(): SphereDirectedParticleEmitter;
  75264. /**
  75265. * Called by the GPUParticleSystem to setup the update shader
  75266. * @param effect defines the update shader
  75267. */
  75268. applyToShader(effect: Effect): void;
  75269. /**
  75270. * Returns a string to use to update the GPU particles update shader
  75271. * @returns a string containng the defines string
  75272. */
  75273. getEffectDefines(): string;
  75274. /**
  75275. * Returns the string "SphereDirectedParticleEmitter"
  75276. * @returns a string containing the class name
  75277. */
  75278. getClassName(): string;
  75279. /**
  75280. * Serializes the particle system to a JSON object.
  75281. * @returns the JSON object
  75282. */
  75283. serialize(): any;
  75284. /**
  75285. * Parse properties from a JSON object
  75286. * @param serializationObject defines the JSON object
  75287. */
  75288. parse(serializationObject: any): void;
  75289. }
  75290. }
  75291. declare module BABYLON {
  75292. /**
  75293. * Interface representing a particle system in Babylon.js.
  75294. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  75295. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  75296. */
  75297. export interface IParticleSystem {
  75298. /**
  75299. * List of animations used by the particle system.
  75300. */
  75301. animations: Animation[];
  75302. /**
  75303. * The id of the Particle system.
  75304. */
  75305. id: string;
  75306. /**
  75307. * The name of the Particle system.
  75308. */
  75309. name: string;
  75310. /**
  75311. * The emitter represents the Mesh or position we are attaching the particle system to.
  75312. */
  75313. emitter: Nullable<AbstractMesh | Vector3>;
  75314. /**
  75315. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  75316. */
  75317. isBillboardBased: boolean;
  75318. /**
  75319. * The rendering group used by the Particle system to chose when to render.
  75320. */
  75321. renderingGroupId: number;
  75322. /**
  75323. * The layer mask we are rendering the particles through.
  75324. */
  75325. layerMask: number;
  75326. /**
  75327. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  75328. */
  75329. updateSpeed: number;
  75330. /**
  75331. * The amount of time the particle system is running (depends of the overall update speed).
  75332. */
  75333. targetStopDuration: number;
  75334. /**
  75335. * The texture used to render each particle. (this can be a spritesheet)
  75336. */
  75337. particleTexture: Nullable<Texture>;
  75338. /**
  75339. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  75340. */
  75341. blendMode: number;
  75342. /**
  75343. * Minimum life time of emitting particles.
  75344. */
  75345. minLifeTime: number;
  75346. /**
  75347. * Maximum life time of emitting particles.
  75348. */
  75349. maxLifeTime: number;
  75350. /**
  75351. * Minimum Size of emitting particles.
  75352. */
  75353. minSize: number;
  75354. /**
  75355. * Maximum Size of emitting particles.
  75356. */
  75357. maxSize: number;
  75358. /**
  75359. * Minimum scale of emitting particles on X axis.
  75360. */
  75361. minScaleX: number;
  75362. /**
  75363. * Maximum scale of emitting particles on X axis.
  75364. */
  75365. maxScaleX: number;
  75366. /**
  75367. * Minimum scale of emitting particles on Y axis.
  75368. */
  75369. minScaleY: number;
  75370. /**
  75371. * Maximum scale of emitting particles on Y axis.
  75372. */
  75373. maxScaleY: number;
  75374. /**
  75375. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  75376. */
  75377. color1: Color4;
  75378. /**
  75379. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  75380. */
  75381. color2: Color4;
  75382. /**
  75383. * Color the particle will have at the end of its lifetime.
  75384. */
  75385. colorDead: Color4;
  75386. /**
  75387. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  75388. */
  75389. emitRate: number;
  75390. /**
  75391. * You can use gravity if you want to give an orientation to your particles.
  75392. */
  75393. gravity: Vector3;
  75394. /**
  75395. * Minimum power of emitting particles.
  75396. */
  75397. minEmitPower: number;
  75398. /**
  75399. * Maximum power of emitting particles.
  75400. */
  75401. maxEmitPower: number;
  75402. /**
  75403. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  75404. */
  75405. minAngularSpeed: number;
  75406. /**
  75407. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  75408. */
  75409. maxAngularSpeed: number;
  75410. /**
  75411. * Gets or sets the minimal initial rotation in radians.
  75412. */
  75413. minInitialRotation: number;
  75414. /**
  75415. * Gets or sets the maximal initial rotation in radians.
  75416. */
  75417. maxInitialRotation: number;
  75418. /**
  75419. * The particle emitter type defines the emitter used by the particle system.
  75420. * It can be for example box, sphere, or cone...
  75421. */
  75422. particleEmitterType: Nullable<IParticleEmitterType>;
  75423. /**
  75424. * Defines the delay in milliseconds before starting the system (0 by default)
  75425. */
  75426. startDelay: number;
  75427. /**
  75428. * 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
  75429. */
  75430. preWarmCycles: number;
  75431. /**
  75432. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  75433. */
  75434. preWarmStepOffset: number;
  75435. /**
  75436. * 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)
  75437. */
  75438. spriteCellChangeSpeed: number;
  75439. /**
  75440. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  75441. */
  75442. startSpriteCellID: number;
  75443. /**
  75444. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  75445. */
  75446. endSpriteCellID: number;
  75447. /**
  75448. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  75449. */
  75450. spriteCellWidth: number;
  75451. /**
  75452. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  75453. */
  75454. spriteCellHeight: number;
  75455. /**
  75456. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  75457. */
  75458. spriteRandomStartCell: boolean;
  75459. /**
  75460. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  75461. */
  75462. isAnimationSheetEnabled: boolean;
  75463. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  75464. translationPivot: Vector2;
  75465. /**
  75466. * Gets or sets a texture used to add random noise to particle positions
  75467. */
  75468. noiseTexture: Nullable<BaseTexture>;
  75469. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  75470. noiseStrength: Vector3;
  75471. /**
  75472. * Gets or sets the billboard mode to use when isBillboardBased = true.
  75473. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  75474. */
  75475. billboardMode: number;
  75476. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  75477. limitVelocityDamping: number;
  75478. /**
  75479. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  75480. */
  75481. beginAnimationOnStart: boolean;
  75482. /**
  75483. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  75484. */
  75485. beginAnimationFrom: number;
  75486. /**
  75487. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  75488. */
  75489. beginAnimationTo: number;
  75490. /**
  75491. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  75492. */
  75493. beginAnimationLoop: boolean;
  75494. /**
  75495. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  75496. */
  75497. disposeOnStop: boolean;
  75498. /**
  75499. * Gets the maximum number of particles active at the same time.
  75500. * @returns The max number of active particles.
  75501. */
  75502. getCapacity(): number;
  75503. /**
  75504. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75505. * @returns True if it has been started, otherwise false.
  75506. */
  75507. isStarted(): boolean;
  75508. /**
  75509. * Animates the particle system for this frame.
  75510. */
  75511. animate(): void;
  75512. /**
  75513. * Renders the particle system in its current state.
  75514. * @returns the current number of particles
  75515. */
  75516. render(): number;
  75517. /**
  75518. * Dispose the particle system and frees its associated resources.
  75519. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  75520. */
  75521. dispose(disposeTexture?: boolean): void;
  75522. /**
  75523. * Clones the particle system.
  75524. * @param name The name of the cloned object
  75525. * @param newEmitter The new emitter to use
  75526. * @returns the cloned particle system
  75527. */
  75528. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  75529. /**
  75530. * Serializes the particle system to a JSON object.
  75531. * @returns the JSON object
  75532. */
  75533. serialize(): any;
  75534. /**
  75535. * Rebuild the particle system
  75536. */
  75537. rebuild(): void;
  75538. /**
  75539. * Starts the particle system and begins to emit
  75540. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  75541. */
  75542. start(delay?: number): void;
  75543. /**
  75544. * Stops the particle system.
  75545. */
  75546. stop(): void;
  75547. /**
  75548. * Remove all active particles
  75549. */
  75550. reset(): void;
  75551. /**
  75552. * Is this system ready to be used/rendered
  75553. * @return true if the system is ready
  75554. */
  75555. isReady(): boolean;
  75556. /**
  75557. * Adds a new color gradient
  75558. * @param gradient defines the gradient to use (between 0 and 1)
  75559. * @param color1 defines the color to affect to the specified gradient
  75560. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75561. * @returns the current particle system
  75562. */
  75563. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  75564. /**
  75565. * Remove a specific color gradient
  75566. * @param gradient defines the gradient to remove
  75567. * @returns the current particle system
  75568. */
  75569. removeColorGradient(gradient: number): IParticleSystem;
  75570. /**
  75571. * Adds a new size gradient
  75572. * @param gradient defines the gradient to use (between 0 and 1)
  75573. * @param factor defines the size factor to affect to the specified gradient
  75574. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75575. * @returns the current particle system
  75576. */
  75577. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75578. /**
  75579. * Remove a specific size gradient
  75580. * @param gradient defines the gradient to remove
  75581. * @returns the current particle system
  75582. */
  75583. removeSizeGradient(gradient: number): IParticleSystem;
  75584. /**
  75585. * Gets the current list of color gradients.
  75586. * You must use addColorGradient and removeColorGradient to udpate this list
  75587. * @returns the list of color gradients
  75588. */
  75589. getColorGradients(): Nullable<Array<ColorGradient>>;
  75590. /**
  75591. * Gets the current list of size gradients.
  75592. * You must use addSizeGradient and removeSizeGradient to udpate this list
  75593. * @returns the list of size gradients
  75594. */
  75595. getSizeGradients(): Nullable<Array<FactorGradient>>;
  75596. /**
  75597. * Gets the current list of angular speed gradients.
  75598. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  75599. * @returns the list of angular speed gradients
  75600. */
  75601. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  75602. /**
  75603. * Adds a new angular speed gradient
  75604. * @param gradient defines the gradient to use (between 0 and 1)
  75605. * @param factor defines the angular speed to affect to the specified gradient
  75606. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75607. * @returns the current particle system
  75608. */
  75609. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75610. /**
  75611. * Remove a specific angular speed gradient
  75612. * @param gradient defines the gradient to remove
  75613. * @returns the current particle system
  75614. */
  75615. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  75616. /**
  75617. * Gets the current list of velocity gradients.
  75618. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  75619. * @returns the list of velocity gradients
  75620. */
  75621. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  75622. /**
  75623. * Adds a new velocity gradient
  75624. * @param gradient defines the gradient to use (between 0 and 1)
  75625. * @param factor defines the velocity to affect to the specified gradient
  75626. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75627. * @returns the current particle system
  75628. */
  75629. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75630. /**
  75631. * Remove a specific velocity gradient
  75632. * @param gradient defines the gradient to remove
  75633. * @returns the current particle system
  75634. */
  75635. removeVelocityGradient(gradient: number): IParticleSystem;
  75636. /**
  75637. * Gets the current list of limit velocity gradients.
  75638. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  75639. * @returns the list of limit velocity gradients
  75640. */
  75641. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  75642. /**
  75643. * Adds a new limit velocity gradient
  75644. * @param gradient defines the gradient to use (between 0 and 1)
  75645. * @param factor defines the limit velocity to affect to the specified gradient
  75646. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75647. * @returns the current particle system
  75648. */
  75649. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75650. /**
  75651. * Remove a specific limit velocity gradient
  75652. * @param gradient defines the gradient to remove
  75653. * @returns the current particle system
  75654. */
  75655. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  75656. /**
  75657. * Adds a new drag gradient
  75658. * @param gradient defines the gradient to use (between 0 and 1)
  75659. * @param factor defines the drag to affect to the specified gradient
  75660. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75661. * @returns the current particle system
  75662. */
  75663. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75664. /**
  75665. * Remove a specific drag gradient
  75666. * @param gradient defines the gradient to remove
  75667. * @returns the current particle system
  75668. */
  75669. removeDragGradient(gradient: number): IParticleSystem;
  75670. /**
  75671. * Gets the current list of drag gradients.
  75672. * You must use addDragGradient and removeDragGradient to udpate this list
  75673. * @returns the list of drag gradients
  75674. */
  75675. getDragGradients(): Nullable<Array<FactorGradient>>;
  75676. /**
  75677. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  75678. * @param gradient defines the gradient to use (between 0 and 1)
  75679. * @param factor defines the emit rate to affect to the specified gradient
  75680. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75681. * @returns the current particle system
  75682. */
  75683. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75684. /**
  75685. * Remove a specific emit rate gradient
  75686. * @param gradient defines the gradient to remove
  75687. * @returns the current particle system
  75688. */
  75689. removeEmitRateGradient(gradient: number): IParticleSystem;
  75690. /**
  75691. * Gets the current list of emit rate gradients.
  75692. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  75693. * @returns the list of emit rate gradients
  75694. */
  75695. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  75696. /**
  75697. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  75698. * @param gradient defines the gradient to use (between 0 and 1)
  75699. * @param factor defines the start size to affect to the specified gradient
  75700. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75701. * @returns the current particle system
  75702. */
  75703. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75704. /**
  75705. * Remove a specific start size gradient
  75706. * @param gradient defines the gradient to remove
  75707. * @returns the current particle system
  75708. */
  75709. removeStartSizeGradient(gradient: number): IParticleSystem;
  75710. /**
  75711. * Gets the current list of start size gradients.
  75712. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  75713. * @returns the list of start size gradients
  75714. */
  75715. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  75716. /**
  75717. * Adds a new life time gradient
  75718. * @param gradient defines the gradient to use (between 0 and 1)
  75719. * @param factor defines the life time factor to affect to the specified gradient
  75720. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75721. * @returns the current particle system
  75722. */
  75723. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75724. /**
  75725. * Remove a specific life time gradient
  75726. * @param gradient defines the gradient to remove
  75727. * @returns the current particle system
  75728. */
  75729. removeLifeTimeGradient(gradient: number): IParticleSystem;
  75730. /**
  75731. * Gets the current list of life time gradients.
  75732. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  75733. * @returns the list of life time gradients
  75734. */
  75735. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  75736. /**
  75737. * Gets the current list of color gradients.
  75738. * You must use addColorGradient and removeColorGradient to udpate this list
  75739. * @returns the list of color gradients
  75740. */
  75741. getColorGradients(): Nullable<Array<ColorGradient>>;
  75742. /**
  75743. * Adds a new ramp gradient used to remap particle colors
  75744. * @param gradient defines the gradient to use (between 0 and 1)
  75745. * @param color defines the color to affect to the specified gradient
  75746. * @returns the current particle system
  75747. */
  75748. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  75749. /**
  75750. * Gets the current list of ramp gradients.
  75751. * You must use addRampGradient and removeRampGradient to udpate this list
  75752. * @returns the list of ramp gradients
  75753. */
  75754. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75755. /** Gets or sets a boolean indicating that ramp gradients must be used
  75756. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  75757. */
  75758. useRampGradients: boolean;
  75759. /**
  75760. * Adds a new color remap gradient
  75761. * @param gradient defines the gradient to use (between 0 and 1)
  75762. * @param min defines the color remap minimal range
  75763. * @param max defines the color remap maximal range
  75764. * @returns the current particle system
  75765. */
  75766. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75767. /**
  75768. * Gets the current list of color remap gradients.
  75769. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  75770. * @returns the list of color remap gradients
  75771. */
  75772. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  75773. /**
  75774. * Adds a new alpha remap gradient
  75775. * @param gradient defines the gradient to use (between 0 and 1)
  75776. * @param min defines the alpha remap minimal range
  75777. * @param max defines the alpha remap maximal range
  75778. * @returns the current particle system
  75779. */
  75780. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75781. /**
  75782. * Gets the current list of alpha remap gradients.
  75783. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  75784. * @returns the list of alpha remap gradients
  75785. */
  75786. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  75787. /**
  75788. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  75789. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  75790. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  75791. * @returns the emitter
  75792. */
  75793. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  75794. /**
  75795. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  75796. * @param radius The radius of the hemisphere to emit from
  75797. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  75798. * @returns the emitter
  75799. */
  75800. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  75801. /**
  75802. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  75803. * @param radius The radius of the sphere to emit from
  75804. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  75805. * @returns the emitter
  75806. */
  75807. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  75808. /**
  75809. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  75810. * @param radius The radius of the sphere to emit from
  75811. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  75812. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  75813. * @returns the emitter
  75814. */
  75815. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  75816. /**
  75817. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  75818. * @param radius The radius of the emission cylinder
  75819. * @param height The height of the emission cylinder
  75820. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  75821. * @param directionRandomizer How much to randomize the particle direction [0-1]
  75822. * @returns the emitter
  75823. */
  75824. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  75825. /**
  75826. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  75827. * @param radius The radius of the cylinder to emit from
  75828. * @param height The height of the emission cylinder
  75829. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75830. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  75831. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  75832. * @returns the emitter
  75833. */
  75834. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  75835. /**
  75836. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  75837. * @param radius The radius of the cone to emit from
  75838. * @param angle The base angle of the cone
  75839. * @returns the emitter
  75840. */
  75841. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  75842. /**
  75843. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  75844. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  75845. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  75846. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  75847. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  75848. * @returns the emitter
  75849. */
  75850. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  75851. /**
  75852. * Get hosting scene
  75853. * @returns the scene
  75854. */
  75855. getScene(): Scene;
  75856. }
  75857. }
  75858. declare module BABYLON {
  75859. /**
  75860. * Creates an instance based on a source mesh.
  75861. */
  75862. export class InstancedMesh extends AbstractMesh {
  75863. private _sourceMesh;
  75864. private _currentLOD;
  75865. /** @hidden */
  75866. _indexInSourceMeshInstanceArray: number;
  75867. constructor(name: string, source: Mesh);
  75868. /**
  75869. * Returns the string "InstancedMesh".
  75870. */
  75871. getClassName(): string;
  75872. /**
  75873. * If the source mesh receives shadows
  75874. */
  75875. readonly receiveShadows: boolean;
  75876. /**
  75877. * The material of the source mesh
  75878. */
  75879. readonly material: Nullable<Material>;
  75880. /**
  75881. * Visibility of the source mesh
  75882. */
  75883. readonly visibility: number;
  75884. /**
  75885. * Skeleton of the source mesh
  75886. */
  75887. readonly skeleton: Nullable<Skeleton>;
  75888. /**
  75889. * Rendering ground id of the source mesh
  75890. */
  75891. renderingGroupId: number;
  75892. /**
  75893. * Returns the total number of vertices (integer).
  75894. */
  75895. getTotalVertices(): number;
  75896. /**
  75897. * Returns a positive integer : the total number of indices in this mesh geometry.
  75898. * @returns the numner of indices or zero if the mesh has no geometry.
  75899. */
  75900. getTotalIndices(): number;
  75901. /**
  75902. * The source mesh of the instance
  75903. */
  75904. readonly sourceMesh: Mesh;
  75905. /**
  75906. * Is this node ready to be used/rendered
  75907. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  75908. * @return {boolean} is it ready
  75909. */
  75910. isReady(completeCheck?: boolean): boolean;
  75911. /**
  75912. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  75913. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  75914. * @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.
  75915. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  75916. */
  75917. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  75918. /**
  75919. * Sets the vertex data of the mesh geometry for the requested `kind`.
  75920. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  75921. * The `data` are either a numeric array either a Float32Array.
  75922. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  75923. * 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).
  75924. * Note that a new underlying VertexBuffer object is created each call.
  75925. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  75926. *
  75927. * Possible `kind` values :
  75928. * - VertexBuffer.PositionKind
  75929. * - VertexBuffer.UVKind
  75930. * - VertexBuffer.UV2Kind
  75931. * - VertexBuffer.UV3Kind
  75932. * - VertexBuffer.UV4Kind
  75933. * - VertexBuffer.UV5Kind
  75934. * - VertexBuffer.UV6Kind
  75935. * - VertexBuffer.ColorKind
  75936. * - VertexBuffer.MatricesIndicesKind
  75937. * - VertexBuffer.MatricesIndicesExtraKind
  75938. * - VertexBuffer.MatricesWeightsKind
  75939. * - VertexBuffer.MatricesWeightsExtraKind
  75940. *
  75941. * Returns the Mesh.
  75942. */
  75943. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  75944. /**
  75945. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  75946. * If the mesh has no geometry, it is simply returned as it is.
  75947. * The `data` are either a numeric array either a Float32Array.
  75948. * No new underlying VertexBuffer object is created.
  75949. * 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.
  75950. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  75951. *
  75952. * Possible `kind` values :
  75953. * - VertexBuffer.PositionKind
  75954. * - VertexBuffer.UVKind
  75955. * - VertexBuffer.UV2Kind
  75956. * - VertexBuffer.UV3Kind
  75957. * - VertexBuffer.UV4Kind
  75958. * - VertexBuffer.UV5Kind
  75959. * - VertexBuffer.UV6Kind
  75960. * - VertexBuffer.ColorKind
  75961. * - VertexBuffer.MatricesIndicesKind
  75962. * - VertexBuffer.MatricesIndicesExtraKind
  75963. * - VertexBuffer.MatricesWeightsKind
  75964. * - VertexBuffer.MatricesWeightsExtraKind
  75965. *
  75966. * Returns the Mesh.
  75967. */
  75968. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  75969. /**
  75970. * Sets the mesh indices.
  75971. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  75972. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  75973. * This method creates a new index buffer each call.
  75974. * Returns the Mesh.
  75975. */
  75976. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  75977. /**
  75978. * Boolean : True if the mesh owns the requested kind of data.
  75979. */
  75980. isVerticesDataPresent(kind: string): boolean;
  75981. /**
  75982. * Returns an array of indices (IndicesArray).
  75983. */
  75984. getIndices(): Nullable<IndicesArray>;
  75985. readonly _positions: Nullable<Vector3[]>;
  75986. /**
  75987. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  75988. * This means the mesh underlying bounding box and sphere are recomputed.
  75989. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  75990. * @returns the current mesh
  75991. */
  75992. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  75993. /** @hidden */
  75994. _preActivate(): InstancedMesh;
  75995. /** @hidden */
  75996. _activate(renderId: number): InstancedMesh;
  75997. /**
  75998. * Returns the current associated LOD AbstractMesh.
  75999. */
  76000. getLOD(camera: Camera): AbstractMesh;
  76001. /** @hidden */
  76002. _syncSubMeshes(): InstancedMesh;
  76003. /** @hidden */
  76004. _generatePointsArray(): boolean;
  76005. /**
  76006. * Creates a new InstancedMesh from the current mesh.
  76007. * - name (string) : the cloned mesh name
  76008. * - newParent (optional Node) : the optional Node to parent the clone to.
  76009. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  76010. *
  76011. * Returns the clone.
  76012. */
  76013. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  76014. /**
  76015. * Disposes the InstancedMesh.
  76016. * Returns nothing.
  76017. */
  76018. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76019. }
  76020. }
  76021. declare module BABYLON {
  76022. /**
  76023. * Defines the options associated with the creation of a shader material.
  76024. */
  76025. export interface IShaderMaterialOptions {
  76026. /**
  76027. * Does the material work in alpha blend mode
  76028. */
  76029. needAlphaBlending: boolean;
  76030. /**
  76031. * Does the material work in alpha test mode
  76032. */
  76033. needAlphaTesting: boolean;
  76034. /**
  76035. * The list of attribute names used in the shader
  76036. */
  76037. attributes: string[];
  76038. /**
  76039. * The list of unifrom names used in the shader
  76040. */
  76041. uniforms: string[];
  76042. /**
  76043. * The list of UBO names used in the shader
  76044. */
  76045. uniformBuffers: string[];
  76046. /**
  76047. * The list of sampler names used in the shader
  76048. */
  76049. samplers: string[];
  76050. /**
  76051. * The list of defines used in the shader
  76052. */
  76053. defines: string[];
  76054. }
  76055. /**
  76056. * 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.
  76057. *
  76058. * This returned material effects how the mesh will look based on the code in the shaders.
  76059. *
  76060. * @see http://doc.babylonjs.com/how_to/shader_material
  76061. */
  76062. export class ShaderMaterial extends Material {
  76063. private _shaderPath;
  76064. private _options;
  76065. private _textures;
  76066. private _textureArrays;
  76067. private _floats;
  76068. private _ints;
  76069. private _floatsArrays;
  76070. private _colors3;
  76071. private _colors3Arrays;
  76072. private _colors4;
  76073. private _vectors2;
  76074. private _vectors3;
  76075. private _vectors4;
  76076. private _matrices;
  76077. private _matrices3x3;
  76078. private _matrices2x2;
  76079. private _vectors2Arrays;
  76080. private _vectors3Arrays;
  76081. private _cachedWorldViewMatrix;
  76082. private _renderId;
  76083. /**
  76084. * Instantiate a new shader material.
  76085. * 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.
  76086. * This returned material effects how the mesh will look based on the code in the shaders.
  76087. * @see http://doc.babylonjs.com/how_to/shader_material
  76088. * @param name Define the name of the material in the scene
  76089. * @param scene Define the scene the material belongs to
  76090. * @param shaderPath Defines the route to the shader code in one of three ways:
  76091. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  76092. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  76093. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  76094. * @param options Define the options used to create the shader
  76095. */
  76096. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  76097. /**
  76098. * Gets the options used to compile the shader.
  76099. * They can be modified to trigger a new compilation
  76100. */
  76101. readonly options: IShaderMaterialOptions;
  76102. /**
  76103. * Gets the current class name of the material e.g. "ShaderMaterial"
  76104. * Mainly use in serialization.
  76105. * @returns the class name
  76106. */
  76107. getClassName(): string;
  76108. /**
  76109. * Specifies if the material will require alpha blending
  76110. * @returns a boolean specifying if alpha blending is needed
  76111. */
  76112. needAlphaBlending(): boolean;
  76113. /**
  76114. * Specifies if this material should be rendered in alpha test mode
  76115. * @returns a boolean specifying if an alpha test is needed.
  76116. */
  76117. needAlphaTesting(): boolean;
  76118. private _checkUniform;
  76119. /**
  76120. * Set a texture in the shader.
  76121. * @param name Define the name of the uniform samplers as defined in the shader
  76122. * @param texture Define the texture to bind to this sampler
  76123. * @return the material itself allowing "fluent" like uniform updates
  76124. */
  76125. setTexture(name: string, texture: Texture): ShaderMaterial;
  76126. /**
  76127. * Set a texture array in the shader.
  76128. * @param name Define the name of the uniform sampler array as defined in the shader
  76129. * @param textures Define the list of textures to bind to this sampler
  76130. * @return the material itself allowing "fluent" like uniform updates
  76131. */
  76132. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  76133. /**
  76134. * Set a float in the shader.
  76135. * @param name Define the name of the uniform as defined in the shader
  76136. * @param value Define the value to give to the uniform
  76137. * @return the material itself allowing "fluent" like uniform updates
  76138. */
  76139. setFloat(name: string, value: number): ShaderMaterial;
  76140. /**
  76141. * Set a int in the shader.
  76142. * @param name Define the name of the uniform as defined in the shader
  76143. * @param value Define the value to give to the uniform
  76144. * @return the material itself allowing "fluent" like uniform updates
  76145. */
  76146. setInt(name: string, value: number): ShaderMaterial;
  76147. /**
  76148. * Set an array of floats in the shader.
  76149. * @param name Define the name of the uniform as defined in the shader
  76150. * @param value Define the value to give to the uniform
  76151. * @return the material itself allowing "fluent" like uniform updates
  76152. */
  76153. setFloats(name: string, value: number[]): ShaderMaterial;
  76154. /**
  76155. * Set a vec3 in the shader from a Color3.
  76156. * @param name Define the name of the uniform as defined in the shader
  76157. * @param value Define the value to give to the uniform
  76158. * @return the material itself allowing "fluent" like uniform updates
  76159. */
  76160. setColor3(name: string, value: Color3): ShaderMaterial;
  76161. /**
  76162. * Set a vec3 array in the shader from a Color3 array.
  76163. * @param name Define the name of the uniform as defined in the shader
  76164. * @param value Define the value to give to the uniform
  76165. * @return the material itself allowing "fluent" like uniform updates
  76166. */
  76167. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  76168. /**
  76169. * Set a vec4 in the shader from a Color4.
  76170. * @param name Define the name of the uniform as defined in the shader
  76171. * @param value Define the value to give to the uniform
  76172. * @return the material itself allowing "fluent" like uniform updates
  76173. */
  76174. setColor4(name: string, value: Color4): ShaderMaterial;
  76175. /**
  76176. * Set a vec2 in the shader from a Vector2.
  76177. * @param name Define the name of the uniform as defined in the shader
  76178. * @param value Define the value to give to the uniform
  76179. * @return the material itself allowing "fluent" like uniform updates
  76180. */
  76181. setVector2(name: string, value: Vector2): ShaderMaterial;
  76182. /**
  76183. * Set a vec3 in the shader from a Vector3.
  76184. * @param name Define the name of the uniform as defined in the shader
  76185. * @param value Define the value to give to the uniform
  76186. * @return the material itself allowing "fluent" like uniform updates
  76187. */
  76188. setVector3(name: string, value: Vector3): ShaderMaterial;
  76189. /**
  76190. * Set a vec4 in the shader from a Vector4.
  76191. * @param name Define the name of the uniform as defined in the shader
  76192. * @param value Define the value to give to the uniform
  76193. * @return the material itself allowing "fluent" like uniform updates
  76194. */
  76195. setVector4(name: string, value: Vector4): ShaderMaterial;
  76196. /**
  76197. * Set a mat4 in the shader from a Matrix.
  76198. * @param name Define the name of the uniform as defined in the shader
  76199. * @param value Define the value to give to the uniform
  76200. * @return the material itself allowing "fluent" like uniform updates
  76201. */
  76202. setMatrix(name: string, value: Matrix): ShaderMaterial;
  76203. /**
  76204. * Set a mat3 in the shader from a Float32Array.
  76205. * @param name Define the name of the uniform as defined in the shader
  76206. * @param value Define the value to give to the uniform
  76207. * @return the material itself allowing "fluent" like uniform updates
  76208. */
  76209. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  76210. /**
  76211. * Set a mat2 in the shader from a Float32Array.
  76212. * @param name Define the name of the uniform as defined in the shader
  76213. * @param value Define the value to give to the uniform
  76214. * @return the material itself allowing "fluent" like uniform updates
  76215. */
  76216. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  76217. /**
  76218. * Set a vec2 array in the shader from a number array.
  76219. * @param name Define the name of the uniform as defined in the shader
  76220. * @param value Define the value to give to the uniform
  76221. * @return the material itself allowing "fluent" like uniform updates
  76222. */
  76223. setArray2(name: string, value: number[]): ShaderMaterial;
  76224. /**
  76225. * Set a vec3 array in the shader from a number array.
  76226. * @param name Define the name of the uniform as defined in the shader
  76227. * @param value Define the value to give to the uniform
  76228. * @return the material itself allowing "fluent" like uniform updates
  76229. */
  76230. setArray3(name: string, value: number[]): ShaderMaterial;
  76231. private _checkCache;
  76232. /**
  76233. * Specifies that the submesh is ready to be used
  76234. * @param mesh defines the mesh to check
  76235. * @param subMesh defines which submesh to check
  76236. * @param useInstances specifies that instances should be used
  76237. * @returns a boolean indicating that the submesh is ready or not
  76238. */
  76239. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  76240. /**
  76241. * Checks if the material is ready to render the requested mesh
  76242. * @param mesh Define the mesh to render
  76243. * @param useInstances Define whether or not the material is used with instances
  76244. * @returns true if ready, otherwise false
  76245. */
  76246. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  76247. /**
  76248. * Binds the world matrix to the material
  76249. * @param world defines the world transformation matrix
  76250. */
  76251. bindOnlyWorldMatrix(world: Matrix): void;
  76252. /**
  76253. * Binds the material to the mesh
  76254. * @param world defines the world transformation matrix
  76255. * @param mesh defines the mesh to bind the material to
  76256. */
  76257. bind(world: Matrix, mesh?: Mesh): void;
  76258. /**
  76259. * Gets the active textures from the material
  76260. * @returns an array of textures
  76261. */
  76262. getActiveTextures(): BaseTexture[];
  76263. /**
  76264. * Specifies if the material uses a texture
  76265. * @param texture defines the texture to check against the material
  76266. * @returns a boolean specifying if the material uses the texture
  76267. */
  76268. hasTexture(texture: BaseTexture): boolean;
  76269. /**
  76270. * Makes a duplicate of the material, and gives it a new name
  76271. * @param name defines the new name for the duplicated material
  76272. * @returns the cloned material
  76273. */
  76274. clone(name: string): ShaderMaterial;
  76275. /**
  76276. * Disposes the material
  76277. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  76278. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  76279. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  76280. */
  76281. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  76282. /**
  76283. * Serializes this material in a JSON representation
  76284. * @returns the serialized material object
  76285. */
  76286. serialize(): any;
  76287. /**
  76288. * Creates a shader material from parsed shader material data
  76289. * @param source defines the JSON represnetation of the material
  76290. * @param scene defines the hosting scene
  76291. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  76292. * @returns a new material
  76293. */
  76294. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  76295. }
  76296. }
  76297. declare module BABYLON {
  76298. /** @hidden */
  76299. export var colorPixelShader: {
  76300. name: string;
  76301. shader: string;
  76302. };
  76303. }
  76304. declare module BABYLON {
  76305. /** @hidden */
  76306. export var colorVertexShader: {
  76307. name: string;
  76308. shader: string;
  76309. };
  76310. }
  76311. declare module BABYLON {
  76312. /**
  76313. * Line mesh
  76314. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  76315. */
  76316. export class LinesMesh extends Mesh {
  76317. /**
  76318. * If vertex color should be applied to the mesh
  76319. */
  76320. useVertexColor?: boolean | undefined;
  76321. /**
  76322. * If vertex alpha should be applied to the mesh
  76323. */
  76324. useVertexAlpha?: boolean | undefined;
  76325. /**
  76326. * Color of the line (Default: White)
  76327. */
  76328. color: Color3;
  76329. /**
  76330. * Alpha of the line (Default: 1)
  76331. */
  76332. alpha: number;
  76333. /**
  76334. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  76335. * This margin is expressed in world space coordinates, so its value may vary.
  76336. * Default value is 0.1
  76337. */
  76338. intersectionThreshold: number;
  76339. private _colorShader;
  76340. /**
  76341. * Creates a new LinesMesh
  76342. * @param name defines the name
  76343. * @param scene defines the hosting scene
  76344. * @param parent defines the parent mesh if any
  76345. * @param source defines the optional source LinesMesh used to clone data from
  76346. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  76347. * When false, achieved by calling a clone(), also passing False.
  76348. * This will make creation of children, recursive.
  76349. * @param useVertexColor defines if this LinesMesh supports vertex color
  76350. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  76351. */
  76352. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  76353. /**
  76354. * If vertex color should be applied to the mesh
  76355. */
  76356. useVertexColor?: boolean | undefined,
  76357. /**
  76358. * If vertex alpha should be applied to the mesh
  76359. */
  76360. useVertexAlpha?: boolean | undefined);
  76361. private _addClipPlaneDefine;
  76362. private _removeClipPlaneDefine;
  76363. isReady(): boolean;
  76364. /**
  76365. * Returns the string "LineMesh"
  76366. */
  76367. getClassName(): string;
  76368. /**
  76369. * @hidden
  76370. */
  76371. /**
  76372. * @hidden
  76373. */
  76374. material: Material;
  76375. /**
  76376. * @hidden
  76377. */
  76378. readonly checkCollisions: boolean;
  76379. /** @hidden */
  76380. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  76381. /** @hidden */
  76382. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  76383. /**
  76384. * Disposes of the line mesh
  76385. * @param doNotRecurse If children should be disposed
  76386. */
  76387. dispose(doNotRecurse?: boolean): void;
  76388. /**
  76389. * Returns a new LineMesh object cloned from the current one.
  76390. */
  76391. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  76392. /**
  76393. * Creates a new InstancedLinesMesh object from the mesh model.
  76394. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76395. * @param name defines the name of the new instance
  76396. * @returns a new InstancedLinesMesh
  76397. */
  76398. createInstance(name: string): InstancedLinesMesh;
  76399. }
  76400. /**
  76401. * Creates an instance based on a source LinesMesh
  76402. */
  76403. export class InstancedLinesMesh extends InstancedMesh {
  76404. /**
  76405. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  76406. * This margin is expressed in world space coordinates, so its value may vary.
  76407. * Initilized with the intersectionThreshold value of the source LinesMesh
  76408. */
  76409. intersectionThreshold: number;
  76410. constructor(name: string, source: LinesMesh);
  76411. /**
  76412. * Returns the string "InstancedLinesMesh".
  76413. */
  76414. getClassName(): string;
  76415. }
  76416. }
  76417. declare module BABYLON {
  76418. /** @hidden */
  76419. export var linePixelShader: {
  76420. name: string;
  76421. shader: string;
  76422. };
  76423. }
  76424. declare module BABYLON {
  76425. /** @hidden */
  76426. export var lineVertexShader: {
  76427. name: string;
  76428. shader: string;
  76429. };
  76430. }
  76431. declare module BABYLON {
  76432. interface AbstractMesh {
  76433. /**
  76434. * Disables the mesh edge rendering mode
  76435. * @returns the currentAbstractMesh
  76436. */
  76437. disableEdgesRendering(): AbstractMesh;
  76438. /**
  76439. * Enables the edge rendering mode on the mesh.
  76440. * This mode makes the mesh edges visible
  76441. * @param epsilon defines the maximal distance between two angles to detect a face
  76442. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76443. * @returns the currentAbstractMesh
  76444. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76445. */
  76446. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  76447. /**
  76448. * Gets the edgesRenderer associated with the mesh
  76449. */
  76450. edgesRenderer: Nullable<EdgesRenderer>;
  76451. }
  76452. interface LinesMesh {
  76453. /**
  76454. * Enables the edge rendering mode on the mesh.
  76455. * This mode makes the mesh edges visible
  76456. * @param epsilon defines the maximal distance between two angles to detect a face
  76457. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76458. * @returns the currentAbstractMesh
  76459. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76460. */
  76461. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  76462. }
  76463. interface InstancedLinesMesh {
  76464. /**
  76465. * Enables the edge rendering mode on the mesh.
  76466. * This mode makes the mesh edges visible
  76467. * @param epsilon defines the maximal distance between two angles to detect a face
  76468. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76469. * @returns the current InstancedLinesMesh
  76470. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76471. */
  76472. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  76473. }
  76474. /**
  76475. * Defines the minimum contract an Edges renderer should follow.
  76476. */
  76477. export interface IEdgesRenderer extends IDisposable {
  76478. /**
  76479. * Gets or sets a boolean indicating if the edgesRenderer is active
  76480. */
  76481. isEnabled: boolean;
  76482. /**
  76483. * Renders the edges of the attached mesh,
  76484. */
  76485. render(): void;
  76486. /**
  76487. * Checks wether or not the edges renderer is ready to render.
  76488. * @return true if ready, otherwise false.
  76489. */
  76490. isReady(): boolean;
  76491. }
  76492. /**
  76493. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  76494. */
  76495. export class EdgesRenderer implements IEdgesRenderer {
  76496. /**
  76497. * Define the size of the edges with an orthographic camera
  76498. */
  76499. edgesWidthScalerForOrthographic: number;
  76500. /**
  76501. * Define the size of the edges with a perspective camera
  76502. */
  76503. edgesWidthScalerForPerspective: number;
  76504. protected _source: AbstractMesh;
  76505. protected _linesPositions: number[];
  76506. protected _linesNormals: number[];
  76507. protected _linesIndices: number[];
  76508. protected _epsilon: number;
  76509. protected _indicesCount: number;
  76510. protected _lineShader: ShaderMaterial;
  76511. protected _ib: WebGLBuffer;
  76512. protected _buffers: {
  76513. [key: string]: Nullable<VertexBuffer>;
  76514. };
  76515. protected _checkVerticesInsteadOfIndices: boolean;
  76516. private _meshRebuildObserver;
  76517. private _meshDisposeObserver;
  76518. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  76519. isEnabled: boolean;
  76520. /**
  76521. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  76522. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  76523. * @param source Mesh used to create edges
  76524. * @param epsilon sum of angles in adjacency to check for edge
  76525. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  76526. * @param generateEdgesLines - should generate Lines or only prepare resources.
  76527. */
  76528. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  76529. protected _prepareRessources(): void;
  76530. /** @hidden */
  76531. _rebuild(): void;
  76532. /**
  76533. * Releases the required resources for the edges renderer
  76534. */
  76535. dispose(): void;
  76536. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  76537. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  76538. /**
  76539. * Checks if the pair of p0 and p1 is en edge
  76540. * @param faceIndex
  76541. * @param edge
  76542. * @param faceNormals
  76543. * @param p0
  76544. * @param p1
  76545. * @private
  76546. */
  76547. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  76548. /**
  76549. * push line into the position, normal and index buffer
  76550. * @protected
  76551. */
  76552. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  76553. /**
  76554. * Generates lines edges from adjacencjes
  76555. * @private
  76556. */
  76557. _generateEdgesLines(): void;
  76558. /**
  76559. * Checks wether or not the edges renderer is ready to render.
  76560. * @return true if ready, otherwise false.
  76561. */
  76562. isReady(): boolean;
  76563. /**
  76564. * Renders the edges of the attached mesh,
  76565. */
  76566. render(): void;
  76567. }
  76568. /**
  76569. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  76570. */
  76571. export class LineEdgesRenderer extends EdgesRenderer {
  76572. /**
  76573. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  76574. * @param source LineMesh used to generate edges
  76575. * @param epsilon not important (specified angle for edge detection)
  76576. * @param checkVerticesInsteadOfIndices not important for LineMesh
  76577. */
  76578. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  76579. /**
  76580. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  76581. */
  76582. _generateEdgesLines(): void;
  76583. }
  76584. }
  76585. declare module BABYLON {
  76586. /**
  76587. * This represents the object necessary to create a rendering group.
  76588. * This is exclusively used and created by the rendering manager.
  76589. * To modify the behavior, you use the available helpers in your scene or meshes.
  76590. * @hidden
  76591. */
  76592. export class RenderingGroup {
  76593. index: number;
  76594. private _scene;
  76595. private _opaqueSubMeshes;
  76596. private _transparentSubMeshes;
  76597. private _alphaTestSubMeshes;
  76598. private _depthOnlySubMeshes;
  76599. private _particleSystems;
  76600. private _spriteManagers;
  76601. private _opaqueSortCompareFn;
  76602. private _alphaTestSortCompareFn;
  76603. private _transparentSortCompareFn;
  76604. private _renderOpaque;
  76605. private _renderAlphaTest;
  76606. private _renderTransparent;
  76607. private _edgesRenderers;
  76608. onBeforeTransparentRendering: () => void;
  76609. /**
  76610. * Set the opaque sort comparison function.
  76611. * If null the sub meshes will be render in the order they were created
  76612. */
  76613. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76614. /**
  76615. * Set the alpha test sort comparison function.
  76616. * If null the sub meshes will be render in the order they were created
  76617. */
  76618. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76619. /**
  76620. * Set the transparent sort comparison function.
  76621. * If null the sub meshes will be render in the order they were created
  76622. */
  76623. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76624. /**
  76625. * Creates a new rendering group.
  76626. * @param index The rendering group index
  76627. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  76628. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  76629. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  76630. */
  76631. 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>);
  76632. /**
  76633. * Render all the sub meshes contained in the group.
  76634. * @param customRenderFunction Used to override the default render behaviour of the group.
  76635. * @returns true if rendered some submeshes.
  76636. */
  76637. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  76638. /**
  76639. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  76640. * @param subMeshes The submeshes to render
  76641. */
  76642. private renderOpaqueSorted;
  76643. /**
  76644. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  76645. * @param subMeshes The submeshes to render
  76646. */
  76647. private renderAlphaTestSorted;
  76648. /**
  76649. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  76650. * @param subMeshes The submeshes to render
  76651. */
  76652. private renderTransparentSorted;
  76653. /**
  76654. * Renders the submeshes in a specified order.
  76655. * @param subMeshes The submeshes to sort before render
  76656. * @param sortCompareFn The comparison function use to sort
  76657. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  76658. * @param transparent Specifies to activate blending if true
  76659. */
  76660. private static renderSorted;
  76661. /**
  76662. * Renders the submeshes in the order they were dispatched (no sort applied).
  76663. * @param subMeshes The submeshes to render
  76664. */
  76665. private static renderUnsorted;
  76666. /**
  76667. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76668. * are rendered back to front if in the same alpha index.
  76669. *
  76670. * @param a The first submesh
  76671. * @param b The second submesh
  76672. * @returns The result of the comparison
  76673. */
  76674. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  76675. /**
  76676. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76677. * are rendered back to front.
  76678. *
  76679. * @param a The first submesh
  76680. * @param b The second submesh
  76681. * @returns The result of the comparison
  76682. */
  76683. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  76684. /**
  76685. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76686. * are rendered front to back (prevent overdraw).
  76687. *
  76688. * @param a The first submesh
  76689. * @param b The second submesh
  76690. * @returns The result of the comparison
  76691. */
  76692. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  76693. /**
  76694. * Resets the different lists of submeshes to prepare a new frame.
  76695. */
  76696. prepare(): void;
  76697. dispose(): void;
  76698. /**
  76699. * Inserts the submesh in its correct queue depending on its material.
  76700. * @param subMesh The submesh to dispatch
  76701. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  76702. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  76703. */
  76704. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  76705. dispatchSprites(spriteManager: ISpriteManager): void;
  76706. dispatchParticles(particleSystem: IParticleSystem): void;
  76707. private _renderParticles;
  76708. private _renderSprites;
  76709. }
  76710. }
  76711. declare module BABYLON {
  76712. /**
  76713. * Interface describing the different options available in the rendering manager
  76714. * regarding Auto Clear between groups.
  76715. */
  76716. export interface IRenderingManagerAutoClearSetup {
  76717. /**
  76718. * Defines whether or not autoclear is enable.
  76719. */
  76720. autoClear: boolean;
  76721. /**
  76722. * Defines whether or not to autoclear the depth buffer.
  76723. */
  76724. depth: boolean;
  76725. /**
  76726. * Defines whether or not to autoclear the stencil buffer.
  76727. */
  76728. stencil: boolean;
  76729. }
  76730. /**
  76731. * This class is used by the onRenderingGroupObservable
  76732. */
  76733. export class RenderingGroupInfo {
  76734. /**
  76735. * The Scene that being rendered
  76736. */
  76737. scene: Scene;
  76738. /**
  76739. * The camera currently used for the rendering pass
  76740. */
  76741. camera: Nullable<Camera>;
  76742. /**
  76743. * The ID of the renderingGroup being processed
  76744. */
  76745. renderingGroupId: number;
  76746. }
  76747. /**
  76748. * This is the manager responsible of all the rendering for meshes sprites and particles.
  76749. * It is enable to manage the different groups as well as the different necessary sort functions.
  76750. * This should not be used directly aside of the few static configurations
  76751. */
  76752. export class RenderingManager {
  76753. /**
  76754. * The max id used for rendering groups (not included)
  76755. */
  76756. static MAX_RENDERINGGROUPS: number;
  76757. /**
  76758. * The min id used for rendering groups (included)
  76759. */
  76760. static MIN_RENDERINGGROUPS: number;
  76761. /**
  76762. * Used to globally prevent autoclearing scenes.
  76763. */
  76764. static AUTOCLEAR: boolean;
  76765. /**
  76766. * @hidden
  76767. */
  76768. _useSceneAutoClearSetup: boolean;
  76769. private _scene;
  76770. private _renderingGroups;
  76771. private _depthStencilBufferAlreadyCleaned;
  76772. private _autoClearDepthStencil;
  76773. private _customOpaqueSortCompareFn;
  76774. private _customAlphaTestSortCompareFn;
  76775. private _customTransparentSortCompareFn;
  76776. private _renderingGroupInfo;
  76777. /**
  76778. * Instantiates a new rendering group for a particular scene
  76779. * @param scene Defines the scene the groups belongs to
  76780. */
  76781. constructor(scene: Scene);
  76782. private _clearDepthStencilBuffer;
  76783. /**
  76784. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  76785. * @hidden
  76786. */
  76787. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  76788. /**
  76789. * Resets the different information of the group to prepare a new frame
  76790. * @hidden
  76791. */
  76792. reset(): void;
  76793. /**
  76794. * Dispose and release the group and its associated resources.
  76795. * @hidden
  76796. */
  76797. dispose(): void;
  76798. /**
  76799. * Clear the info related to rendering groups preventing retention points during dispose.
  76800. */
  76801. freeRenderingGroups(): void;
  76802. private _prepareRenderingGroup;
  76803. /**
  76804. * Add a sprite manager to the rendering manager in order to render it this frame.
  76805. * @param spriteManager Define the sprite manager to render
  76806. */
  76807. dispatchSprites(spriteManager: ISpriteManager): void;
  76808. /**
  76809. * Add a particle system to the rendering manager in order to render it this frame.
  76810. * @param particleSystem Define the particle system to render
  76811. */
  76812. dispatchParticles(particleSystem: IParticleSystem): void;
  76813. /**
  76814. * Add a submesh to the manager in order to render it this frame
  76815. * @param subMesh The submesh to dispatch
  76816. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  76817. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  76818. */
  76819. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  76820. /**
  76821. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  76822. * This allowed control for front to back rendering or reversly depending of the special needs.
  76823. *
  76824. * @param renderingGroupId The rendering group id corresponding to its index
  76825. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  76826. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  76827. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  76828. */
  76829. 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;
  76830. /**
  76831. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  76832. *
  76833. * @param renderingGroupId The rendering group id corresponding to its index
  76834. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  76835. * @param depth Automatically clears depth between groups if true and autoClear is true.
  76836. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  76837. */
  76838. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  76839. /**
  76840. * Gets the current auto clear configuration for one rendering group of the rendering
  76841. * manager.
  76842. * @param index the rendering group index to get the information for
  76843. * @returns The auto clear setup for the requested rendering group
  76844. */
  76845. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  76846. }
  76847. }
  76848. declare module BABYLON {
  76849. /**
  76850. * This Helps creating a texture that will be created from a camera in your scene.
  76851. * It is basically a dynamic texture that could be used to create special effects for instance.
  76852. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  76853. */
  76854. export class RenderTargetTexture extends Texture {
  76855. isCube: boolean;
  76856. /**
  76857. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  76858. */
  76859. static readonly REFRESHRATE_RENDER_ONCE: number;
  76860. /**
  76861. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  76862. */
  76863. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  76864. /**
  76865. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  76866. * the central point of your effect and can save a lot of performances.
  76867. */
  76868. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  76869. /**
  76870. * Use this predicate to dynamically define the list of mesh you want to render.
  76871. * If set, the renderList property will be overwritten.
  76872. */
  76873. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  76874. private _renderList;
  76875. /**
  76876. * Use this list to define the list of mesh you want to render.
  76877. */
  76878. renderList: Nullable<Array<AbstractMesh>>;
  76879. private _hookArray;
  76880. /**
  76881. * Define if particles should be rendered in your texture.
  76882. */
  76883. renderParticles: boolean;
  76884. /**
  76885. * Define if sprites should be rendered in your texture.
  76886. */
  76887. renderSprites: boolean;
  76888. /**
  76889. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  76890. */
  76891. coordinatesMode: number;
  76892. /**
  76893. * Define the camera used to render the texture.
  76894. */
  76895. activeCamera: Nullable<Camera>;
  76896. /**
  76897. * Override the render function of the texture with your own one.
  76898. */
  76899. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  76900. /**
  76901. * Define if camera post processes should be use while rendering the texture.
  76902. */
  76903. useCameraPostProcesses: boolean;
  76904. /**
  76905. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  76906. */
  76907. ignoreCameraViewport: boolean;
  76908. private _postProcessManager;
  76909. private _postProcesses;
  76910. private _resizeObserver;
  76911. /**
  76912. * An event triggered when the texture is unbind.
  76913. */
  76914. onBeforeBindObservable: Observable<RenderTargetTexture>;
  76915. /**
  76916. * An event triggered when the texture is unbind.
  76917. */
  76918. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  76919. private _onAfterUnbindObserver;
  76920. /**
  76921. * Set a after unbind callback in the texture.
  76922. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  76923. */
  76924. onAfterUnbind: () => void;
  76925. /**
  76926. * An event triggered before rendering the texture
  76927. */
  76928. onBeforeRenderObservable: Observable<number>;
  76929. private _onBeforeRenderObserver;
  76930. /**
  76931. * Set a before render callback in the texture.
  76932. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  76933. */
  76934. onBeforeRender: (faceIndex: number) => void;
  76935. /**
  76936. * An event triggered after rendering the texture
  76937. */
  76938. onAfterRenderObservable: Observable<number>;
  76939. private _onAfterRenderObserver;
  76940. /**
  76941. * Set a after render callback in the texture.
  76942. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  76943. */
  76944. onAfterRender: (faceIndex: number) => void;
  76945. /**
  76946. * An event triggered after the texture clear
  76947. */
  76948. onClearObservable: Observable<Engine>;
  76949. private _onClearObserver;
  76950. /**
  76951. * Set a clear callback in the texture.
  76952. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  76953. */
  76954. onClear: (Engine: Engine) => void;
  76955. /**
  76956. * Define the clear color of the Render Target if it should be different from the scene.
  76957. */
  76958. clearColor: Color4;
  76959. protected _size: number | {
  76960. width: number;
  76961. height: number;
  76962. };
  76963. protected _initialSizeParameter: number | {
  76964. width: number;
  76965. height: number;
  76966. } | {
  76967. ratio: number;
  76968. };
  76969. protected _sizeRatio: Nullable<number>;
  76970. /** @hidden */
  76971. _generateMipMaps: boolean;
  76972. protected _renderingManager: RenderingManager;
  76973. /** @hidden */
  76974. _waitingRenderList: string[];
  76975. protected _doNotChangeAspectRatio: boolean;
  76976. protected _currentRefreshId: number;
  76977. protected _refreshRate: number;
  76978. protected _textureMatrix: Matrix;
  76979. protected _samples: number;
  76980. protected _renderTargetOptions: RenderTargetCreationOptions;
  76981. /**
  76982. * Gets render target creation options that were used.
  76983. */
  76984. readonly renderTargetOptions: RenderTargetCreationOptions;
  76985. protected _engine: Engine;
  76986. protected _onRatioRescale(): void;
  76987. /**
  76988. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  76989. * It must define where the camera used to render the texture is set
  76990. */
  76991. boundingBoxPosition: Vector3;
  76992. private _boundingBoxSize;
  76993. /**
  76994. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  76995. * When defined, the cubemap will switch to local mode
  76996. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  76997. * @example https://www.babylonjs-playground.com/#RNASML
  76998. */
  76999. boundingBoxSize: Vector3;
  77000. /**
  77001. * In case the RTT has been created with a depth texture, get the associated
  77002. * depth texture.
  77003. * Otherwise, return null.
  77004. */
  77005. depthStencilTexture: Nullable<InternalTexture>;
  77006. /**
  77007. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  77008. * or used a shadow, depth texture...
  77009. * @param name The friendly name of the texture
  77010. * @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)
  77011. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  77012. * @param generateMipMaps True if mip maps need to be generated after render.
  77013. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  77014. * @param type The type of the buffer in the RTT (int, half float, float...)
  77015. * @param isCube True if a cube texture needs to be created
  77016. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  77017. * @param generateDepthBuffer True to generate a depth buffer
  77018. * @param generateStencilBuffer True to generate a stencil buffer
  77019. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  77020. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  77021. * @param delayAllocation if the texture allocation should be delayed (default: false)
  77022. */
  77023. constructor(name: string, size: number | {
  77024. width: number;
  77025. height: number;
  77026. } | {
  77027. ratio: number;
  77028. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  77029. /**
  77030. * Creates a depth stencil texture.
  77031. * This is only available in WebGL 2 or with the depth texture extension available.
  77032. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  77033. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  77034. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  77035. */
  77036. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  77037. private _processSizeParameter;
  77038. /**
  77039. * Define the number of samples to use in case of MSAA.
  77040. * It defaults to one meaning no MSAA has been enabled.
  77041. */
  77042. samples: number;
  77043. /**
  77044. * Resets the refresh counter of the texture and start bak from scratch.
  77045. * Could be useful to regenerate the texture if it is setup to render only once.
  77046. */
  77047. resetRefreshCounter(): void;
  77048. /**
  77049. * Define the refresh rate of the texture or the rendering frequency.
  77050. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  77051. */
  77052. refreshRate: number;
  77053. /**
  77054. * Adds a post process to the render target rendering passes.
  77055. * @param postProcess define the post process to add
  77056. */
  77057. addPostProcess(postProcess: PostProcess): void;
  77058. /**
  77059. * Clear all the post processes attached to the render target
  77060. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  77061. */
  77062. clearPostProcesses(dispose?: boolean): void;
  77063. /**
  77064. * Remove one of the post process from the list of attached post processes to the texture
  77065. * @param postProcess define the post process to remove from the list
  77066. */
  77067. removePostProcess(postProcess: PostProcess): void;
  77068. /** @hidden */
  77069. _shouldRender(): boolean;
  77070. /**
  77071. * Gets the actual render size of the texture.
  77072. * @returns the width of the render size
  77073. */
  77074. getRenderSize(): number;
  77075. /**
  77076. * Gets the actual render width of the texture.
  77077. * @returns the width of the render size
  77078. */
  77079. getRenderWidth(): number;
  77080. /**
  77081. * Gets the actual render height of the texture.
  77082. * @returns the height of the render size
  77083. */
  77084. getRenderHeight(): number;
  77085. /**
  77086. * Get if the texture can be rescaled or not.
  77087. */
  77088. readonly canRescale: boolean;
  77089. /**
  77090. * Resize the texture using a ratio.
  77091. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  77092. */
  77093. scale(ratio: number): void;
  77094. /**
  77095. * Get the texture reflection matrix used to rotate/transform the reflection.
  77096. * @returns the reflection matrix
  77097. */
  77098. getReflectionTextureMatrix(): Matrix;
  77099. /**
  77100. * Resize the texture to a new desired size.
  77101. * Be carrefull as it will recreate all the data in the new texture.
  77102. * @param size Define the new size. It can be:
  77103. * - a number for squared texture,
  77104. * - an object containing { width: number, height: number }
  77105. * - or an object containing a ratio { ratio: number }
  77106. */
  77107. resize(size: number | {
  77108. width: number;
  77109. height: number;
  77110. } | {
  77111. ratio: number;
  77112. }): void;
  77113. /**
  77114. * Renders all the objects from the render list into the texture.
  77115. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  77116. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  77117. */
  77118. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  77119. private _bestReflectionRenderTargetDimension;
  77120. /**
  77121. * @hidden
  77122. * @param faceIndex face index to bind to if this is a cubetexture
  77123. */
  77124. _bindFrameBuffer(faceIndex?: number): void;
  77125. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  77126. private renderToTarget;
  77127. /**
  77128. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77129. * This allowed control for front to back rendering or reversly depending of the special needs.
  77130. *
  77131. * @param renderingGroupId The rendering group id corresponding to its index
  77132. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77133. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77134. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77135. */
  77136. 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;
  77137. /**
  77138. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77139. *
  77140. * @param renderingGroupId The rendering group id corresponding to its index
  77141. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77142. */
  77143. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  77144. /**
  77145. * Clones the texture.
  77146. * @returns the cloned texture
  77147. */
  77148. clone(): RenderTargetTexture;
  77149. /**
  77150. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77151. * @returns The JSON representation of the texture
  77152. */
  77153. serialize(): any;
  77154. /**
  77155. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  77156. */
  77157. disposeFramebufferObjects(): void;
  77158. /**
  77159. * Dispose the texture and release its associated resources.
  77160. */
  77161. dispose(): void;
  77162. /** @hidden */
  77163. _rebuild(): void;
  77164. /**
  77165. * Clear the info related to rendering groups preventing retention point in material dispose.
  77166. */
  77167. freeRenderingGroups(): void;
  77168. /**
  77169. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  77170. * @returns the view count
  77171. */
  77172. getViewCount(): number;
  77173. }
  77174. }
  77175. declare module BABYLON {
  77176. /**
  77177. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77178. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77179. * You can then easily use it as a reflectionTexture on a flat surface.
  77180. * In case the surface is not a plane, please consider relying on reflection probes.
  77181. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77182. */
  77183. export class MirrorTexture extends RenderTargetTexture {
  77184. private scene;
  77185. /**
  77186. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  77187. * 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.
  77188. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77189. */
  77190. mirrorPlane: Plane;
  77191. /**
  77192. * Define the blur ratio used to blur the reflection if needed.
  77193. */
  77194. blurRatio: number;
  77195. /**
  77196. * Define the adaptive blur kernel used to blur the reflection if needed.
  77197. * This will autocompute the closest best match for the `blurKernel`
  77198. */
  77199. adaptiveBlurKernel: number;
  77200. /**
  77201. * Define the blur kernel used to blur the reflection if needed.
  77202. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77203. */
  77204. blurKernel: number;
  77205. /**
  77206. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  77207. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77208. */
  77209. blurKernelX: number;
  77210. /**
  77211. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  77212. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77213. */
  77214. blurKernelY: number;
  77215. private _autoComputeBlurKernel;
  77216. protected _onRatioRescale(): void;
  77217. private _updateGammaSpace;
  77218. private _imageProcessingConfigChangeObserver;
  77219. private _transformMatrix;
  77220. private _mirrorMatrix;
  77221. private _savedViewMatrix;
  77222. private _blurX;
  77223. private _blurY;
  77224. private _adaptiveBlurKernel;
  77225. private _blurKernelX;
  77226. private _blurKernelY;
  77227. private _blurRatio;
  77228. /**
  77229. * Instantiates a Mirror Texture.
  77230. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77231. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77232. * You can then easily use it as a reflectionTexture on a flat surface.
  77233. * In case the surface is not a plane, please consider relying on reflection probes.
  77234. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77235. * @param name
  77236. * @param size
  77237. * @param scene
  77238. * @param generateMipMaps
  77239. * @param type
  77240. * @param samplingMode
  77241. * @param generateDepthBuffer
  77242. */
  77243. constructor(name: string, size: number | {
  77244. width: number;
  77245. height: number;
  77246. } | {
  77247. ratio: number;
  77248. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  77249. private _preparePostProcesses;
  77250. /**
  77251. * Clone the mirror texture.
  77252. * @returns the cloned texture
  77253. */
  77254. clone(): MirrorTexture;
  77255. /**
  77256. * Serialize the texture to a JSON representation you could use in Parse later on
  77257. * @returns the serialized JSON representation
  77258. */
  77259. serialize(): any;
  77260. /**
  77261. * Dispose the texture and release its associated resources.
  77262. */
  77263. dispose(): void;
  77264. }
  77265. }
  77266. declare module BABYLON {
  77267. /**
  77268. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  77269. * @see http://doc.babylonjs.com/babylon101/materials#texture
  77270. */
  77271. export class Texture extends BaseTexture {
  77272. /** @hidden */
  77273. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  77274. /** @hidden */
  77275. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  77276. /** @hidden */
  77277. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  77278. /** nearest is mag = nearest and min = nearest and mip = linear */
  77279. static readonly NEAREST_SAMPLINGMODE: number;
  77280. /** nearest is mag = nearest and min = nearest and mip = linear */
  77281. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  77282. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77283. static readonly BILINEAR_SAMPLINGMODE: number;
  77284. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77285. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  77286. /** Trilinear is mag = linear and min = linear and mip = linear */
  77287. static readonly TRILINEAR_SAMPLINGMODE: number;
  77288. /** Trilinear is mag = linear and min = linear and mip = linear */
  77289. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  77290. /** mag = nearest and min = nearest and mip = nearest */
  77291. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  77292. /** mag = nearest and min = linear and mip = nearest */
  77293. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  77294. /** mag = nearest and min = linear and mip = linear */
  77295. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  77296. /** mag = nearest and min = linear and mip = none */
  77297. static readonly NEAREST_LINEAR: number;
  77298. /** mag = nearest and min = nearest and mip = none */
  77299. static readonly NEAREST_NEAREST: number;
  77300. /** mag = linear and min = nearest and mip = nearest */
  77301. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  77302. /** mag = linear and min = nearest and mip = linear */
  77303. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  77304. /** mag = linear and min = linear and mip = none */
  77305. static readonly LINEAR_LINEAR: number;
  77306. /** mag = linear and min = nearest and mip = none */
  77307. static readonly LINEAR_NEAREST: number;
  77308. /** Explicit coordinates mode */
  77309. static readonly EXPLICIT_MODE: number;
  77310. /** Spherical coordinates mode */
  77311. static readonly SPHERICAL_MODE: number;
  77312. /** Planar coordinates mode */
  77313. static readonly PLANAR_MODE: number;
  77314. /** Cubic coordinates mode */
  77315. static readonly CUBIC_MODE: number;
  77316. /** Projection coordinates mode */
  77317. static readonly PROJECTION_MODE: number;
  77318. /** Inverse Cubic coordinates mode */
  77319. static readonly SKYBOX_MODE: number;
  77320. /** Inverse Cubic coordinates mode */
  77321. static readonly INVCUBIC_MODE: number;
  77322. /** Equirectangular coordinates mode */
  77323. static readonly EQUIRECTANGULAR_MODE: number;
  77324. /** Equirectangular Fixed coordinates mode */
  77325. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  77326. /** Equirectangular Fixed Mirrored coordinates mode */
  77327. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  77328. /** Texture is not repeating outside of 0..1 UVs */
  77329. static readonly CLAMP_ADDRESSMODE: number;
  77330. /** Texture is repeating outside of 0..1 UVs */
  77331. static readonly WRAP_ADDRESSMODE: number;
  77332. /** Texture is repeating and mirrored */
  77333. static readonly MIRROR_ADDRESSMODE: number;
  77334. /**
  77335. * 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
  77336. */
  77337. static UseSerializedUrlIfAny: boolean;
  77338. /**
  77339. * Define the url of the texture.
  77340. */
  77341. url: Nullable<string>;
  77342. /**
  77343. * Define an offset on the texture to offset the u coordinates of the UVs
  77344. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  77345. */
  77346. uOffset: number;
  77347. /**
  77348. * Define an offset on the texture to offset the v coordinates of the UVs
  77349. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  77350. */
  77351. vOffset: number;
  77352. /**
  77353. * Define an offset on the texture to scale the u coordinates of the UVs
  77354. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  77355. */
  77356. uScale: number;
  77357. /**
  77358. * Define an offset on the texture to scale the v coordinates of the UVs
  77359. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  77360. */
  77361. vScale: number;
  77362. /**
  77363. * Define an offset on the texture to rotate around the u coordinates of the UVs
  77364. * @see http://doc.babylonjs.com/how_to/more_materials
  77365. */
  77366. uAng: number;
  77367. /**
  77368. * Define an offset on the texture to rotate around the v coordinates of the UVs
  77369. * @see http://doc.babylonjs.com/how_to/more_materials
  77370. */
  77371. vAng: number;
  77372. /**
  77373. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  77374. * @see http://doc.babylonjs.com/how_to/more_materials
  77375. */
  77376. wAng: number;
  77377. /**
  77378. * Defines the center of rotation (U)
  77379. */
  77380. uRotationCenter: number;
  77381. /**
  77382. * Defines the center of rotation (V)
  77383. */
  77384. vRotationCenter: number;
  77385. /**
  77386. * Defines the center of rotation (W)
  77387. */
  77388. wRotationCenter: number;
  77389. /**
  77390. * Are mip maps generated for this texture or not.
  77391. */
  77392. readonly noMipmap: boolean;
  77393. /**
  77394. * List of inspectable custom properties (used by the Inspector)
  77395. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77396. */
  77397. inspectableCustomProperties: IInspectable[];
  77398. private _noMipmap;
  77399. /** @hidden */
  77400. _invertY: boolean;
  77401. private _rowGenerationMatrix;
  77402. private _cachedTextureMatrix;
  77403. private _projectionModeMatrix;
  77404. private _t0;
  77405. private _t1;
  77406. private _t2;
  77407. private _cachedUOffset;
  77408. private _cachedVOffset;
  77409. private _cachedUScale;
  77410. private _cachedVScale;
  77411. private _cachedUAng;
  77412. private _cachedVAng;
  77413. private _cachedWAng;
  77414. private _cachedProjectionMatrixId;
  77415. private _cachedCoordinatesMode;
  77416. /** @hidden */
  77417. protected _initialSamplingMode: number;
  77418. /** @hidden */
  77419. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  77420. private _deleteBuffer;
  77421. protected _format: Nullable<number>;
  77422. private _delayedOnLoad;
  77423. private _delayedOnError;
  77424. /**
  77425. * Observable triggered once the texture has been loaded.
  77426. */
  77427. onLoadObservable: Observable<Texture>;
  77428. protected _isBlocking: boolean;
  77429. /**
  77430. * Is the texture preventing material to render while loading.
  77431. * If false, a default texture will be used instead of the loading one during the preparation step.
  77432. */
  77433. isBlocking: boolean;
  77434. /**
  77435. * Get the current sampling mode associated with the texture.
  77436. */
  77437. readonly samplingMode: number;
  77438. /**
  77439. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  77440. */
  77441. readonly invertY: boolean;
  77442. /**
  77443. * Instantiates a new texture.
  77444. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  77445. * @see http://doc.babylonjs.com/babylon101/materials#texture
  77446. * @param url define the url of the picture to load as a texture
  77447. * @param scene define the scene the texture will belong to
  77448. * @param noMipmap define if the texture will require mip maps or not
  77449. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77450. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77451. * @param onLoad define a callback triggered when the texture has been loaded
  77452. * @param onError define a callback triggered when an error occurred during the loading session
  77453. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  77454. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  77455. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77456. */
  77457. 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);
  77458. /**
  77459. * Update the url (and optional buffer) of this texture if url was null during construction.
  77460. * @param url the url of the texture
  77461. * @param buffer the buffer of the texture (defaults to null)
  77462. * @param onLoad callback called when the texture is loaded (defaults to null)
  77463. */
  77464. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  77465. /**
  77466. * Finish the loading sequence of a texture flagged as delayed load.
  77467. * @hidden
  77468. */
  77469. delayLoad(): void;
  77470. private _prepareRowForTextureGeneration;
  77471. /**
  77472. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  77473. * @returns the transform matrix of the texture.
  77474. */
  77475. getTextureMatrix(): Matrix;
  77476. /**
  77477. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  77478. * @returns The reflection texture transform
  77479. */
  77480. getReflectionTextureMatrix(): Matrix;
  77481. /**
  77482. * Clones the texture.
  77483. * @returns the cloned texture
  77484. */
  77485. clone(): Texture;
  77486. /**
  77487. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77488. * @returns The JSON representation of the texture
  77489. */
  77490. serialize(): any;
  77491. /**
  77492. * Get the current class name of the texture useful for serialization or dynamic coding.
  77493. * @returns "Texture"
  77494. */
  77495. getClassName(): string;
  77496. /**
  77497. * Dispose the texture and release its associated resources.
  77498. */
  77499. dispose(): void;
  77500. /**
  77501. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  77502. * @param parsedTexture Define the JSON representation of the texture
  77503. * @param scene Define the scene the parsed texture should be instantiated in
  77504. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  77505. * @returns The parsed texture if successful
  77506. */
  77507. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  77508. /**
  77509. * Creates a texture from its base 64 representation.
  77510. * @param data Define the base64 payload without the data: prefix
  77511. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  77512. * @param scene Define the scene the texture should belong to
  77513. * @param noMipmap Forces the texture to not create mip map information if true
  77514. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77515. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77516. * @param onLoad define a callback triggered when the texture has been loaded
  77517. * @param onError define a callback triggered when an error occurred during the loading session
  77518. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77519. * @returns the created texture
  77520. */
  77521. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  77522. /**
  77523. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  77524. * @param data Define the base64 payload without the data: prefix
  77525. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  77526. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  77527. * @param scene Define the scene the texture should belong to
  77528. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  77529. * @param noMipmap Forces the texture to not create mip map information if true
  77530. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77531. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77532. * @param onLoad define a callback triggered when the texture has been loaded
  77533. * @param onError define a callback triggered when an error occurred during the loading session
  77534. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77535. * @returns the created texture
  77536. */
  77537. 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;
  77538. }
  77539. }
  77540. declare module BABYLON {
  77541. /**
  77542. * Raw texture can help creating a texture directly from an array of data.
  77543. * This can be super useful if you either get the data from an uncompressed source or
  77544. * if you wish to create your texture pixel by pixel.
  77545. */
  77546. export class RawTexture extends Texture {
  77547. /**
  77548. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77549. */
  77550. format: number;
  77551. private _engine;
  77552. /**
  77553. * Instantiates a new RawTexture.
  77554. * Raw texture can help creating a texture directly from an array of data.
  77555. * This can be super useful if you either get the data from an uncompressed source or
  77556. * if you wish to create your texture pixel by pixel.
  77557. * @param data define the array of data to use to create the texture
  77558. * @param width define the width of the texture
  77559. * @param height define the height of the texture
  77560. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77561. * @param scene define the scene the texture belongs to
  77562. * @param generateMipMaps define whether mip maps should be generated or not
  77563. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77564. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77565. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77566. */
  77567. constructor(data: ArrayBufferView, width: number, height: number,
  77568. /**
  77569. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77570. */
  77571. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  77572. /**
  77573. * Updates the texture underlying data.
  77574. * @param data Define the new data of the texture
  77575. */
  77576. update(data: ArrayBufferView): void;
  77577. /**
  77578. * Creates a luminance texture from some data.
  77579. * @param data Define the texture data
  77580. * @param width Define the width of the texture
  77581. * @param height Define the height of the texture
  77582. * @param scene Define the scene the texture belongs to
  77583. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77584. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77585. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77586. * @returns the luminance texture
  77587. */
  77588. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77589. /**
  77590. * Creates a luminance alpha texture from some data.
  77591. * @param data Define the texture data
  77592. * @param width Define the width of the texture
  77593. * @param height Define the height of the texture
  77594. * @param scene Define the scene the texture belongs to
  77595. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77596. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77597. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77598. * @returns the luminance alpha texture
  77599. */
  77600. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77601. /**
  77602. * Creates an alpha texture from some data.
  77603. * @param data Define the texture data
  77604. * @param width Define the width of the texture
  77605. * @param height Define the height of the texture
  77606. * @param scene Define the scene the texture belongs to
  77607. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77608. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77609. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77610. * @returns the alpha texture
  77611. */
  77612. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77613. /**
  77614. * Creates a RGB texture from some data.
  77615. * @param data Define the texture data
  77616. * @param width Define the width of the texture
  77617. * @param height Define the height of the texture
  77618. * @param scene Define the scene the texture belongs to
  77619. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77620. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77621. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77622. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77623. * @returns the RGB alpha texture
  77624. */
  77625. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77626. /**
  77627. * Creates a RGBA texture from some data.
  77628. * @param data Define the texture data
  77629. * @param width Define the width of the texture
  77630. * @param height Define the height of the texture
  77631. * @param scene Define the scene the texture belongs to
  77632. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77633. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77634. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77635. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77636. * @returns the RGBA texture
  77637. */
  77638. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77639. /**
  77640. * Creates a R texture from some data.
  77641. * @param data Define the texture data
  77642. * @param width Define the width of the texture
  77643. * @param height Define the height of the texture
  77644. * @param scene Define the scene the texture belongs to
  77645. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77646. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77647. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77648. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77649. * @returns the R texture
  77650. */
  77651. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77652. }
  77653. }
  77654. declare module BABYLON {
  77655. /**
  77656. * Defines a runtime animation
  77657. */
  77658. export class RuntimeAnimation {
  77659. private _events;
  77660. /**
  77661. * The current frame of the runtime animation
  77662. */
  77663. private _currentFrame;
  77664. /**
  77665. * The animation used by the runtime animation
  77666. */
  77667. private _animation;
  77668. /**
  77669. * The target of the runtime animation
  77670. */
  77671. private _target;
  77672. /**
  77673. * The initiating animatable
  77674. */
  77675. private _host;
  77676. /**
  77677. * The original value of the runtime animation
  77678. */
  77679. private _originalValue;
  77680. /**
  77681. * The original blend value of the runtime animation
  77682. */
  77683. private _originalBlendValue;
  77684. /**
  77685. * The offsets cache of the runtime animation
  77686. */
  77687. private _offsetsCache;
  77688. /**
  77689. * The high limits cache of the runtime animation
  77690. */
  77691. private _highLimitsCache;
  77692. /**
  77693. * Specifies if the runtime animation has been stopped
  77694. */
  77695. private _stopped;
  77696. /**
  77697. * The blending factor of the runtime animation
  77698. */
  77699. private _blendingFactor;
  77700. /**
  77701. * The BabylonJS scene
  77702. */
  77703. private _scene;
  77704. /**
  77705. * The current value of the runtime animation
  77706. */
  77707. private _currentValue;
  77708. /** @hidden */
  77709. _workValue: any;
  77710. /**
  77711. * The active target of the runtime animation
  77712. */
  77713. private _activeTargets;
  77714. private _currentActiveTarget;
  77715. /**
  77716. * The target path of the runtime animation
  77717. */
  77718. private _targetPath;
  77719. /**
  77720. * The weight of the runtime animation
  77721. */
  77722. private _weight;
  77723. /**
  77724. * The ratio offset of the runtime animation
  77725. */
  77726. private _ratioOffset;
  77727. /**
  77728. * The previous delay of the runtime animation
  77729. */
  77730. private _previousDelay;
  77731. /**
  77732. * The previous ratio of the runtime animation
  77733. */
  77734. private _previousRatio;
  77735. private _enableBlending;
  77736. private _correctLoopMode;
  77737. /**
  77738. * Gets the current frame of the runtime animation
  77739. */
  77740. readonly currentFrame: number;
  77741. /**
  77742. * Gets the weight of the runtime animation
  77743. */
  77744. readonly weight: number;
  77745. /**
  77746. * Gets the current value of the runtime animation
  77747. */
  77748. readonly currentValue: any;
  77749. /**
  77750. * Gets the target path of the runtime animation
  77751. */
  77752. readonly targetPath: string;
  77753. /**
  77754. * Gets the actual target of the runtime animation
  77755. */
  77756. readonly target: any;
  77757. /**
  77758. * Create a new RuntimeAnimation object
  77759. * @param target defines the target of the animation
  77760. * @param animation defines the source animation object
  77761. * @param scene defines the hosting scene
  77762. * @param host defines the initiating Animatable
  77763. */
  77764. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  77765. private _preparePath;
  77766. /**
  77767. * Gets the animation from the runtime animation
  77768. */
  77769. readonly animation: Animation;
  77770. /**
  77771. * Resets the runtime animation to the beginning
  77772. * @param restoreOriginal defines whether to restore the target property to the original value
  77773. */
  77774. reset(restoreOriginal?: boolean): void;
  77775. /**
  77776. * Specifies if the runtime animation is stopped
  77777. * @returns Boolean specifying if the runtime animation is stopped
  77778. */
  77779. isStopped(): boolean;
  77780. /**
  77781. * Disposes of the runtime animation
  77782. */
  77783. dispose(): void;
  77784. /**
  77785. * Interpolates the animation from the current frame
  77786. * @param currentFrame The frame to interpolate the animation to
  77787. * @param repeatCount The number of times that the animation should loop
  77788. * @param loopMode The type of looping mode to use
  77789. * @param offsetValue Animation offset value
  77790. * @param highLimitValue The high limit value
  77791. * @returns The interpolated value
  77792. */
  77793. private _interpolate;
  77794. /**
  77795. * Apply the interpolated value to the target
  77796. * @param currentValue defines the value computed by the animation
  77797. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  77798. */
  77799. setValue(currentValue: any, weight?: number): void;
  77800. private _getOriginalValues;
  77801. private _activeBlendingProcessor;
  77802. private _noBlendingProcessor;
  77803. private _blendingProcessor;
  77804. private _setValue;
  77805. /**
  77806. * Gets the loop pmode of the runtime animation
  77807. * @returns Loop Mode
  77808. */
  77809. private _getCorrectLoopMode;
  77810. /**
  77811. * Move the current animation to a given frame
  77812. * @param frame defines the frame to move to
  77813. */
  77814. goToFrame(frame: number): void;
  77815. /**
  77816. * @hidden Internal use only
  77817. */
  77818. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  77819. /**
  77820. * Execute the current animation
  77821. * @param delay defines the delay to add to the current frame
  77822. * @param from defines the lower bound of the animation range
  77823. * @param to defines the upper bound of the animation range
  77824. * @param loop defines if the current animation must loop
  77825. * @param speedRatio defines the current speed ratio
  77826. * @param weight defines the weight of the animation (default is -1 so no weight)
  77827. * @param onLoop optional callback called when animation loops
  77828. * @returns a boolean indicating if the animation is running
  77829. */
  77830. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  77831. }
  77832. }
  77833. declare module BABYLON {
  77834. /**
  77835. * Class used to store an actual running animation
  77836. */
  77837. export class Animatable {
  77838. /** defines the target object */
  77839. target: any;
  77840. /** defines the starting frame number (default is 0) */
  77841. fromFrame: number;
  77842. /** defines the ending frame number (default is 100) */
  77843. toFrame: number;
  77844. /** defines if the animation must loop (default is false) */
  77845. loopAnimation: boolean;
  77846. /** defines a callback to call when animation ends if it is not looping */
  77847. onAnimationEnd?: (() => void) | null | undefined;
  77848. /** defines a callback to call when animation loops */
  77849. onAnimationLoop?: (() => void) | null | undefined;
  77850. private _localDelayOffset;
  77851. private _pausedDelay;
  77852. private _runtimeAnimations;
  77853. private _paused;
  77854. private _scene;
  77855. private _speedRatio;
  77856. private _weight;
  77857. private _syncRoot;
  77858. /**
  77859. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  77860. * This will only apply for non looping animation (default is true)
  77861. */
  77862. disposeOnEnd: boolean;
  77863. /**
  77864. * Gets a boolean indicating if the animation has started
  77865. */
  77866. animationStarted: boolean;
  77867. /**
  77868. * Observer raised when the animation ends
  77869. */
  77870. onAnimationEndObservable: Observable<Animatable>;
  77871. /**
  77872. * Observer raised when the animation loops
  77873. */
  77874. onAnimationLoopObservable: Observable<Animatable>;
  77875. /**
  77876. * Gets the root Animatable used to synchronize and normalize animations
  77877. */
  77878. readonly syncRoot: Animatable;
  77879. /**
  77880. * Gets the current frame of the first RuntimeAnimation
  77881. * Used to synchronize Animatables
  77882. */
  77883. readonly masterFrame: number;
  77884. /**
  77885. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  77886. */
  77887. weight: number;
  77888. /**
  77889. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  77890. */
  77891. speedRatio: number;
  77892. /**
  77893. * Creates a new Animatable
  77894. * @param scene defines the hosting scene
  77895. * @param target defines the target object
  77896. * @param fromFrame defines the starting frame number (default is 0)
  77897. * @param toFrame defines the ending frame number (default is 100)
  77898. * @param loopAnimation defines if the animation must loop (default is false)
  77899. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  77900. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  77901. * @param animations defines a group of animation to add to the new Animatable
  77902. * @param onAnimationLoop defines a callback to call when animation loops
  77903. */
  77904. constructor(scene: Scene,
  77905. /** defines the target object */
  77906. target: any,
  77907. /** defines the starting frame number (default is 0) */
  77908. fromFrame?: number,
  77909. /** defines the ending frame number (default is 100) */
  77910. toFrame?: number,
  77911. /** defines if the animation must loop (default is false) */
  77912. loopAnimation?: boolean, speedRatio?: number,
  77913. /** defines a callback to call when animation ends if it is not looping */
  77914. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  77915. /** defines a callback to call when animation loops */
  77916. onAnimationLoop?: (() => void) | null | undefined);
  77917. /**
  77918. * Synchronize and normalize current Animatable with a source Animatable
  77919. * This is useful when using animation weights and when animations are not of the same length
  77920. * @param root defines the root Animatable to synchronize with
  77921. * @returns the current Animatable
  77922. */
  77923. syncWith(root: Animatable): Animatable;
  77924. /**
  77925. * Gets the list of runtime animations
  77926. * @returns an array of RuntimeAnimation
  77927. */
  77928. getAnimations(): RuntimeAnimation[];
  77929. /**
  77930. * Adds more animations to the current animatable
  77931. * @param target defines the target of the animations
  77932. * @param animations defines the new animations to add
  77933. */
  77934. appendAnimations(target: any, animations: Animation[]): void;
  77935. /**
  77936. * Gets the source animation for a specific property
  77937. * @param property defines the propertyu to look for
  77938. * @returns null or the source animation for the given property
  77939. */
  77940. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  77941. /**
  77942. * Gets the runtime animation for a specific property
  77943. * @param property defines the propertyu to look for
  77944. * @returns null or the runtime animation for the given property
  77945. */
  77946. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  77947. /**
  77948. * Resets the animatable to its original state
  77949. */
  77950. reset(): void;
  77951. /**
  77952. * Allows the animatable to blend with current running animations
  77953. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77954. * @param blendingSpeed defines the blending speed to use
  77955. */
  77956. enableBlending(blendingSpeed: number): void;
  77957. /**
  77958. * Disable animation blending
  77959. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77960. */
  77961. disableBlending(): void;
  77962. /**
  77963. * Jump directly to a given frame
  77964. * @param frame defines the frame to jump to
  77965. */
  77966. goToFrame(frame: number): void;
  77967. /**
  77968. * Pause the animation
  77969. */
  77970. pause(): void;
  77971. /**
  77972. * Restart the animation
  77973. */
  77974. restart(): void;
  77975. private _raiseOnAnimationEnd;
  77976. /**
  77977. * Stop and delete the current animation
  77978. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  77979. * @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)
  77980. */
  77981. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  77982. /**
  77983. * Wait asynchronously for the animation to end
  77984. * @returns a promise which will be fullfilled when the animation ends
  77985. */
  77986. waitAsync(): Promise<Animatable>;
  77987. /** @hidden */
  77988. _animate(delay: number): boolean;
  77989. }
  77990. interface Scene {
  77991. /** @hidden */
  77992. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  77993. /** @hidden */
  77994. _processLateAnimationBindingsForMatrices(holder: {
  77995. totalWeight: number;
  77996. animations: RuntimeAnimation[];
  77997. originalValue: Matrix;
  77998. }): any;
  77999. /** @hidden */
  78000. _processLateAnimationBindingsForQuaternions(holder: {
  78001. totalWeight: number;
  78002. animations: RuntimeAnimation[];
  78003. originalValue: Quaternion;
  78004. }, refQuaternion: Quaternion): Quaternion;
  78005. /** @hidden */
  78006. _processLateAnimationBindings(): void;
  78007. /**
  78008. * Will start the animation sequence of a given target
  78009. * @param target defines the target
  78010. * @param from defines from which frame should animation start
  78011. * @param to defines until which frame should animation run.
  78012. * @param weight defines the weight to apply to the animation (1.0 by default)
  78013. * @param loop defines if the animation loops
  78014. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78015. * @param onAnimationEnd defines the function to be executed when the animation ends
  78016. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78017. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78018. * @param onAnimationLoop defines the callback to call when an animation loops
  78019. * @returns the animatable object created for this animation
  78020. */
  78021. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78022. /**
  78023. * Will start the animation sequence of a given target
  78024. * @param target defines the target
  78025. * @param from defines from which frame should animation start
  78026. * @param to defines until which frame should animation run.
  78027. * @param loop defines if the animation loops
  78028. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78029. * @param onAnimationEnd defines the function to be executed when the animation ends
  78030. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78031. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78032. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78033. * @param onAnimationLoop defines the callback to call when an animation loops
  78034. * @returns the animatable object created for this animation
  78035. */
  78036. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78037. /**
  78038. * Will start the animation sequence of a given target and its hierarchy
  78039. * @param target defines the target
  78040. * @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.
  78041. * @param from defines from which frame should animation start
  78042. * @param to defines until which frame should animation run.
  78043. * @param loop defines if the animation loops
  78044. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78045. * @param onAnimationEnd defines the function to be executed when the animation ends
  78046. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78047. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78048. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78049. * @param onAnimationLoop defines the callback to call when an animation loops
  78050. * @returns the list of created animatables
  78051. */
  78052. 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[];
  78053. /**
  78054. * Begin a new animation on a given node
  78055. * @param target defines the target where the animation will take place
  78056. * @param animations defines the list of animations to start
  78057. * @param from defines the initial value
  78058. * @param to defines the final value
  78059. * @param loop defines if you want animation to loop (off by default)
  78060. * @param speedRatio defines the speed ratio to apply to all animations
  78061. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78062. * @param onAnimationLoop defines the callback to call when an animation loops
  78063. * @returns the list of created animatables
  78064. */
  78065. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78066. /**
  78067. * Begin a new animation on a given node and its hierarchy
  78068. * @param target defines the root node where the animation will take place
  78069. * @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.
  78070. * @param animations defines the list of animations to start
  78071. * @param from defines the initial value
  78072. * @param to defines the final value
  78073. * @param loop defines if you want animation to loop (off by default)
  78074. * @param speedRatio defines the speed ratio to apply to all animations
  78075. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78076. * @param onAnimationLoop defines the callback to call when an animation loops
  78077. * @returns the list of animatables created for all nodes
  78078. */
  78079. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  78080. /**
  78081. * Gets the animatable associated with a specific target
  78082. * @param target defines the target of the animatable
  78083. * @returns the required animatable if found
  78084. */
  78085. getAnimatableByTarget(target: any): Nullable<Animatable>;
  78086. /**
  78087. * Gets all animatables associated with a given target
  78088. * @param target defines the target to look animatables for
  78089. * @returns an array of Animatables
  78090. */
  78091. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  78092. /**
  78093. * Will stop the animation of the given target
  78094. * @param target - the target
  78095. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  78096. * @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)
  78097. */
  78098. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  78099. /**
  78100. * Stops and removes all animations that have been applied to the scene
  78101. */
  78102. stopAllAnimations(): void;
  78103. }
  78104. interface Bone {
  78105. /**
  78106. * Copy an animation range from another bone
  78107. * @param source defines the source bone
  78108. * @param rangeName defines the range name to copy
  78109. * @param frameOffset defines the frame offset
  78110. * @param rescaleAsRequired defines if rescaling must be applied if required
  78111. * @param skelDimensionsRatio defines the scaling ratio
  78112. * @returns true if operation was successful
  78113. */
  78114. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  78115. }
  78116. }
  78117. declare module BABYLON {
  78118. /**
  78119. * Class used to handle skinning animations
  78120. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78121. */
  78122. export class Skeleton implements IAnimatable {
  78123. /** defines the skeleton name */
  78124. name: string;
  78125. /** defines the skeleton Id */
  78126. id: string;
  78127. /**
  78128. * Defines the list of child bones
  78129. */
  78130. bones: Bone[];
  78131. /**
  78132. * Defines an estimate of the dimension of the skeleton at rest
  78133. */
  78134. dimensionsAtRest: Vector3;
  78135. /**
  78136. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  78137. */
  78138. needInitialSkinMatrix: boolean;
  78139. /**
  78140. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  78141. */
  78142. overrideMesh: Nullable<AbstractMesh>;
  78143. /**
  78144. * Gets the list of animations attached to this skeleton
  78145. */
  78146. animations: Array<Animation>;
  78147. private _scene;
  78148. private _isDirty;
  78149. private _transformMatrices;
  78150. private _transformMatrixTexture;
  78151. private _meshesWithPoseMatrix;
  78152. private _animatables;
  78153. private _identity;
  78154. private _synchronizedWithMesh;
  78155. private _ranges;
  78156. private _lastAbsoluteTransformsUpdateId;
  78157. private _canUseTextureForBones;
  78158. private _uniqueId;
  78159. /** @hidden */
  78160. _numBonesWithLinkedTransformNode: number;
  78161. /**
  78162. * Specifies if the skeleton should be serialized
  78163. */
  78164. doNotSerialize: boolean;
  78165. private _useTextureToStoreBoneMatrices;
  78166. /**
  78167. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  78168. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  78169. */
  78170. useTextureToStoreBoneMatrices: boolean;
  78171. private _animationPropertiesOverride;
  78172. /**
  78173. * Gets or sets the animation properties override
  78174. */
  78175. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78176. /**
  78177. * List of inspectable custom properties (used by the Inspector)
  78178. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78179. */
  78180. inspectableCustomProperties: IInspectable[];
  78181. /**
  78182. * An observable triggered before computing the skeleton's matrices
  78183. */
  78184. onBeforeComputeObservable: Observable<Skeleton>;
  78185. /**
  78186. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  78187. */
  78188. readonly isUsingTextureForMatrices: boolean;
  78189. /**
  78190. * Gets the unique ID of this skeleton
  78191. */
  78192. readonly uniqueId: number;
  78193. /**
  78194. * Creates a new skeleton
  78195. * @param name defines the skeleton name
  78196. * @param id defines the skeleton Id
  78197. * @param scene defines the hosting scene
  78198. */
  78199. constructor(
  78200. /** defines the skeleton name */
  78201. name: string,
  78202. /** defines the skeleton Id */
  78203. id: string, scene: Scene);
  78204. /**
  78205. * Gets the current object class name.
  78206. * @return the class name
  78207. */
  78208. getClassName(): string;
  78209. /**
  78210. * Returns an array containing the root bones
  78211. * @returns an array containing the root bones
  78212. */
  78213. getChildren(): Array<Bone>;
  78214. /**
  78215. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  78216. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78217. * @returns a Float32Array containing matrices data
  78218. */
  78219. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  78220. /**
  78221. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  78222. * @returns a raw texture containing the data
  78223. */
  78224. getTransformMatrixTexture(): Nullable<RawTexture>;
  78225. /**
  78226. * Gets the current hosting scene
  78227. * @returns a scene object
  78228. */
  78229. getScene(): Scene;
  78230. /**
  78231. * Gets a string representing the current skeleton data
  78232. * @param fullDetails defines a boolean indicating if we want a verbose version
  78233. * @returns a string representing the current skeleton data
  78234. */
  78235. toString(fullDetails?: boolean): string;
  78236. /**
  78237. * Get bone's index searching by name
  78238. * @param name defines bone's name to search for
  78239. * @return the indice of the bone. Returns -1 if not found
  78240. */
  78241. getBoneIndexByName(name: string): number;
  78242. /**
  78243. * Creater a new animation range
  78244. * @param name defines the name of the range
  78245. * @param from defines the start key
  78246. * @param to defines the end key
  78247. */
  78248. createAnimationRange(name: string, from: number, to: number): void;
  78249. /**
  78250. * Delete a specific animation range
  78251. * @param name defines the name of the range
  78252. * @param deleteFrames defines if frames must be removed as well
  78253. */
  78254. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  78255. /**
  78256. * Gets a specific animation range
  78257. * @param name defines the name of the range to look for
  78258. * @returns the requested animation range or null if not found
  78259. */
  78260. getAnimationRange(name: string): Nullable<AnimationRange>;
  78261. /**
  78262. * Gets the list of all animation ranges defined on this skeleton
  78263. * @returns an array
  78264. */
  78265. getAnimationRanges(): Nullable<AnimationRange>[];
  78266. /**
  78267. * Copy animation range from a source skeleton.
  78268. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  78269. * @param source defines the source skeleton
  78270. * @param name defines the name of the range to copy
  78271. * @param rescaleAsRequired defines if rescaling must be applied if required
  78272. * @returns true if operation was successful
  78273. */
  78274. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  78275. /**
  78276. * Forces the skeleton to go to rest pose
  78277. */
  78278. returnToRest(): void;
  78279. private _getHighestAnimationFrame;
  78280. /**
  78281. * Begin a specific animation range
  78282. * @param name defines the name of the range to start
  78283. * @param loop defines if looping must be turned on (false by default)
  78284. * @param speedRatio defines the speed ratio to apply (1 by default)
  78285. * @param onAnimationEnd defines a callback which will be called when animation will end
  78286. * @returns a new animatable
  78287. */
  78288. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  78289. /** @hidden */
  78290. _markAsDirty(): void;
  78291. /** @hidden */
  78292. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78293. /** @hidden */
  78294. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78295. private _computeTransformMatrices;
  78296. /**
  78297. * Build all resources required to render a skeleton
  78298. */
  78299. prepare(): void;
  78300. /**
  78301. * Gets the list of animatables currently running for this skeleton
  78302. * @returns an array of animatables
  78303. */
  78304. getAnimatables(): IAnimatable[];
  78305. /**
  78306. * Clone the current skeleton
  78307. * @param name defines the name of the new skeleton
  78308. * @param id defines the id of the enw skeleton
  78309. * @returns the new skeleton
  78310. */
  78311. clone(name: string, id: string): Skeleton;
  78312. /**
  78313. * Enable animation blending for this skeleton
  78314. * @param blendingSpeed defines the blending speed to apply
  78315. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78316. */
  78317. enableBlending(blendingSpeed?: number): void;
  78318. /**
  78319. * Releases all resources associated with the current skeleton
  78320. */
  78321. dispose(): void;
  78322. /**
  78323. * Serialize the skeleton in a JSON object
  78324. * @returns a JSON object
  78325. */
  78326. serialize(): any;
  78327. /**
  78328. * Creates a new skeleton from serialized data
  78329. * @param parsedSkeleton defines the serialized data
  78330. * @param scene defines the hosting scene
  78331. * @returns a new skeleton
  78332. */
  78333. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  78334. /**
  78335. * Compute all node absolute transforms
  78336. * @param forceUpdate defines if computation must be done even if cache is up to date
  78337. */
  78338. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  78339. /**
  78340. * Gets the root pose matrix
  78341. * @returns a matrix
  78342. */
  78343. getPoseMatrix(): Nullable<Matrix>;
  78344. /**
  78345. * Sorts bones per internal index
  78346. */
  78347. sortBones(): void;
  78348. private _sortBones;
  78349. }
  78350. }
  78351. declare module BABYLON {
  78352. /**
  78353. * Defines a target to use with MorphTargetManager
  78354. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78355. */
  78356. export class MorphTarget implements IAnimatable {
  78357. /** defines the name of the target */
  78358. name: string;
  78359. /**
  78360. * Gets or sets the list of animations
  78361. */
  78362. animations: Animation[];
  78363. private _scene;
  78364. private _positions;
  78365. private _normals;
  78366. private _tangents;
  78367. private _influence;
  78368. /**
  78369. * Observable raised when the influence changes
  78370. */
  78371. onInfluenceChanged: Observable<boolean>;
  78372. /** @hidden */
  78373. _onDataLayoutChanged: Observable<void>;
  78374. /**
  78375. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  78376. */
  78377. influence: number;
  78378. /**
  78379. * Gets or sets the id of the morph Target
  78380. */
  78381. id: string;
  78382. private _animationPropertiesOverride;
  78383. /**
  78384. * Gets or sets the animation properties override
  78385. */
  78386. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78387. /**
  78388. * Creates a new MorphTarget
  78389. * @param name defines the name of the target
  78390. * @param influence defines the influence to use
  78391. * @param scene defines the scene the morphtarget belongs to
  78392. */
  78393. constructor(
  78394. /** defines the name of the target */
  78395. name: string, influence?: number, scene?: Nullable<Scene>);
  78396. /**
  78397. * Gets a boolean defining if the target contains position data
  78398. */
  78399. readonly hasPositions: boolean;
  78400. /**
  78401. * Gets a boolean defining if the target contains normal data
  78402. */
  78403. readonly hasNormals: boolean;
  78404. /**
  78405. * Gets a boolean defining if the target contains tangent data
  78406. */
  78407. readonly hasTangents: boolean;
  78408. /**
  78409. * Affects position data to this target
  78410. * @param data defines the position data to use
  78411. */
  78412. setPositions(data: Nullable<FloatArray>): void;
  78413. /**
  78414. * Gets the position data stored in this target
  78415. * @returns a FloatArray containing the position data (or null if not present)
  78416. */
  78417. getPositions(): Nullable<FloatArray>;
  78418. /**
  78419. * Affects normal data to this target
  78420. * @param data defines the normal data to use
  78421. */
  78422. setNormals(data: Nullable<FloatArray>): void;
  78423. /**
  78424. * Gets the normal data stored in this target
  78425. * @returns a FloatArray containing the normal data (or null if not present)
  78426. */
  78427. getNormals(): Nullable<FloatArray>;
  78428. /**
  78429. * Affects tangent data to this target
  78430. * @param data defines the tangent data to use
  78431. */
  78432. setTangents(data: Nullable<FloatArray>): void;
  78433. /**
  78434. * Gets the tangent data stored in this target
  78435. * @returns a FloatArray containing the tangent data (or null if not present)
  78436. */
  78437. getTangents(): Nullable<FloatArray>;
  78438. /**
  78439. * Serializes the current target into a Serialization object
  78440. * @returns the serialized object
  78441. */
  78442. serialize(): any;
  78443. /**
  78444. * Returns the string "MorphTarget"
  78445. * @returns "MorphTarget"
  78446. */
  78447. getClassName(): string;
  78448. /**
  78449. * Creates a new target from serialized data
  78450. * @param serializationObject defines the serialized data to use
  78451. * @returns a new MorphTarget
  78452. */
  78453. static Parse(serializationObject: any): MorphTarget;
  78454. /**
  78455. * Creates a MorphTarget from mesh data
  78456. * @param mesh defines the source mesh
  78457. * @param name defines the name to use for the new target
  78458. * @param influence defines the influence to attach to the target
  78459. * @returns a new MorphTarget
  78460. */
  78461. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  78462. }
  78463. }
  78464. declare module BABYLON {
  78465. /**
  78466. * This class is used to deform meshes using morphing between different targets
  78467. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78468. */
  78469. export class MorphTargetManager {
  78470. private _targets;
  78471. private _targetInfluenceChangedObservers;
  78472. private _targetDataLayoutChangedObservers;
  78473. private _activeTargets;
  78474. private _scene;
  78475. private _influences;
  78476. private _supportsNormals;
  78477. private _supportsTangents;
  78478. private _vertexCount;
  78479. private _uniqueId;
  78480. private _tempInfluences;
  78481. /**
  78482. * Creates a new MorphTargetManager
  78483. * @param scene defines the current scene
  78484. */
  78485. constructor(scene?: Nullable<Scene>);
  78486. /**
  78487. * Gets the unique ID of this manager
  78488. */
  78489. readonly uniqueId: number;
  78490. /**
  78491. * Gets the number of vertices handled by this manager
  78492. */
  78493. readonly vertexCount: number;
  78494. /**
  78495. * Gets a boolean indicating if this manager supports morphing of normals
  78496. */
  78497. readonly supportsNormals: boolean;
  78498. /**
  78499. * Gets a boolean indicating if this manager supports morphing of tangents
  78500. */
  78501. readonly supportsTangents: boolean;
  78502. /**
  78503. * Gets the number of targets stored in this manager
  78504. */
  78505. readonly numTargets: number;
  78506. /**
  78507. * Gets the number of influencers (ie. the number of targets with influences > 0)
  78508. */
  78509. readonly numInfluencers: number;
  78510. /**
  78511. * Gets the list of influences (one per target)
  78512. */
  78513. readonly influences: Float32Array;
  78514. /**
  78515. * Gets the active target at specified index. An active target is a target with an influence > 0
  78516. * @param index defines the index to check
  78517. * @returns the requested target
  78518. */
  78519. getActiveTarget(index: number): MorphTarget;
  78520. /**
  78521. * Gets the target at specified index
  78522. * @param index defines the index to check
  78523. * @returns the requested target
  78524. */
  78525. getTarget(index: number): MorphTarget;
  78526. /**
  78527. * Add a new target to this manager
  78528. * @param target defines the target to add
  78529. */
  78530. addTarget(target: MorphTarget): void;
  78531. /**
  78532. * Removes a target from the manager
  78533. * @param target defines the target to remove
  78534. */
  78535. removeTarget(target: MorphTarget): void;
  78536. /**
  78537. * Serializes the current manager into a Serialization object
  78538. * @returns the serialized object
  78539. */
  78540. serialize(): any;
  78541. private _syncActiveTargets;
  78542. /**
  78543. * Syncrhonize the targets with all the meshes using this morph target manager
  78544. */
  78545. synchronize(): void;
  78546. /**
  78547. * Creates a new MorphTargetManager from serialized data
  78548. * @param serializationObject defines the serialized data
  78549. * @param scene defines the hosting scene
  78550. * @returns the new MorphTargetManager
  78551. */
  78552. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  78553. }
  78554. }
  78555. declare module BABYLON {
  78556. /**
  78557. * Mesh representing the gorund
  78558. */
  78559. export class GroundMesh extends Mesh {
  78560. /** If octree should be generated */
  78561. generateOctree: boolean;
  78562. private _heightQuads;
  78563. /** @hidden */
  78564. _subdivisionsX: number;
  78565. /** @hidden */
  78566. _subdivisionsY: number;
  78567. /** @hidden */
  78568. _width: number;
  78569. /** @hidden */
  78570. _height: number;
  78571. /** @hidden */
  78572. _minX: number;
  78573. /** @hidden */
  78574. _maxX: number;
  78575. /** @hidden */
  78576. _minZ: number;
  78577. /** @hidden */
  78578. _maxZ: number;
  78579. constructor(name: string, scene: Scene);
  78580. /**
  78581. * "GroundMesh"
  78582. * @returns "GroundMesh"
  78583. */
  78584. getClassName(): string;
  78585. /**
  78586. * The minimum of x and y subdivisions
  78587. */
  78588. readonly subdivisions: number;
  78589. /**
  78590. * X subdivisions
  78591. */
  78592. readonly subdivisionsX: number;
  78593. /**
  78594. * Y subdivisions
  78595. */
  78596. readonly subdivisionsY: number;
  78597. /**
  78598. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  78599. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  78600. * @param chunksCount the number of subdivisions for x and y
  78601. * @param octreeBlocksSize (Default: 32)
  78602. */
  78603. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  78604. /**
  78605. * Returns a height (y) value in the Worl system :
  78606. * the ground altitude at the coordinates (x, z) expressed in the World system.
  78607. * @param x x coordinate
  78608. * @param z z coordinate
  78609. * @returns the ground y position if (x, z) are outside the ground surface.
  78610. */
  78611. getHeightAtCoordinates(x: number, z: number): number;
  78612. /**
  78613. * Returns a normalized vector (Vector3) orthogonal to the ground
  78614. * at the ground coordinates (x, z) expressed in the World system.
  78615. * @param x x coordinate
  78616. * @param z z coordinate
  78617. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  78618. */
  78619. getNormalAtCoordinates(x: number, z: number): Vector3;
  78620. /**
  78621. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  78622. * at the ground coordinates (x, z) expressed in the World system.
  78623. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  78624. * @param x x coordinate
  78625. * @param z z coordinate
  78626. * @param ref vector to store the result
  78627. * @returns the GroundMesh.
  78628. */
  78629. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  78630. /**
  78631. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  78632. * if the ground has been updated.
  78633. * This can be used in the render loop.
  78634. * @returns the GroundMesh.
  78635. */
  78636. updateCoordinateHeights(): GroundMesh;
  78637. private _getFacetAt;
  78638. private _initHeightQuads;
  78639. private _computeHeightQuads;
  78640. /**
  78641. * Serializes this ground mesh
  78642. * @param serializationObject object to write serialization to
  78643. */
  78644. serialize(serializationObject: any): void;
  78645. /**
  78646. * Parses a serialized ground mesh
  78647. * @param parsedMesh the serialized mesh
  78648. * @param scene the scene to create the ground mesh in
  78649. * @returns the created ground mesh
  78650. */
  78651. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  78652. }
  78653. }
  78654. declare module BABYLON {
  78655. /**
  78656. * Interface for Physics-Joint data
  78657. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78658. */
  78659. export interface PhysicsJointData {
  78660. /**
  78661. * The main pivot of the joint
  78662. */
  78663. mainPivot?: Vector3;
  78664. /**
  78665. * The connected pivot of the joint
  78666. */
  78667. connectedPivot?: Vector3;
  78668. /**
  78669. * The main axis of the joint
  78670. */
  78671. mainAxis?: Vector3;
  78672. /**
  78673. * The connected axis of the joint
  78674. */
  78675. connectedAxis?: Vector3;
  78676. /**
  78677. * The collision of the joint
  78678. */
  78679. collision?: boolean;
  78680. /**
  78681. * Native Oimo/Cannon/Energy data
  78682. */
  78683. nativeParams?: any;
  78684. }
  78685. /**
  78686. * This is a holder class for the physics joint created by the physics plugin
  78687. * It holds a set of functions to control the underlying joint
  78688. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78689. */
  78690. export class PhysicsJoint {
  78691. /**
  78692. * The type of the physics joint
  78693. */
  78694. type: number;
  78695. /**
  78696. * The data for the physics joint
  78697. */
  78698. jointData: PhysicsJointData;
  78699. private _physicsJoint;
  78700. protected _physicsPlugin: IPhysicsEnginePlugin;
  78701. /**
  78702. * Initializes the physics joint
  78703. * @param type The type of the physics joint
  78704. * @param jointData The data for the physics joint
  78705. */
  78706. constructor(
  78707. /**
  78708. * The type of the physics joint
  78709. */
  78710. type: number,
  78711. /**
  78712. * The data for the physics joint
  78713. */
  78714. jointData: PhysicsJointData);
  78715. /**
  78716. * Gets the physics joint
  78717. */
  78718. /**
  78719. * Sets the physics joint
  78720. */
  78721. physicsJoint: any;
  78722. /**
  78723. * Sets the physics plugin
  78724. */
  78725. physicsPlugin: IPhysicsEnginePlugin;
  78726. /**
  78727. * Execute a function that is physics-plugin specific.
  78728. * @param {Function} func the function that will be executed.
  78729. * It accepts two parameters: the physics world and the physics joint
  78730. */
  78731. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  78732. /**
  78733. * Distance-Joint type
  78734. */
  78735. static DistanceJoint: number;
  78736. /**
  78737. * Hinge-Joint type
  78738. */
  78739. static HingeJoint: number;
  78740. /**
  78741. * Ball-and-Socket joint type
  78742. */
  78743. static BallAndSocketJoint: number;
  78744. /**
  78745. * Wheel-Joint type
  78746. */
  78747. static WheelJoint: number;
  78748. /**
  78749. * Slider-Joint type
  78750. */
  78751. static SliderJoint: number;
  78752. /**
  78753. * Prismatic-Joint type
  78754. */
  78755. static PrismaticJoint: number;
  78756. /**
  78757. * Universal-Joint type
  78758. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  78759. */
  78760. static UniversalJoint: number;
  78761. /**
  78762. * Hinge-Joint 2 type
  78763. */
  78764. static Hinge2Joint: number;
  78765. /**
  78766. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  78767. */
  78768. static PointToPointJoint: number;
  78769. /**
  78770. * Spring-Joint type
  78771. */
  78772. static SpringJoint: number;
  78773. /**
  78774. * Lock-Joint type
  78775. */
  78776. static LockJoint: number;
  78777. }
  78778. /**
  78779. * A class representing a physics distance joint
  78780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78781. */
  78782. export class DistanceJoint extends PhysicsJoint {
  78783. /**
  78784. *
  78785. * @param jointData The data for the Distance-Joint
  78786. */
  78787. constructor(jointData: DistanceJointData);
  78788. /**
  78789. * Update the predefined distance.
  78790. * @param maxDistance The maximum preferred distance
  78791. * @param minDistance The minimum preferred distance
  78792. */
  78793. updateDistance(maxDistance: number, minDistance?: number): void;
  78794. }
  78795. /**
  78796. * Represents a Motor-Enabled Joint
  78797. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78798. */
  78799. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  78800. /**
  78801. * Initializes the Motor-Enabled Joint
  78802. * @param type The type of the joint
  78803. * @param jointData The physica joint data for the joint
  78804. */
  78805. constructor(type: number, jointData: PhysicsJointData);
  78806. /**
  78807. * Set the motor values.
  78808. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78809. * @param force the force to apply
  78810. * @param maxForce max force for this motor.
  78811. */
  78812. setMotor(force?: number, maxForce?: number): void;
  78813. /**
  78814. * Set the motor's limits.
  78815. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78816. * @param upperLimit The upper limit of the motor
  78817. * @param lowerLimit The lower limit of the motor
  78818. */
  78819. setLimit(upperLimit: number, lowerLimit?: number): void;
  78820. }
  78821. /**
  78822. * This class represents a single physics Hinge-Joint
  78823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78824. */
  78825. export class HingeJoint extends MotorEnabledJoint {
  78826. /**
  78827. * Initializes the Hinge-Joint
  78828. * @param jointData The joint data for the Hinge-Joint
  78829. */
  78830. constructor(jointData: PhysicsJointData);
  78831. /**
  78832. * Set the motor values.
  78833. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78834. * @param {number} force the force to apply
  78835. * @param {number} maxForce max force for this motor.
  78836. */
  78837. setMotor(force?: number, maxForce?: number): void;
  78838. /**
  78839. * Set the motor's limits.
  78840. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78841. * @param upperLimit The upper limit of the motor
  78842. * @param lowerLimit The lower limit of the motor
  78843. */
  78844. setLimit(upperLimit: number, lowerLimit?: number): void;
  78845. }
  78846. /**
  78847. * This class represents a dual hinge physics joint (same as wheel joint)
  78848. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78849. */
  78850. export class Hinge2Joint extends MotorEnabledJoint {
  78851. /**
  78852. * Initializes the Hinge2-Joint
  78853. * @param jointData The joint data for the Hinge2-Joint
  78854. */
  78855. constructor(jointData: PhysicsJointData);
  78856. /**
  78857. * Set the motor values.
  78858. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78859. * @param {number} targetSpeed the speed the motor is to reach
  78860. * @param {number} maxForce max force for this motor.
  78861. * @param {motorIndex} the motor's index, 0 or 1.
  78862. */
  78863. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  78864. /**
  78865. * Set the motor limits.
  78866. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78867. * @param {number} upperLimit the upper limit
  78868. * @param {number} lowerLimit lower limit
  78869. * @param {motorIndex} the motor's index, 0 or 1.
  78870. */
  78871. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78872. }
  78873. /**
  78874. * Interface for a motor enabled joint
  78875. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78876. */
  78877. export interface IMotorEnabledJoint {
  78878. /**
  78879. * Physics joint
  78880. */
  78881. physicsJoint: any;
  78882. /**
  78883. * Sets the motor of the motor-enabled joint
  78884. * @param force The force of the motor
  78885. * @param maxForce The maximum force of the motor
  78886. * @param motorIndex The index of the motor
  78887. */
  78888. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  78889. /**
  78890. * Sets the limit of the motor
  78891. * @param upperLimit The upper limit of the motor
  78892. * @param lowerLimit The lower limit of the motor
  78893. * @param motorIndex The index of the motor
  78894. */
  78895. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78896. }
  78897. /**
  78898. * Joint data for a Distance-Joint
  78899. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78900. */
  78901. export interface DistanceJointData extends PhysicsJointData {
  78902. /**
  78903. * Max distance the 2 joint objects can be apart
  78904. */
  78905. maxDistance: number;
  78906. }
  78907. /**
  78908. * Joint data from a spring joint
  78909. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78910. */
  78911. export interface SpringJointData extends PhysicsJointData {
  78912. /**
  78913. * Length of the spring
  78914. */
  78915. length: number;
  78916. /**
  78917. * Stiffness of the spring
  78918. */
  78919. stiffness: number;
  78920. /**
  78921. * Damping of the spring
  78922. */
  78923. damping: number;
  78924. /** this callback will be called when applying the force to the impostors. */
  78925. forceApplicationCallback: () => void;
  78926. }
  78927. }
  78928. declare module BABYLON {
  78929. /**
  78930. * Holds the data for the raycast result
  78931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78932. */
  78933. export class PhysicsRaycastResult {
  78934. private _hasHit;
  78935. private _hitDistance;
  78936. private _hitNormalWorld;
  78937. private _hitPointWorld;
  78938. private _rayFromWorld;
  78939. private _rayToWorld;
  78940. /**
  78941. * Gets if there was a hit
  78942. */
  78943. readonly hasHit: boolean;
  78944. /**
  78945. * Gets the distance from the hit
  78946. */
  78947. readonly hitDistance: number;
  78948. /**
  78949. * Gets the hit normal/direction in the world
  78950. */
  78951. readonly hitNormalWorld: Vector3;
  78952. /**
  78953. * Gets the hit point in the world
  78954. */
  78955. readonly hitPointWorld: Vector3;
  78956. /**
  78957. * Gets the ray "start point" of the ray in the world
  78958. */
  78959. readonly rayFromWorld: Vector3;
  78960. /**
  78961. * Gets the ray "end point" of the ray in the world
  78962. */
  78963. readonly rayToWorld: Vector3;
  78964. /**
  78965. * Sets the hit data (normal & point in world space)
  78966. * @param hitNormalWorld defines the normal in world space
  78967. * @param hitPointWorld defines the point in world space
  78968. */
  78969. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  78970. /**
  78971. * Sets the distance from the start point to the hit point
  78972. * @param distance
  78973. */
  78974. setHitDistance(distance: number): void;
  78975. /**
  78976. * Calculates the distance manually
  78977. */
  78978. calculateHitDistance(): void;
  78979. /**
  78980. * Resets all the values to default
  78981. * @param from The from point on world space
  78982. * @param to The to point on world space
  78983. */
  78984. reset(from?: Vector3, to?: Vector3): void;
  78985. }
  78986. /**
  78987. * Interface for the size containing width and height
  78988. */
  78989. interface IXYZ {
  78990. /**
  78991. * X
  78992. */
  78993. x: number;
  78994. /**
  78995. * Y
  78996. */
  78997. y: number;
  78998. /**
  78999. * Z
  79000. */
  79001. z: number;
  79002. }
  79003. }
  79004. declare module BABYLON {
  79005. /**
  79006. * Interface used to describe a physics joint
  79007. */
  79008. export interface PhysicsImpostorJoint {
  79009. /** Defines the main impostor to which the joint is linked */
  79010. mainImpostor: PhysicsImpostor;
  79011. /** Defines the impostor that is connected to the main impostor using this joint */
  79012. connectedImpostor: PhysicsImpostor;
  79013. /** Defines the joint itself */
  79014. joint: PhysicsJoint;
  79015. }
  79016. /** @hidden */
  79017. export interface IPhysicsEnginePlugin {
  79018. world: any;
  79019. name: string;
  79020. setGravity(gravity: Vector3): void;
  79021. setTimeStep(timeStep: number): void;
  79022. getTimeStep(): number;
  79023. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  79024. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79025. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79026. generatePhysicsBody(impostor: PhysicsImpostor): void;
  79027. removePhysicsBody(impostor: PhysicsImpostor): void;
  79028. generateJoint(joint: PhysicsImpostorJoint): void;
  79029. removeJoint(joint: PhysicsImpostorJoint): void;
  79030. isSupported(): boolean;
  79031. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  79032. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  79033. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  79034. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  79035. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  79036. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  79037. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  79038. getBodyMass(impostor: PhysicsImpostor): number;
  79039. getBodyFriction(impostor: PhysicsImpostor): number;
  79040. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  79041. getBodyRestitution(impostor: PhysicsImpostor): number;
  79042. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  79043. getBodyPressure?(impostor: PhysicsImpostor): number;
  79044. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  79045. getBodyStiffness?(impostor: PhysicsImpostor): number;
  79046. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  79047. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  79048. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  79049. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  79050. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  79051. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  79052. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  79053. sleepBody(impostor: PhysicsImpostor): void;
  79054. wakeUpBody(impostor: PhysicsImpostor): void;
  79055. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  79056. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  79057. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  79058. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79059. getRadius(impostor: PhysicsImpostor): number;
  79060. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  79061. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  79062. dispose(): void;
  79063. }
  79064. /**
  79065. * Interface used to define a physics engine
  79066. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  79067. */
  79068. export interface IPhysicsEngine {
  79069. /**
  79070. * Gets the gravity vector used by the simulation
  79071. */
  79072. gravity: Vector3;
  79073. /**
  79074. * Sets the gravity vector used by the simulation
  79075. * @param gravity defines the gravity vector to use
  79076. */
  79077. setGravity(gravity: Vector3): void;
  79078. /**
  79079. * Set the time step of the physics engine.
  79080. * Default is 1/60.
  79081. * To slow it down, enter 1/600 for example.
  79082. * To speed it up, 1/30
  79083. * @param newTimeStep the new timestep to apply to this world.
  79084. */
  79085. setTimeStep(newTimeStep: number): void;
  79086. /**
  79087. * Get the time step of the physics engine.
  79088. * @returns the current time step
  79089. */
  79090. getTimeStep(): number;
  79091. /**
  79092. * Release all resources
  79093. */
  79094. dispose(): void;
  79095. /**
  79096. * Gets the name of the current physics plugin
  79097. * @returns the name of the plugin
  79098. */
  79099. getPhysicsPluginName(): string;
  79100. /**
  79101. * Adding a new impostor for the impostor tracking.
  79102. * This will be done by the impostor itself.
  79103. * @param impostor the impostor to add
  79104. */
  79105. addImpostor(impostor: PhysicsImpostor): void;
  79106. /**
  79107. * Remove an impostor from the engine.
  79108. * This impostor and its mesh will not longer be updated by the physics engine.
  79109. * @param impostor the impostor to remove
  79110. */
  79111. removeImpostor(impostor: PhysicsImpostor): void;
  79112. /**
  79113. * Add a joint to the physics engine
  79114. * @param mainImpostor defines the main impostor to which the joint is added.
  79115. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  79116. * @param joint defines the joint that will connect both impostors.
  79117. */
  79118. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  79119. /**
  79120. * Removes a joint from the simulation
  79121. * @param mainImpostor defines the impostor used with the joint
  79122. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  79123. * @param joint defines the joint to remove
  79124. */
  79125. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  79126. /**
  79127. * Gets the current plugin used to run the simulation
  79128. * @returns current plugin
  79129. */
  79130. getPhysicsPlugin(): IPhysicsEnginePlugin;
  79131. /**
  79132. * Gets the list of physic impostors
  79133. * @returns an array of PhysicsImpostor
  79134. */
  79135. getImpostors(): Array<PhysicsImpostor>;
  79136. /**
  79137. * Gets the impostor for a physics enabled object
  79138. * @param object defines the object impersonated by the impostor
  79139. * @returns the PhysicsImpostor or null if not found
  79140. */
  79141. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  79142. /**
  79143. * Gets the impostor for a physics body object
  79144. * @param body defines physics body used by the impostor
  79145. * @returns the PhysicsImpostor or null if not found
  79146. */
  79147. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  79148. /**
  79149. * Does a raycast in the physics world
  79150. * @param from when should the ray start?
  79151. * @param to when should the ray end?
  79152. * @returns PhysicsRaycastResult
  79153. */
  79154. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  79155. /**
  79156. * Called by the scene. No need to call it.
  79157. * @param delta defines the timespam between frames
  79158. */
  79159. _step(delta: number): void;
  79160. }
  79161. }
  79162. declare module BABYLON {
  79163. /**
  79164. * The interface for the physics imposter parameters
  79165. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79166. */
  79167. export interface PhysicsImpostorParameters {
  79168. /**
  79169. * The mass of the physics imposter
  79170. */
  79171. mass: number;
  79172. /**
  79173. * The friction of the physics imposter
  79174. */
  79175. friction?: number;
  79176. /**
  79177. * The coefficient of restitution of the physics imposter
  79178. */
  79179. restitution?: number;
  79180. /**
  79181. * The native options of the physics imposter
  79182. */
  79183. nativeOptions?: any;
  79184. /**
  79185. * Specifies if the parent should be ignored
  79186. */
  79187. ignoreParent?: boolean;
  79188. /**
  79189. * Specifies if bi-directional transformations should be disabled
  79190. */
  79191. disableBidirectionalTransformation?: boolean;
  79192. /**
  79193. * The pressure inside the physics imposter, soft object only
  79194. */
  79195. pressure?: number;
  79196. /**
  79197. * The stiffness the physics imposter, soft object only
  79198. */
  79199. stiffness?: number;
  79200. /**
  79201. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  79202. */
  79203. velocityIterations?: number;
  79204. /**
  79205. * The number of iterations used in maintaining consistent vertex positions, soft object only
  79206. */
  79207. positionIterations?: number;
  79208. /**
  79209. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  79210. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  79211. * Add to fix multiple points
  79212. */
  79213. fixedPoints?: number;
  79214. /**
  79215. * The collision margin around a soft object
  79216. */
  79217. margin?: number;
  79218. /**
  79219. * The collision margin around a soft object
  79220. */
  79221. damping?: number;
  79222. /**
  79223. * The path for a rope based on an extrusion
  79224. */
  79225. path?: any;
  79226. /**
  79227. * The shape of an extrusion used for a rope based on an extrusion
  79228. */
  79229. shape?: any;
  79230. }
  79231. /**
  79232. * Interface for a physics-enabled object
  79233. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79234. */
  79235. export interface IPhysicsEnabledObject {
  79236. /**
  79237. * The position of the physics-enabled object
  79238. */
  79239. position: Vector3;
  79240. /**
  79241. * The rotation of the physics-enabled object
  79242. */
  79243. rotationQuaternion: Nullable<Quaternion>;
  79244. /**
  79245. * The scale of the physics-enabled object
  79246. */
  79247. scaling: Vector3;
  79248. /**
  79249. * The rotation of the physics-enabled object
  79250. */
  79251. rotation?: Vector3;
  79252. /**
  79253. * The parent of the physics-enabled object
  79254. */
  79255. parent?: any;
  79256. /**
  79257. * The bounding info of the physics-enabled object
  79258. * @returns The bounding info of the physics-enabled object
  79259. */
  79260. getBoundingInfo(): BoundingInfo;
  79261. /**
  79262. * Computes the world matrix
  79263. * @param force Specifies if the world matrix should be computed by force
  79264. * @returns A world matrix
  79265. */
  79266. computeWorldMatrix(force: boolean): Matrix;
  79267. /**
  79268. * Gets the world matrix
  79269. * @returns A world matrix
  79270. */
  79271. getWorldMatrix?(): Matrix;
  79272. /**
  79273. * Gets the child meshes
  79274. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  79275. * @returns An array of abstract meshes
  79276. */
  79277. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  79278. /**
  79279. * Gets the vertex data
  79280. * @param kind The type of vertex data
  79281. * @returns A nullable array of numbers, or a float32 array
  79282. */
  79283. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  79284. /**
  79285. * Gets the indices from the mesh
  79286. * @returns A nullable array of index arrays
  79287. */
  79288. getIndices?(): Nullable<IndicesArray>;
  79289. /**
  79290. * Gets the scene from the mesh
  79291. * @returns the indices array or null
  79292. */
  79293. getScene?(): Scene;
  79294. /**
  79295. * Gets the absolute position from the mesh
  79296. * @returns the absolute position
  79297. */
  79298. getAbsolutePosition(): Vector3;
  79299. /**
  79300. * Gets the absolute pivot point from the mesh
  79301. * @returns the absolute pivot point
  79302. */
  79303. getAbsolutePivotPoint(): Vector3;
  79304. /**
  79305. * Rotates the mesh
  79306. * @param axis The axis of rotation
  79307. * @param amount The amount of rotation
  79308. * @param space The space of the rotation
  79309. * @returns The rotation transform node
  79310. */
  79311. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79312. /**
  79313. * Translates the mesh
  79314. * @param axis The axis of translation
  79315. * @param distance The distance of translation
  79316. * @param space The space of the translation
  79317. * @returns The transform node
  79318. */
  79319. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79320. /**
  79321. * Sets the absolute position of the mesh
  79322. * @param absolutePosition The absolute position of the mesh
  79323. * @returns The transform node
  79324. */
  79325. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  79326. /**
  79327. * Gets the class name of the mesh
  79328. * @returns The class name
  79329. */
  79330. getClassName(): string;
  79331. }
  79332. /**
  79333. * Represents a physics imposter
  79334. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79335. */
  79336. export class PhysicsImpostor {
  79337. /**
  79338. * The physics-enabled object used as the physics imposter
  79339. */
  79340. object: IPhysicsEnabledObject;
  79341. /**
  79342. * The type of the physics imposter
  79343. */
  79344. type: number;
  79345. private _options;
  79346. private _scene?;
  79347. /**
  79348. * The default object size of the imposter
  79349. */
  79350. static DEFAULT_OBJECT_SIZE: Vector3;
  79351. /**
  79352. * The identity quaternion of the imposter
  79353. */
  79354. static IDENTITY_QUATERNION: Quaternion;
  79355. /** @hidden */
  79356. _pluginData: any;
  79357. private _physicsEngine;
  79358. private _physicsBody;
  79359. private _bodyUpdateRequired;
  79360. private _onBeforePhysicsStepCallbacks;
  79361. private _onAfterPhysicsStepCallbacks;
  79362. /** @hidden */
  79363. _onPhysicsCollideCallbacks: Array<{
  79364. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  79365. otherImpostors: Array<PhysicsImpostor>;
  79366. }>;
  79367. private _deltaPosition;
  79368. private _deltaRotation;
  79369. private _deltaRotationConjugated;
  79370. /** hidden */
  79371. _isFromLine: boolean;
  79372. private _parent;
  79373. private _isDisposed;
  79374. private static _tmpVecs;
  79375. private static _tmpQuat;
  79376. /**
  79377. * Specifies if the physics imposter is disposed
  79378. */
  79379. readonly isDisposed: boolean;
  79380. /**
  79381. * Gets the mass of the physics imposter
  79382. */
  79383. mass: number;
  79384. /**
  79385. * Gets the coefficient of friction
  79386. */
  79387. /**
  79388. * Sets the coefficient of friction
  79389. */
  79390. friction: number;
  79391. /**
  79392. * Gets the coefficient of restitution
  79393. */
  79394. /**
  79395. * Sets the coefficient of restitution
  79396. */
  79397. restitution: number;
  79398. /**
  79399. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  79400. */
  79401. /**
  79402. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  79403. */
  79404. pressure: number;
  79405. /**
  79406. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  79407. */
  79408. /**
  79409. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  79410. */
  79411. stiffness: number;
  79412. /**
  79413. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  79414. */
  79415. /**
  79416. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  79417. */
  79418. velocityIterations: number;
  79419. /**
  79420. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  79421. */
  79422. /**
  79423. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  79424. */
  79425. positionIterations: number;
  79426. /**
  79427. * The unique id of the physics imposter
  79428. * set by the physics engine when adding this impostor to the array
  79429. */
  79430. uniqueId: number;
  79431. /**
  79432. * @hidden
  79433. */
  79434. soft: boolean;
  79435. /**
  79436. * @hidden
  79437. */
  79438. segments: number;
  79439. private _joints;
  79440. /**
  79441. * Initializes the physics imposter
  79442. * @param object The physics-enabled object used as the physics imposter
  79443. * @param type The type of the physics imposter
  79444. * @param _options The options for the physics imposter
  79445. * @param _scene The Babylon scene
  79446. */
  79447. constructor(
  79448. /**
  79449. * The physics-enabled object used as the physics imposter
  79450. */
  79451. object: IPhysicsEnabledObject,
  79452. /**
  79453. * The type of the physics imposter
  79454. */
  79455. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  79456. /**
  79457. * This function will completly initialize this impostor.
  79458. * It will create a new body - but only if this mesh has no parent.
  79459. * If it has, this impostor will not be used other than to define the impostor
  79460. * of the child mesh.
  79461. * @hidden
  79462. */
  79463. _init(): void;
  79464. private _getPhysicsParent;
  79465. /**
  79466. * Should a new body be generated.
  79467. * @returns boolean specifying if body initialization is required
  79468. */
  79469. isBodyInitRequired(): boolean;
  79470. /**
  79471. * Sets the updated scaling
  79472. * @param updated Specifies if the scaling is updated
  79473. */
  79474. setScalingUpdated(): void;
  79475. /**
  79476. * Force a regeneration of this or the parent's impostor's body.
  79477. * Use under cautious - This will remove all joints already implemented.
  79478. */
  79479. forceUpdate(): void;
  79480. /**
  79481. * Gets the body that holds this impostor. Either its own, or its parent.
  79482. */
  79483. /**
  79484. * Set the physics body. Used mainly by the physics engine/plugin
  79485. */
  79486. physicsBody: any;
  79487. /**
  79488. * Get the parent of the physics imposter
  79489. * @returns Physics imposter or null
  79490. */
  79491. /**
  79492. * Sets the parent of the physics imposter
  79493. */
  79494. parent: Nullable<PhysicsImpostor>;
  79495. /**
  79496. * Resets the update flags
  79497. */
  79498. resetUpdateFlags(): void;
  79499. /**
  79500. * Gets the object extend size
  79501. * @returns the object extend size
  79502. */
  79503. getObjectExtendSize(): Vector3;
  79504. /**
  79505. * Gets the object center
  79506. * @returns The object center
  79507. */
  79508. getObjectCenter(): Vector3;
  79509. /**
  79510. * Get a specific parametes from the options parameter
  79511. * @param paramName The object parameter name
  79512. * @returns The object parameter
  79513. */
  79514. getParam(paramName: string): any;
  79515. /**
  79516. * Sets a specific parameter in the options given to the physics plugin
  79517. * @param paramName The parameter name
  79518. * @param value The value of the parameter
  79519. */
  79520. setParam(paramName: string, value: number): void;
  79521. /**
  79522. * Specifically change the body's mass option. Won't recreate the physics body object
  79523. * @param mass The mass of the physics imposter
  79524. */
  79525. setMass(mass: number): void;
  79526. /**
  79527. * Gets the linear velocity
  79528. * @returns linear velocity or null
  79529. */
  79530. getLinearVelocity(): Nullable<Vector3>;
  79531. /**
  79532. * Sets the linear velocity
  79533. * @param velocity linear velocity or null
  79534. */
  79535. setLinearVelocity(velocity: Nullable<Vector3>): void;
  79536. /**
  79537. * Gets the angular velocity
  79538. * @returns angular velocity or null
  79539. */
  79540. getAngularVelocity(): Nullable<Vector3>;
  79541. /**
  79542. * Sets the angular velocity
  79543. * @param velocity The velocity or null
  79544. */
  79545. setAngularVelocity(velocity: Nullable<Vector3>): void;
  79546. /**
  79547. * Execute a function with the physics plugin native code
  79548. * Provide a function the will have two variables - the world object and the physics body object
  79549. * @param func The function to execute with the physics plugin native code
  79550. */
  79551. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  79552. /**
  79553. * Register a function that will be executed before the physics world is stepping forward
  79554. * @param func The function to execute before the physics world is stepped forward
  79555. */
  79556. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79557. /**
  79558. * Unregister a function that will be executed before the physics world is stepping forward
  79559. * @param func The function to execute before the physics world is stepped forward
  79560. */
  79561. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79562. /**
  79563. * Register a function that will be executed after the physics step
  79564. * @param func The function to execute after physics step
  79565. */
  79566. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79567. /**
  79568. * Unregisters a function that will be executed after the physics step
  79569. * @param func The function to execute after physics step
  79570. */
  79571. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79572. /**
  79573. * register a function that will be executed when this impostor collides against a different body
  79574. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  79575. * @param func Callback that is executed on collision
  79576. */
  79577. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  79578. /**
  79579. * Unregisters the physics imposter on contact
  79580. * @param collideAgainst The physics object to collide against
  79581. * @param func Callback to execute on collision
  79582. */
  79583. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  79584. private _tmpQuat;
  79585. private _tmpQuat2;
  79586. /**
  79587. * Get the parent rotation
  79588. * @returns The parent rotation
  79589. */
  79590. getParentsRotation(): Quaternion;
  79591. /**
  79592. * this function is executed by the physics engine.
  79593. */
  79594. beforeStep: () => void;
  79595. /**
  79596. * this function is executed by the physics engine
  79597. */
  79598. afterStep: () => void;
  79599. /**
  79600. * Legacy collision detection event support
  79601. */
  79602. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  79603. /**
  79604. * event and body object due to cannon's event-based architecture.
  79605. */
  79606. onCollide: (e: {
  79607. body: any;
  79608. }) => void;
  79609. /**
  79610. * Apply a force
  79611. * @param force The force to apply
  79612. * @param contactPoint The contact point for the force
  79613. * @returns The physics imposter
  79614. */
  79615. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  79616. /**
  79617. * Apply an impulse
  79618. * @param force The impulse force
  79619. * @param contactPoint The contact point for the impulse force
  79620. * @returns The physics imposter
  79621. */
  79622. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  79623. /**
  79624. * A help function to create a joint
  79625. * @param otherImpostor A physics imposter used to create a joint
  79626. * @param jointType The type of joint
  79627. * @param jointData The data for the joint
  79628. * @returns The physics imposter
  79629. */
  79630. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  79631. /**
  79632. * Add a joint to this impostor with a different impostor
  79633. * @param otherImpostor A physics imposter used to add a joint
  79634. * @param joint The joint to add
  79635. * @returns The physics imposter
  79636. */
  79637. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  79638. /**
  79639. * Add an anchor to a cloth impostor
  79640. * @param otherImpostor rigid impostor to anchor to
  79641. * @param width ratio across width from 0 to 1
  79642. * @param height ratio up height from 0 to 1
  79643. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  79644. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  79645. * @returns impostor the soft imposter
  79646. */
  79647. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  79648. /**
  79649. * Add a hook to a rope impostor
  79650. * @param otherImpostor rigid impostor to anchor to
  79651. * @param length ratio across rope from 0 to 1
  79652. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  79653. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  79654. * @returns impostor the rope imposter
  79655. */
  79656. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  79657. /**
  79658. * Will keep this body still, in a sleep mode.
  79659. * @returns the physics imposter
  79660. */
  79661. sleep(): PhysicsImpostor;
  79662. /**
  79663. * Wake the body up.
  79664. * @returns The physics imposter
  79665. */
  79666. wakeUp(): PhysicsImpostor;
  79667. /**
  79668. * Clones the physics imposter
  79669. * @param newObject The physics imposter clones to this physics-enabled object
  79670. * @returns A nullable physics imposter
  79671. */
  79672. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  79673. /**
  79674. * Disposes the physics imposter
  79675. */
  79676. dispose(): void;
  79677. /**
  79678. * Sets the delta position
  79679. * @param position The delta position amount
  79680. */
  79681. setDeltaPosition(position: Vector3): void;
  79682. /**
  79683. * Sets the delta rotation
  79684. * @param rotation The delta rotation amount
  79685. */
  79686. setDeltaRotation(rotation: Quaternion): void;
  79687. /**
  79688. * Gets the box size of the physics imposter and stores the result in the input parameter
  79689. * @param result Stores the box size
  79690. * @returns The physics imposter
  79691. */
  79692. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  79693. /**
  79694. * Gets the radius of the physics imposter
  79695. * @returns Radius of the physics imposter
  79696. */
  79697. getRadius(): number;
  79698. /**
  79699. * Sync a bone with this impostor
  79700. * @param bone The bone to sync to the impostor.
  79701. * @param boneMesh The mesh that the bone is influencing.
  79702. * @param jointPivot The pivot of the joint / bone in local space.
  79703. * @param distToJoint Optional distance from the impostor to the joint.
  79704. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  79705. */
  79706. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  79707. /**
  79708. * Sync impostor to a bone
  79709. * @param bone The bone that the impostor will be synced to.
  79710. * @param boneMesh The mesh that the bone is influencing.
  79711. * @param jointPivot The pivot of the joint / bone in local space.
  79712. * @param distToJoint Optional distance from the impostor to the joint.
  79713. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  79714. * @param boneAxis Optional vector3 axis the bone is aligned with
  79715. */
  79716. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  79717. /**
  79718. * No-Imposter type
  79719. */
  79720. static NoImpostor: number;
  79721. /**
  79722. * Sphere-Imposter type
  79723. */
  79724. static SphereImpostor: number;
  79725. /**
  79726. * Box-Imposter type
  79727. */
  79728. static BoxImpostor: number;
  79729. /**
  79730. * Plane-Imposter type
  79731. */
  79732. static PlaneImpostor: number;
  79733. /**
  79734. * Mesh-imposter type
  79735. */
  79736. static MeshImpostor: number;
  79737. /**
  79738. * Cylinder-Imposter type
  79739. */
  79740. static CylinderImpostor: number;
  79741. /**
  79742. * Particle-Imposter type
  79743. */
  79744. static ParticleImpostor: number;
  79745. /**
  79746. * Heightmap-Imposter type
  79747. */
  79748. static HeightmapImpostor: number;
  79749. /**
  79750. * ConvexHull-Impostor type (Ammo.js plugin only)
  79751. */
  79752. static ConvexHullImpostor: number;
  79753. /**
  79754. * Rope-Imposter type
  79755. */
  79756. static RopeImpostor: number;
  79757. /**
  79758. * Cloth-Imposter type
  79759. */
  79760. static ClothImpostor: number;
  79761. /**
  79762. * Softbody-Imposter type
  79763. */
  79764. static SoftbodyImpostor: number;
  79765. }
  79766. }
  79767. declare module BABYLON {
  79768. /**
  79769. * Class used to represent a specific level of detail of a mesh
  79770. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79771. */
  79772. export class MeshLODLevel {
  79773. /** Defines the distance where this level should star being displayed */
  79774. distance: number;
  79775. /** Defines the mesh to use to render this level */
  79776. mesh: Nullable<Mesh>;
  79777. /**
  79778. * Creates a new LOD level
  79779. * @param distance defines the distance where this level should star being displayed
  79780. * @param mesh defines the mesh to use to render this level
  79781. */
  79782. constructor(
  79783. /** Defines the distance where this level should star being displayed */
  79784. distance: number,
  79785. /** Defines the mesh to use to render this level */
  79786. mesh: Nullable<Mesh>);
  79787. }
  79788. /**
  79789. * @hidden
  79790. **/
  79791. export class _CreationDataStorage {
  79792. closePath?: boolean;
  79793. closeArray?: boolean;
  79794. idx: number[];
  79795. dashSize: number;
  79796. gapSize: number;
  79797. path3D: Path3D;
  79798. pathArray: Vector3[][];
  79799. arc: number;
  79800. radius: number;
  79801. cap: number;
  79802. tessellation: number;
  79803. }
  79804. /**
  79805. * @hidden
  79806. **/
  79807. class _InstanceDataStorage {
  79808. visibleInstances: any;
  79809. renderIdForInstances: number[];
  79810. batchCache: _InstancesBatch;
  79811. instancesBufferSize: number;
  79812. instancesBuffer: Nullable<Buffer>;
  79813. instancesData: Float32Array;
  79814. overridenInstanceCount: number;
  79815. }
  79816. /**
  79817. * @hidden
  79818. **/
  79819. export class _InstancesBatch {
  79820. mustReturn: boolean;
  79821. visibleInstances: Nullable<InstancedMesh[]>[];
  79822. renderSelf: boolean[];
  79823. }
  79824. /**
  79825. * Class used to represent renderable models
  79826. */
  79827. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  79828. /**
  79829. * Mesh side orientation : usually the external or front surface
  79830. */
  79831. static readonly FRONTSIDE: number;
  79832. /**
  79833. * Mesh side orientation : usually the internal or back surface
  79834. */
  79835. static readonly BACKSIDE: number;
  79836. /**
  79837. * Mesh side orientation : both internal and external or front and back surfaces
  79838. */
  79839. static readonly DOUBLESIDE: number;
  79840. /**
  79841. * Mesh side orientation : by default, `FRONTSIDE`
  79842. */
  79843. static readonly DEFAULTSIDE: number;
  79844. /**
  79845. * Mesh cap setting : no cap
  79846. */
  79847. static readonly NO_CAP: number;
  79848. /**
  79849. * Mesh cap setting : one cap at the beginning of the mesh
  79850. */
  79851. static readonly CAP_START: number;
  79852. /**
  79853. * Mesh cap setting : one cap at the end of the mesh
  79854. */
  79855. static readonly CAP_END: number;
  79856. /**
  79857. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  79858. */
  79859. static readonly CAP_ALL: number;
  79860. /**
  79861. * Gets the default side orientation.
  79862. * @param orientation the orientation to value to attempt to get
  79863. * @returns the default orientation
  79864. * @hidden
  79865. */
  79866. static _GetDefaultSideOrientation(orientation?: number): number;
  79867. private _onBeforeRenderObservable;
  79868. private _onBeforeBindObservable;
  79869. private _onAfterRenderObservable;
  79870. private _onBeforeDrawObservable;
  79871. /**
  79872. * An event triggered before rendering the mesh
  79873. */
  79874. readonly onBeforeRenderObservable: Observable<Mesh>;
  79875. /**
  79876. * An event triggered before binding the mesh
  79877. */
  79878. readonly onBeforeBindObservable: Observable<Mesh>;
  79879. /**
  79880. * An event triggered after rendering the mesh
  79881. */
  79882. readonly onAfterRenderObservable: Observable<Mesh>;
  79883. /**
  79884. * An event triggered before drawing the mesh
  79885. */
  79886. readonly onBeforeDrawObservable: Observable<Mesh>;
  79887. private _onBeforeDrawObserver;
  79888. /**
  79889. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  79890. */
  79891. onBeforeDraw: () => void;
  79892. /**
  79893. * Gets the delay loading state of the mesh (when delay loading is turned on)
  79894. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  79895. */
  79896. delayLoadState: number;
  79897. /**
  79898. * Gets the list of instances created from this mesh
  79899. * it is not supposed to be modified manually.
  79900. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  79901. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  79902. */
  79903. instances: InstancedMesh[];
  79904. /**
  79905. * Gets the file containing delay loading data for this mesh
  79906. */
  79907. delayLoadingFile: string;
  79908. /** @hidden */
  79909. _binaryInfo: any;
  79910. private _LODLevels;
  79911. /**
  79912. * User defined function used to change how LOD level selection is done
  79913. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79914. */
  79915. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  79916. private _morphTargetManager;
  79917. /**
  79918. * Gets or sets the morph target manager
  79919. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79920. */
  79921. morphTargetManager: Nullable<MorphTargetManager>;
  79922. /** @hidden */
  79923. _creationDataStorage: Nullable<_CreationDataStorage>;
  79924. /** @hidden */
  79925. _geometry: Nullable<Geometry>;
  79926. /** @hidden */
  79927. _delayInfo: Array<string>;
  79928. /** @hidden */
  79929. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  79930. /** @hidden */
  79931. _instanceDataStorage: _InstanceDataStorage;
  79932. private _effectiveMaterial;
  79933. /** @hidden */
  79934. _shouldGenerateFlatShading: boolean;
  79935. private _preActivateId;
  79936. /** @hidden */
  79937. _originalBuilderSideOrientation: number;
  79938. /**
  79939. * Use this property to change the original side orientation defined at construction time
  79940. */
  79941. overrideMaterialSideOrientation: Nullable<number>;
  79942. private _areNormalsFrozen;
  79943. private _sourcePositions;
  79944. private _sourceNormals;
  79945. private _source;
  79946. private meshMap;
  79947. /**
  79948. * Gets the source mesh (the one used to clone this one from)
  79949. */
  79950. readonly source: Nullable<Mesh>;
  79951. /**
  79952. * Gets or sets a boolean indicating that this mesh does not use index buffer
  79953. */
  79954. isUnIndexed: boolean;
  79955. /**
  79956. * @constructor
  79957. * @param name The value used by scene.getMeshByName() to do a lookup.
  79958. * @param scene The scene to add this mesh to.
  79959. * @param parent The parent of this mesh, if it has one
  79960. * @param source An optional Mesh from which geometry is shared, cloned.
  79961. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  79962. * When false, achieved by calling a clone(), also passing False.
  79963. * This will make creation of children, recursive.
  79964. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  79965. */
  79966. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  79967. /**
  79968. * Gets the class name
  79969. * @returns the string "Mesh".
  79970. */
  79971. getClassName(): string;
  79972. /** @hidden */
  79973. readonly _isMesh: boolean;
  79974. /**
  79975. * Returns a description of this mesh
  79976. * @param fullDetails define if full details about this mesh must be used
  79977. * @returns a descriptive string representing this mesh
  79978. */
  79979. toString(fullDetails?: boolean): string;
  79980. /** @hidden */
  79981. _unBindEffect(): void;
  79982. /**
  79983. * Gets a boolean indicating if this mesh has LOD
  79984. */
  79985. readonly hasLODLevels: boolean;
  79986. /**
  79987. * Gets the list of MeshLODLevel associated with the current mesh
  79988. * @returns an array of MeshLODLevel
  79989. */
  79990. getLODLevels(): MeshLODLevel[];
  79991. private _sortLODLevels;
  79992. /**
  79993. * Add a mesh as LOD level triggered at the given distance.
  79994. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79995. * @param distance The distance from the center of the object to show this level
  79996. * @param mesh The mesh to be added as LOD level (can be null)
  79997. * @return This mesh (for chaining)
  79998. */
  79999. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  80000. /**
  80001. * Returns the LOD level mesh at the passed distance or null if not found.
  80002. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80003. * @param distance The distance from the center of the object to show this level
  80004. * @returns a Mesh or `null`
  80005. */
  80006. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  80007. /**
  80008. * Remove a mesh from the LOD array
  80009. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80010. * @param mesh defines the mesh to be removed
  80011. * @return This mesh (for chaining)
  80012. */
  80013. removeLODLevel(mesh: Mesh): Mesh;
  80014. /**
  80015. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  80016. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80017. * @param camera defines the camera to use to compute distance
  80018. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  80019. * @return This mesh (for chaining)
  80020. */
  80021. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  80022. /**
  80023. * Gets the mesh internal Geometry object
  80024. */
  80025. readonly geometry: Nullable<Geometry>;
  80026. /**
  80027. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  80028. * @returns the total number of vertices
  80029. */
  80030. getTotalVertices(): number;
  80031. /**
  80032. * Returns the content of an associated vertex buffer
  80033. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80034. * - VertexBuffer.PositionKind
  80035. * - VertexBuffer.UVKind
  80036. * - VertexBuffer.UV2Kind
  80037. * - VertexBuffer.UV3Kind
  80038. * - VertexBuffer.UV4Kind
  80039. * - VertexBuffer.UV5Kind
  80040. * - VertexBuffer.UV6Kind
  80041. * - VertexBuffer.ColorKind
  80042. * - VertexBuffer.MatricesIndicesKind
  80043. * - VertexBuffer.MatricesIndicesExtraKind
  80044. * - VertexBuffer.MatricesWeightsKind
  80045. * - VertexBuffer.MatricesWeightsExtraKind
  80046. * @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
  80047. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  80048. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  80049. */
  80050. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80051. /**
  80052. * Returns the mesh VertexBuffer object from the requested `kind`
  80053. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80054. * - VertexBuffer.PositionKind
  80055. * - VertexBuffer.UVKind
  80056. * - VertexBuffer.UV2Kind
  80057. * - VertexBuffer.UV3Kind
  80058. * - VertexBuffer.UV4Kind
  80059. * - VertexBuffer.UV5Kind
  80060. * - VertexBuffer.UV6Kind
  80061. * - VertexBuffer.ColorKind
  80062. * - VertexBuffer.MatricesIndicesKind
  80063. * - VertexBuffer.MatricesIndicesExtraKind
  80064. * - VertexBuffer.MatricesWeightsKind
  80065. * - VertexBuffer.MatricesWeightsExtraKind
  80066. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  80067. */
  80068. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  80069. /**
  80070. * Tests if a specific vertex buffer is associated with this mesh
  80071. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80072. * - VertexBuffer.PositionKind
  80073. * - VertexBuffer.UVKind
  80074. * - VertexBuffer.UV2Kind
  80075. * - VertexBuffer.UV3Kind
  80076. * - VertexBuffer.UV4Kind
  80077. * - VertexBuffer.UV5Kind
  80078. * - VertexBuffer.UV6Kind
  80079. * - VertexBuffer.ColorKind
  80080. * - VertexBuffer.MatricesIndicesKind
  80081. * - VertexBuffer.MatricesIndicesExtraKind
  80082. * - VertexBuffer.MatricesWeightsKind
  80083. * - VertexBuffer.MatricesWeightsExtraKind
  80084. * @returns a boolean
  80085. */
  80086. isVerticesDataPresent(kind: string): boolean;
  80087. /**
  80088. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  80089. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80090. * - VertexBuffer.PositionKind
  80091. * - VertexBuffer.UVKind
  80092. * - VertexBuffer.UV2Kind
  80093. * - VertexBuffer.UV3Kind
  80094. * - VertexBuffer.UV4Kind
  80095. * - VertexBuffer.UV5Kind
  80096. * - VertexBuffer.UV6Kind
  80097. * - VertexBuffer.ColorKind
  80098. * - VertexBuffer.MatricesIndicesKind
  80099. * - VertexBuffer.MatricesIndicesExtraKind
  80100. * - VertexBuffer.MatricesWeightsKind
  80101. * - VertexBuffer.MatricesWeightsExtraKind
  80102. * @returns a boolean
  80103. */
  80104. isVertexBufferUpdatable(kind: string): boolean;
  80105. /**
  80106. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  80107. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80108. * - VertexBuffer.PositionKind
  80109. * - VertexBuffer.UVKind
  80110. * - VertexBuffer.UV2Kind
  80111. * - VertexBuffer.UV3Kind
  80112. * - VertexBuffer.UV4Kind
  80113. * - VertexBuffer.UV5Kind
  80114. * - VertexBuffer.UV6Kind
  80115. * - VertexBuffer.ColorKind
  80116. * - VertexBuffer.MatricesIndicesKind
  80117. * - VertexBuffer.MatricesIndicesExtraKind
  80118. * - VertexBuffer.MatricesWeightsKind
  80119. * - VertexBuffer.MatricesWeightsExtraKind
  80120. * @returns an array of strings
  80121. */
  80122. getVerticesDataKinds(): string[];
  80123. /**
  80124. * Returns a positive integer : the total number of indices in this mesh geometry.
  80125. * @returns the numner of indices or zero if the mesh has no geometry.
  80126. */
  80127. getTotalIndices(): number;
  80128. /**
  80129. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  80130. * @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.
  80131. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80132. * @returns the indices array or an empty array if the mesh has no geometry
  80133. */
  80134. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  80135. readonly isBlocked: boolean;
  80136. /**
  80137. * Determine if the current mesh is ready to be rendered
  80138. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  80139. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  80140. * @returns true if all associated assets are ready (material, textures, shaders)
  80141. */
  80142. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  80143. /**
  80144. * 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.
  80145. */
  80146. readonly areNormalsFrozen: boolean;
  80147. /**
  80148. * 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.
  80149. * @returns the current mesh
  80150. */
  80151. freezeNormals(): Mesh;
  80152. /**
  80153. * 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
  80154. * @returns the current mesh
  80155. */
  80156. unfreezeNormals(): Mesh;
  80157. /**
  80158. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  80159. */
  80160. overridenInstanceCount: number;
  80161. /** @hidden */
  80162. _preActivate(): Mesh;
  80163. /** @hidden */
  80164. _preActivateForIntermediateRendering(renderId: number): Mesh;
  80165. /** @hidden */
  80166. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  80167. /**
  80168. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  80169. * This means the mesh underlying bounding box and sphere are recomputed.
  80170. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  80171. * @returns the current mesh
  80172. */
  80173. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  80174. /** @hidden */
  80175. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  80176. /**
  80177. * This function will subdivide the mesh into multiple submeshes
  80178. * @param count defines the expected number of submeshes
  80179. */
  80180. subdivide(count: number): void;
  80181. /**
  80182. * Copy a FloatArray into a specific associated vertex buffer
  80183. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80184. * - VertexBuffer.PositionKind
  80185. * - VertexBuffer.UVKind
  80186. * - VertexBuffer.UV2Kind
  80187. * - VertexBuffer.UV3Kind
  80188. * - VertexBuffer.UV4Kind
  80189. * - VertexBuffer.UV5Kind
  80190. * - VertexBuffer.UV6Kind
  80191. * - VertexBuffer.ColorKind
  80192. * - VertexBuffer.MatricesIndicesKind
  80193. * - VertexBuffer.MatricesIndicesExtraKind
  80194. * - VertexBuffer.MatricesWeightsKind
  80195. * - VertexBuffer.MatricesWeightsExtraKind
  80196. * @param data defines the data source
  80197. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  80198. * @param stride defines the data stride size (can be null)
  80199. * @returns the current mesh
  80200. */
  80201. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  80202. /**
  80203. * Flags an associated vertex buffer as updatable
  80204. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  80205. * - VertexBuffer.PositionKind
  80206. * - VertexBuffer.UVKind
  80207. * - VertexBuffer.UV2Kind
  80208. * - VertexBuffer.UV3Kind
  80209. * - VertexBuffer.UV4Kind
  80210. * - VertexBuffer.UV5Kind
  80211. * - VertexBuffer.UV6Kind
  80212. * - VertexBuffer.ColorKind
  80213. * - VertexBuffer.MatricesIndicesKind
  80214. * - VertexBuffer.MatricesIndicesExtraKind
  80215. * - VertexBuffer.MatricesWeightsKind
  80216. * - VertexBuffer.MatricesWeightsExtraKind
  80217. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  80218. */
  80219. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  80220. /**
  80221. * Sets the mesh global Vertex Buffer
  80222. * @param buffer defines the buffer to use
  80223. * @returns the current mesh
  80224. */
  80225. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  80226. /**
  80227. * Update a specific associated vertex buffer
  80228. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80229. * - VertexBuffer.PositionKind
  80230. * - VertexBuffer.UVKind
  80231. * - VertexBuffer.UV2Kind
  80232. * - VertexBuffer.UV3Kind
  80233. * - VertexBuffer.UV4Kind
  80234. * - VertexBuffer.UV5Kind
  80235. * - VertexBuffer.UV6Kind
  80236. * - VertexBuffer.ColorKind
  80237. * - VertexBuffer.MatricesIndicesKind
  80238. * - VertexBuffer.MatricesIndicesExtraKind
  80239. * - VertexBuffer.MatricesWeightsKind
  80240. * - VertexBuffer.MatricesWeightsExtraKind
  80241. * @param data defines the data source
  80242. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  80243. * @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)
  80244. * @returns the current mesh
  80245. */
  80246. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  80247. /**
  80248. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  80249. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  80250. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  80251. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  80252. * @returns the current mesh
  80253. */
  80254. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  80255. /**
  80256. * Creates a un-shared specific occurence of the geometry for the mesh.
  80257. * @returns the current mesh
  80258. */
  80259. makeGeometryUnique(): Mesh;
  80260. /**
  80261. * Set the index buffer of this mesh
  80262. * @param indices defines the source data
  80263. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  80264. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  80265. * @returns the current mesh
  80266. */
  80267. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  80268. /**
  80269. * Update the current index buffer
  80270. * @param indices defines the source data
  80271. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  80272. * @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)
  80273. * @returns the current mesh
  80274. */
  80275. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  80276. /**
  80277. * Invert the geometry to move from a right handed system to a left handed one.
  80278. * @returns the current mesh
  80279. */
  80280. toLeftHanded(): Mesh;
  80281. /** @hidden */
  80282. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  80283. /** @hidden */
  80284. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  80285. /**
  80286. * Registers for this mesh a javascript function called just before the rendering process
  80287. * @param func defines the function to call before rendering this mesh
  80288. * @returns the current mesh
  80289. */
  80290. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  80291. /**
  80292. * Disposes a previously registered javascript function called before the rendering
  80293. * @param func defines the function to remove
  80294. * @returns the current mesh
  80295. */
  80296. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  80297. /**
  80298. * Registers for this mesh a javascript function called just after the rendering is complete
  80299. * @param func defines the function to call after rendering this mesh
  80300. * @returns the current mesh
  80301. */
  80302. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  80303. /**
  80304. * Disposes a previously registered javascript function called after the rendering.
  80305. * @param func defines the function to remove
  80306. * @returns the current mesh
  80307. */
  80308. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  80309. /** @hidden */
  80310. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  80311. /** @hidden */
  80312. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  80313. /** @hidden */
  80314. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  80315. /**
  80316. * 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
  80317. * @param subMesh defines the subMesh to render
  80318. * @param enableAlphaMode defines if alpha mode can be changed
  80319. * @returns the current mesh
  80320. */
  80321. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  80322. private _onBeforeDraw;
  80323. /**
  80324. * Renormalize the mesh and patch it up if there are no weights
  80325. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  80326. * However in the case of zero weights then we set just a single influence to 1.
  80327. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  80328. */
  80329. cleanMatrixWeights(): void;
  80330. private normalizeSkinFourWeights;
  80331. private normalizeSkinWeightsAndExtra;
  80332. /**
  80333. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  80334. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  80335. * the user know there was an issue with importing the mesh
  80336. * @returns a validation object with skinned, valid and report string
  80337. */
  80338. validateSkinning(): {
  80339. skinned: boolean;
  80340. valid: boolean;
  80341. report: string;
  80342. };
  80343. /** @hidden */
  80344. _checkDelayState(): Mesh;
  80345. private _queueLoad;
  80346. /**
  80347. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  80348. * A mesh is in the frustum if its bounding box intersects the frustum
  80349. * @param frustumPlanes defines the frustum to test
  80350. * @returns true if the mesh is in the frustum planes
  80351. */
  80352. isInFrustum(frustumPlanes: Plane[]): boolean;
  80353. /**
  80354. * Sets the mesh material by the material or multiMaterial `id` property
  80355. * @param id is a string identifying the material or the multiMaterial
  80356. * @returns the current mesh
  80357. */
  80358. setMaterialByID(id: string): Mesh;
  80359. /**
  80360. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  80361. * @returns an array of IAnimatable
  80362. */
  80363. getAnimatables(): IAnimatable[];
  80364. /**
  80365. * Modifies the mesh geometry according to the passed transformation matrix.
  80366. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  80367. * The mesh normals are modified using the same transformation.
  80368. * Note that, under the hood, this method sets a new VertexBuffer each call.
  80369. * @param transform defines the transform matrix to use
  80370. * @see http://doc.babylonjs.com/resources/baking_transformations
  80371. * @returns the current mesh
  80372. */
  80373. bakeTransformIntoVertices(transform: Matrix): Mesh;
  80374. /**
  80375. * Modifies the mesh geometry according to its own current World Matrix.
  80376. * The mesh World Matrix is then reset.
  80377. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  80378. * Note that, under the hood, this method sets a new VertexBuffer each call.
  80379. * @see http://doc.babylonjs.com/resources/baking_transformations
  80380. * @returns the current mesh
  80381. */
  80382. bakeCurrentTransformIntoVertices(): Mesh;
  80383. /** @hidden */
  80384. readonly _positions: Nullable<Vector3[]>;
  80385. /** @hidden */
  80386. _resetPointsArrayCache(): Mesh;
  80387. /** @hidden */
  80388. _generatePointsArray(): boolean;
  80389. /**
  80390. * Returns a new Mesh object generated from the current mesh properties.
  80391. * This method must not get confused with createInstance()
  80392. * @param name is a string, the name given to the new mesh
  80393. * @param newParent can be any Node object (default `null`)
  80394. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  80395. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  80396. * @returns a new mesh
  80397. */
  80398. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  80399. /**
  80400. * Releases resources associated with this mesh.
  80401. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80402. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80403. */
  80404. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80405. /**
  80406. * Modifies the mesh geometry according to a displacement map.
  80407. * 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.
  80408. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  80409. * @param url is a string, the URL from the image file is to be downloaded.
  80410. * @param minHeight is the lower limit of the displacement.
  80411. * @param maxHeight is the upper limit of the displacement.
  80412. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  80413. * @param uvOffset is an optional vector2 used to offset UV.
  80414. * @param uvScale is an optional vector2 used to scale UV.
  80415. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  80416. * @returns the Mesh.
  80417. */
  80418. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  80419. /**
  80420. * Modifies the mesh geometry according to a displacementMap buffer.
  80421. * 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.
  80422. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  80423. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  80424. * @param heightMapWidth is the width of the buffer image.
  80425. * @param heightMapHeight is the height of the buffer image.
  80426. * @param minHeight is the lower limit of the displacement.
  80427. * @param maxHeight is the upper limit of the displacement.
  80428. * @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.
  80429. * @param uvOffset is an optional vector2 used to offset UV.
  80430. * @param uvScale is an optional vector2 used to scale UV.
  80431. * @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.
  80432. * @returns the Mesh.
  80433. */
  80434. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  80435. /**
  80436. * Modify the mesh to get a flat shading rendering.
  80437. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  80438. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  80439. * @returns current mesh
  80440. */
  80441. convertToFlatShadedMesh(): Mesh;
  80442. /**
  80443. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  80444. * In other words, more vertices, no more indices and a single bigger VBO.
  80445. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  80446. * @returns current mesh
  80447. */
  80448. convertToUnIndexedMesh(): Mesh;
  80449. /**
  80450. * Inverses facet orientations.
  80451. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80452. * @param flipNormals will also inverts the normals
  80453. * @returns current mesh
  80454. */
  80455. flipFaces(flipNormals?: boolean): Mesh;
  80456. /**
  80457. * Increase the number of facets and hence vertices in a mesh
  80458. * Vertex normals are interpolated from existing vertex normals
  80459. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80460. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  80461. */
  80462. increaseVertices(numberPerEdge: number): void;
  80463. /**
  80464. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  80465. * This will undo any application of covertToFlatShadedMesh
  80466. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80467. */
  80468. forceSharedVertices(): void;
  80469. /** @hidden */
  80470. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  80471. /** @hidden */
  80472. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  80473. /**
  80474. * Creates a new InstancedMesh object from the mesh model.
  80475. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80476. * @param name defines the name of the new instance
  80477. * @returns a new InstancedMesh
  80478. */
  80479. createInstance(name: string): InstancedMesh;
  80480. /**
  80481. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  80482. * After this call, all the mesh instances have the same submeshes than the current mesh.
  80483. * @returns the current mesh
  80484. */
  80485. synchronizeInstances(): Mesh;
  80486. /**
  80487. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  80488. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  80489. * This should be used together with the simplification to avoid disappearing triangles.
  80490. * @param successCallback an optional success callback to be called after the optimization finished.
  80491. * @returns the current mesh
  80492. */
  80493. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  80494. /**
  80495. * Serialize current mesh
  80496. * @param serializationObject defines the object which will receive the serialization data
  80497. */
  80498. serialize(serializationObject: any): void;
  80499. /** @hidden */
  80500. _syncGeometryWithMorphTargetManager(): void;
  80501. /** @hidden */
  80502. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  80503. /**
  80504. * Returns a new Mesh object parsed from the source provided.
  80505. * @param parsedMesh is the source
  80506. * @param scene defines the hosting scene
  80507. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  80508. * @returns a new Mesh
  80509. */
  80510. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  80511. /**
  80512. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  80513. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80514. * @param name defines the name of the mesh to create
  80515. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  80516. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  80517. * @param closePath creates a seam between the first and the last points of each path of the path array
  80518. * @param offset is taken in account only if the `pathArray` is containing a single path
  80519. * @param scene defines the hosting scene
  80520. * @param updatable defines if the mesh must be flagged as updatable
  80521. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80522. * @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)
  80523. * @returns a new Mesh
  80524. */
  80525. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80526. /**
  80527. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  80528. * @param name defines the name of the mesh to create
  80529. * @param radius sets the radius size (float) of the polygon (default 0.5)
  80530. * @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
  80531. * @param scene defines the hosting scene
  80532. * @param updatable defines if the mesh must be flagged as updatable
  80533. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80534. * @returns a new Mesh
  80535. */
  80536. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  80537. /**
  80538. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  80539. * @param name defines the name of the mesh to create
  80540. * @param size sets the size (float) of each box side (default 1)
  80541. * @param scene defines the hosting scene
  80542. * @param updatable defines if the mesh must be flagged as updatable
  80543. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80544. * @returns a new Mesh
  80545. */
  80546. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  80547. /**
  80548. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  80549. * @param name defines the name of the mesh to create
  80550. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  80551. * @param diameter sets the diameter size (float) of the sphere (default 1)
  80552. * @param scene defines the hosting scene
  80553. * @param updatable defines if the mesh must be flagged as updatable
  80554. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80555. * @returns a new Mesh
  80556. */
  80557. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80558. /**
  80559. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  80560. * @param name defines the name of the mesh to create
  80561. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  80562. * @param diameter sets the diameter size (float) of the sphere (default 1)
  80563. * @param scene defines the hosting scene
  80564. * @returns a new Mesh
  80565. */
  80566. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  80567. /**
  80568. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  80569. * @param name defines the name of the mesh to create
  80570. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  80571. * @param diameterTop set the top cap diameter (floats, default 1)
  80572. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  80573. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  80574. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  80575. * @param scene defines the hosting scene
  80576. * @param updatable defines if the mesh must be flagged as updatable
  80577. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80578. * @returns a new Mesh
  80579. */
  80580. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  80581. /**
  80582. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  80583. * @param name defines the name of the mesh to create
  80584. * @param diameter sets the diameter size (float) of the torus (default 1)
  80585. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  80586. * @param tessellation sets the number of torus sides (postive integer, default 16)
  80587. * @param scene defines the hosting scene
  80588. * @param updatable defines if the mesh must be flagged as updatable
  80589. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80590. * @returns a new Mesh
  80591. */
  80592. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80593. /**
  80594. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  80595. * @param name defines the name of the mesh to create
  80596. * @param radius sets the global radius size (float) of the torus knot (default 2)
  80597. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  80598. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  80599. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  80600. * @param p the number of windings on X axis (positive integers, default 2)
  80601. * @param q the number of windings on Y axis (positive integers, default 3)
  80602. * @param scene defines the hosting scene
  80603. * @param updatable defines if the mesh must be flagged as updatable
  80604. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80605. * @returns a new Mesh
  80606. */
  80607. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80608. /**
  80609. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  80610. * @param name defines the name of the mesh to create
  80611. * @param points is an array successive Vector3
  80612. * @param scene defines the hosting scene
  80613. * @param updatable defines if the mesh must be flagged as updatable
  80614. * @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).
  80615. * @returns a new Mesh
  80616. */
  80617. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  80618. /**
  80619. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  80620. * @param name defines the name of the mesh to create
  80621. * @param points is an array successive Vector3
  80622. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  80623. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  80624. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  80625. * @param scene defines the hosting scene
  80626. * @param updatable defines if the mesh must be flagged as updatable
  80627. * @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)
  80628. * @returns a new Mesh
  80629. */
  80630. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  80631. /**
  80632. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  80633. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  80634. * 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.
  80635. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80636. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  80637. * Remember you can only change the shape positions, not their number when updating a polygon.
  80638. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  80639. * @param name defines the name of the mesh to create
  80640. * @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
  80641. * @param scene defines the hosting scene
  80642. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  80643. * @param updatable defines if the mesh must be flagged as updatable
  80644. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80645. * @param earcutInjection can be used to inject your own earcut reference
  80646. * @returns a new Mesh
  80647. */
  80648. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  80649. /**
  80650. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  80651. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  80652. * @param name defines the name of the mesh to create
  80653. * @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
  80654. * @param depth defines the height of extrusion
  80655. * @param scene defines the hosting scene
  80656. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  80657. * @param updatable defines if the mesh must be flagged as updatable
  80658. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80659. * @param earcutInjection can be used to inject your own earcut reference
  80660. * @returns a new Mesh
  80661. */
  80662. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  80663. /**
  80664. * Creates an extruded shape mesh.
  80665. * 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
  80666. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80667. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80668. * @param name defines the name of the mesh to create
  80669. * @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
  80670. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  80671. * @param scale is the value to scale the shape
  80672. * @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
  80673. * @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
  80674. * @param scene defines the hosting scene
  80675. * @param updatable defines if the mesh must be flagged as updatable
  80676. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80677. * @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)
  80678. * @returns a new Mesh
  80679. */
  80680. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80681. /**
  80682. * Creates an custom extruded shape mesh.
  80683. * The custom extrusion is a parametric shape.
  80684. * It has no predefined shape. Its final shape will depend on the input parameters.
  80685. * Please consider using the same method from the MeshBuilder class instead
  80686. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80687. * @param name defines the name of the mesh to create
  80688. * @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
  80689. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  80690. * @param scaleFunction is a custom Javascript function called on each path point
  80691. * @param rotationFunction is a custom Javascript function called on each path point
  80692. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  80693. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  80694. * @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
  80695. * @param scene defines the hosting scene
  80696. * @param updatable defines if the mesh must be flagged as updatable
  80697. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80698. * @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)
  80699. * @returns a new Mesh
  80700. */
  80701. 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;
  80702. /**
  80703. * Creates lathe mesh.
  80704. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  80705. * Please consider using the same method from the MeshBuilder class instead
  80706. * @param name defines the name of the mesh to create
  80707. * @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
  80708. * @param radius is the radius value of the lathe
  80709. * @param tessellation is the side number of the lathe.
  80710. * @param scene defines the hosting scene
  80711. * @param updatable defines if the mesh must be flagged as updatable
  80712. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80713. * @returns a new Mesh
  80714. */
  80715. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80716. /**
  80717. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  80718. * @param name defines the name of the mesh to create
  80719. * @param size sets the size (float) of both sides of the plane at once (default 1)
  80720. * @param scene defines the hosting scene
  80721. * @param updatable defines if the mesh must be flagged as updatable
  80722. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80723. * @returns a new Mesh
  80724. */
  80725. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80726. /**
  80727. * Creates a ground mesh.
  80728. * Please consider using the same method from the MeshBuilder class instead
  80729. * @param name defines the name of the mesh to create
  80730. * @param width set the width of the ground
  80731. * @param height set the height of the ground
  80732. * @param subdivisions sets the number of subdivisions per side
  80733. * @param scene defines the hosting scene
  80734. * @param updatable defines if the mesh must be flagged as updatable
  80735. * @returns a new Mesh
  80736. */
  80737. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  80738. /**
  80739. * Creates a tiled ground mesh.
  80740. * Please consider using the same method from the MeshBuilder class instead
  80741. * @param name defines the name of the mesh to create
  80742. * @param xmin set the ground minimum X coordinate
  80743. * @param zmin set the ground minimum Y coordinate
  80744. * @param xmax set the ground maximum X coordinate
  80745. * @param zmax set the ground maximum Z coordinate
  80746. * @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
  80747. * @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
  80748. * @param scene defines the hosting scene
  80749. * @param updatable defines if the mesh must be flagged as updatable
  80750. * @returns a new Mesh
  80751. */
  80752. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  80753. w: number;
  80754. h: number;
  80755. }, precision: {
  80756. w: number;
  80757. h: number;
  80758. }, scene: Scene, updatable?: boolean): Mesh;
  80759. /**
  80760. * Creates a ground mesh from a height map.
  80761. * Please consider using the same method from the MeshBuilder class instead
  80762. * @see http://doc.babylonjs.com/babylon101/height_map
  80763. * @param name defines the name of the mesh to create
  80764. * @param url sets the URL of the height map image resource
  80765. * @param width set the ground width size
  80766. * @param height set the ground height size
  80767. * @param subdivisions sets the number of subdivision per side
  80768. * @param minHeight is the minimum altitude on the ground
  80769. * @param maxHeight is the maximum altitude on the ground
  80770. * @param scene defines the hosting scene
  80771. * @param updatable defines if the mesh must be flagged as updatable
  80772. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  80773. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  80774. * @returns a new Mesh
  80775. */
  80776. 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;
  80777. /**
  80778. * Creates a tube mesh.
  80779. * The tube is a parametric shape.
  80780. * It has no predefined shape. Its final shape will depend on the input parameters.
  80781. * Please consider using the same method from the MeshBuilder class instead
  80782. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80783. * @param name defines the name of the mesh to create
  80784. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  80785. * @param radius sets the tube radius size
  80786. * @param tessellation is the number of sides on the tubular surface
  80787. * @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
  80788. * @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
  80789. * @param scene defines the hosting scene
  80790. * @param updatable defines if the mesh must be flagged as updatable
  80791. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80792. * @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)
  80793. * @returns a new Mesh
  80794. */
  80795. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  80796. (i: number, distance: number): number;
  80797. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80798. /**
  80799. * Creates a polyhedron mesh.
  80800. * Please consider using the same method from the MeshBuilder class instead.
  80801. * * 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
  80802. * * The parameter `size` (positive float, default 1) sets the polygon size
  80803. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  80804. * * 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`
  80805. * * 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
  80806. * * 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)`)
  80807. * * 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
  80808. * * 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
  80809. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80810. * * If you create a double-sided mesh, you can choose what parts of 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
  80811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80812. * @param name defines the name of the mesh to create
  80813. * @param options defines the options used to create the mesh
  80814. * @param scene defines the hosting scene
  80815. * @returns a new Mesh
  80816. */
  80817. static CreatePolyhedron(name: string, options: {
  80818. type?: number;
  80819. size?: number;
  80820. sizeX?: number;
  80821. sizeY?: number;
  80822. sizeZ?: number;
  80823. custom?: any;
  80824. faceUV?: Vector4[];
  80825. faceColors?: Color4[];
  80826. updatable?: boolean;
  80827. sideOrientation?: number;
  80828. }, scene: Scene): Mesh;
  80829. /**
  80830. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  80831. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  80832. * * 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`)
  80833. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  80834. * * 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
  80835. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80836. * * If you create a double-sided mesh, you can choose what parts of 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
  80837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80838. * @param name defines the name of the mesh
  80839. * @param options defines the options used to create the mesh
  80840. * @param scene defines the hosting scene
  80841. * @returns a new Mesh
  80842. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  80843. */
  80844. static CreateIcoSphere(name: string, options: {
  80845. radius?: number;
  80846. flat?: boolean;
  80847. subdivisions?: number;
  80848. sideOrientation?: number;
  80849. updatable?: boolean;
  80850. }, scene: Scene): Mesh;
  80851. /**
  80852. * Creates a decal mesh.
  80853. * Please consider using the same method from the MeshBuilder class instead.
  80854. * A decal is a mesh usually applied as a model onto the surface of another mesh
  80855. * @param name defines the name of the mesh
  80856. * @param sourceMesh defines the mesh receiving the decal
  80857. * @param position sets the position of the decal in world coordinates
  80858. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  80859. * @param size sets the decal scaling
  80860. * @param angle sets the angle to rotate the decal
  80861. * @returns a new Mesh
  80862. */
  80863. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  80864. /**
  80865. * Prepare internal position array for software CPU skinning
  80866. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  80867. */
  80868. setPositionsForCPUSkinning(): Float32Array;
  80869. /**
  80870. * Prepare internal normal array for software CPU skinning
  80871. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  80872. */
  80873. setNormalsForCPUSkinning(): Float32Array;
  80874. /**
  80875. * Updates the vertex buffer by applying transformation from the bones
  80876. * @param skeleton defines the skeleton to apply to current mesh
  80877. * @returns the current mesh
  80878. */
  80879. applySkeleton(skeleton: Skeleton): Mesh;
  80880. /**
  80881. * 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
  80882. * @param meshes defines the list of meshes to scan
  80883. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  80884. */
  80885. static MinMax(meshes: AbstractMesh[]): {
  80886. min: Vector3;
  80887. max: Vector3;
  80888. };
  80889. /**
  80890. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  80891. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  80892. * @returns a vector3
  80893. */
  80894. static Center(meshesOrMinMaxVector: {
  80895. min: Vector3;
  80896. max: Vector3;
  80897. } | AbstractMesh[]): Vector3;
  80898. /**
  80899. * Merge the array of meshes into a single mesh for performance reasons.
  80900. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  80901. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  80902. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  80903. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  80904. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  80905. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  80906. * @returns a new mesh
  80907. */
  80908. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  80909. /** @hidden */
  80910. addInstance(instance: InstancedMesh): void;
  80911. /** @hidden */
  80912. removeInstance(instance: InstancedMesh): void;
  80913. }
  80914. }
  80915. declare module BABYLON {
  80916. /**
  80917. * Base class for the main features of a material in Babylon.js
  80918. */
  80919. export class Material implements IAnimatable {
  80920. /**
  80921. * Returns the triangle fill mode
  80922. */
  80923. static readonly TriangleFillMode: number;
  80924. /**
  80925. * Returns the wireframe mode
  80926. */
  80927. static readonly WireFrameFillMode: number;
  80928. /**
  80929. * Returns the point fill mode
  80930. */
  80931. static readonly PointFillMode: number;
  80932. /**
  80933. * Returns the point list draw mode
  80934. */
  80935. static readonly PointListDrawMode: number;
  80936. /**
  80937. * Returns the line list draw mode
  80938. */
  80939. static readonly LineListDrawMode: number;
  80940. /**
  80941. * Returns the line loop draw mode
  80942. */
  80943. static readonly LineLoopDrawMode: number;
  80944. /**
  80945. * Returns the line strip draw mode
  80946. */
  80947. static readonly LineStripDrawMode: number;
  80948. /**
  80949. * Returns the triangle strip draw mode
  80950. */
  80951. static readonly TriangleStripDrawMode: number;
  80952. /**
  80953. * Returns the triangle fan draw mode
  80954. */
  80955. static readonly TriangleFanDrawMode: number;
  80956. /**
  80957. * Stores the clock-wise side orientation
  80958. */
  80959. static readonly ClockWiseSideOrientation: number;
  80960. /**
  80961. * Stores the counter clock-wise side orientation
  80962. */
  80963. static readonly CounterClockWiseSideOrientation: number;
  80964. /**
  80965. * The dirty texture flag value
  80966. */
  80967. static readonly TextureDirtyFlag: number;
  80968. /**
  80969. * The dirty light flag value
  80970. */
  80971. static readonly LightDirtyFlag: number;
  80972. /**
  80973. * The dirty fresnel flag value
  80974. */
  80975. static readonly FresnelDirtyFlag: number;
  80976. /**
  80977. * The dirty attribute flag value
  80978. */
  80979. static readonly AttributesDirtyFlag: number;
  80980. /**
  80981. * The dirty misc flag value
  80982. */
  80983. static readonly MiscDirtyFlag: number;
  80984. /**
  80985. * The all dirty flag value
  80986. */
  80987. static readonly AllDirtyFlag: number;
  80988. /**
  80989. * The ID of the material
  80990. */
  80991. id: string;
  80992. /**
  80993. * Gets or sets the unique id of the material
  80994. */
  80995. uniqueId: number;
  80996. /**
  80997. * The name of the material
  80998. */
  80999. name: string;
  81000. /**
  81001. * Gets or sets user defined metadata
  81002. */
  81003. metadata: any;
  81004. /**
  81005. * For internal use only. Please do not use.
  81006. */
  81007. reservedDataStore: any;
  81008. /**
  81009. * Specifies if the ready state should be checked on each call
  81010. */
  81011. checkReadyOnEveryCall: boolean;
  81012. /**
  81013. * Specifies if the ready state should be checked once
  81014. */
  81015. checkReadyOnlyOnce: boolean;
  81016. /**
  81017. * The state of the material
  81018. */
  81019. state: string;
  81020. /**
  81021. * The alpha value of the material
  81022. */
  81023. protected _alpha: number;
  81024. /**
  81025. * List of inspectable custom properties (used by the Inspector)
  81026. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81027. */
  81028. inspectableCustomProperties: IInspectable[];
  81029. /**
  81030. * Sets the alpha value of the material
  81031. */
  81032. /**
  81033. * Gets the alpha value of the material
  81034. */
  81035. alpha: number;
  81036. /**
  81037. * Specifies if back face culling is enabled
  81038. */
  81039. protected _backFaceCulling: boolean;
  81040. /**
  81041. * Sets the back-face culling state
  81042. */
  81043. /**
  81044. * Gets the back-face culling state
  81045. */
  81046. backFaceCulling: boolean;
  81047. /**
  81048. * Stores the value for side orientation
  81049. */
  81050. sideOrientation: number;
  81051. /**
  81052. * Callback triggered when the material is compiled
  81053. */
  81054. onCompiled: (effect: Effect) => void;
  81055. /**
  81056. * Callback triggered when an error occurs
  81057. */
  81058. onError: (effect: Effect, errors: string) => void;
  81059. /**
  81060. * Callback triggered to get the render target textures
  81061. */
  81062. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  81063. /**
  81064. * Gets a boolean indicating that current material needs to register RTT
  81065. */
  81066. readonly hasRenderTargetTextures: boolean;
  81067. /**
  81068. * Specifies if the material should be serialized
  81069. */
  81070. doNotSerialize: boolean;
  81071. /**
  81072. * @hidden
  81073. */
  81074. _storeEffectOnSubMeshes: boolean;
  81075. /**
  81076. * Stores the animations for the material
  81077. */
  81078. animations: Array<Animation>;
  81079. /**
  81080. * An event triggered when the material is disposed
  81081. */
  81082. onDisposeObservable: Observable<Material>;
  81083. /**
  81084. * An observer which watches for dispose events
  81085. */
  81086. private _onDisposeObserver;
  81087. private _onUnBindObservable;
  81088. /**
  81089. * Called during a dispose event
  81090. */
  81091. onDispose: () => void;
  81092. private _onBindObservable;
  81093. /**
  81094. * An event triggered when the material is bound
  81095. */
  81096. readonly onBindObservable: Observable<AbstractMesh>;
  81097. /**
  81098. * An observer which watches for bind events
  81099. */
  81100. private _onBindObserver;
  81101. /**
  81102. * Called during a bind event
  81103. */
  81104. onBind: (Mesh: AbstractMesh) => void;
  81105. /**
  81106. * An event triggered when the material is unbound
  81107. */
  81108. readonly onUnBindObservable: Observable<Material>;
  81109. /**
  81110. * Stores the value of the alpha mode
  81111. */
  81112. private _alphaMode;
  81113. /**
  81114. * Sets the value of the alpha mode.
  81115. *
  81116. * | Value | Type | Description |
  81117. * | --- | --- | --- |
  81118. * | 0 | ALPHA_DISABLE | |
  81119. * | 1 | ALPHA_ADD | |
  81120. * | 2 | ALPHA_COMBINE | |
  81121. * | 3 | ALPHA_SUBTRACT | |
  81122. * | 4 | ALPHA_MULTIPLY | |
  81123. * | 5 | ALPHA_MAXIMIZED | |
  81124. * | 6 | ALPHA_ONEONE | |
  81125. * | 7 | ALPHA_PREMULTIPLIED | |
  81126. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  81127. * | 9 | ALPHA_INTERPOLATE | |
  81128. * | 10 | ALPHA_SCREENMODE | |
  81129. *
  81130. */
  81131. /**
  81132. * Gets the value of the alpha mode
  81133. */
  81134. alphaMode: number;
  81135. /**
  81136. * Stores the state of the need depth pre-pass value
  81137. */
  81138. private _needDepthPrePass;
  81139. /**
  81140. * Sets the need depth pre-pass value
  81141. */
  81142. /**
  81143. * Gets the depth pre-pass value
  81144. */
  81145. needDepthPrePass: boolean;
  81146. /**
  81147. * Specifies if depth writing should be disabled
  81148. */
  81149. disableDepthWrite: boolean;
  81150. /**
  81151. * Specifies if depth writing should be forced
  81152. */
  81153. forceDepthWrite: boolean;
  81154. /**
  81155. * Specifies if there should be a separate pass for culling
  81156. */
  81157. separateCullingPass: boolean;
  81158. /**
  81159. * Stores the state specifing if fog should be enabled
  81160. */
  81161. private _fogEnabled;
  81162. /**
  81163. * Sets the state for enabling fog
  81164. */
  81165. /**
  81166. * Gets the value of the fog enabled state
  81167. */
  81168. fogEnabled: boolean;
  81169. /**
  81170. * Stores the size of points
  81171. */
  81172. pointSize: number;
  81173. /**
  81174. * Stores the z offset value
  81175. */
  81176. zOffset: number;
  81177. /**
  81178. * Gets a value specifying if wireframe mode is enabled
  81179. */
  81180. /**
  81181. * Sets the state of wireframe mode
  81182. */
  81183. wireframe: boolean;
  81184. /**
  81185. * Gets the value specifying if point clouds are enabled
  81186. */
  81187. /**
  81188. * Sets the state of point cloud mode
  81189. */
  81190. pointsCloud: boolean;
  81191. /**
  81192. * Gets the material fill mode
  81193. */
  81194. /**
  81195. * Sets the material fill mode
  81196. */
  81197. fillMode: number;
  81198. /**
  81199. * @hidden
  81200. * Stores the effects for the material
  81201. */
  81202. _effect: Nullable<Effect>;
  81203. /**
  81204. * @hidden
  81205. * Specifies if the material was previously ready
  81206. */
  81207. _wasPreviouslyReady: boolean;
  81208. /**
  81209. * Specifies if uniform buffers should be used
  81210. */
  81211. private _useUBO;
  81212. /**
  81213. * Stores a reference to the scene
  81214. */
  81215. private _scene;
  81216. /**
  81217. * Stores the fill mode state
  81218. */
  81219. private _fillMode;
  81220. /**
  81221. * Specifies if the depth write state should be cached
  81222. */
  81223. private _cachedDepthWriteState;
  81224. /**
  81225. * Stores the uniform buffer
  81226. */
  81227. protected _uniformBuffer: UniformBuffer;
  81228. /** @hidden */
  81229. _indexInSceneMaterialArray: number;
  81230. /** @hidden */
  81231. meshMap: Nullable<{
  81232. [id: string]: AbstractMesh | undefined;
  81233. }>;
  81234. /**
  81235. * Creates a material instance
  81236. * @param name defines the name of the material
  81237. * @param scene defines the scene to reference
  81238. * @param doNotAdd specifies if the material should be added to the scene
  81239. */
  81240. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  81241. /**
  81242. * Returns a string representation of the current material
  81243. * @param fullDetails defines a boolean indicating which levels of logging is desired
  81244. * @returns a string with material information
  81245. */
  81246. toString(fullDetails?: boolean): string;
  81247. /**
  81248. * Gets the class name of the material
  81249. * @returns a string with the class name of the material
  81250. */
  81251. getClassName(): string;
  81252. /**
  81253. * Specifies if updates for the material been locked
  81254. */
  81255. readonly isFrozen: boolean;
  81256. /**
  81257. * Locks updates for the material
  81258. */
  81259. freeze(): void;
  81260. /**
  81261. * Unlocks updates for the material
  81262. */
  81263. unfreeze(): void;
  81264. /**
  81265. * Specifies if the material is ready to be used
  81266. * @param mesh defines the mesh to check
  81267. * @param useInstances specifies if instances should be used
  81268. * @returns a boolean indicating if the material is ready to be used
  81269. */
  81270. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  81271. /**
  81272. * Specifies that the submesh is ready to be used
  81273. * @param mesh defines the mesh to check
  81274. * @param subMesh defines which submesh to check
  81275. * @param useInstances specifies that instances should be used
  81276. * @returns a boolean indicating that the submesh is ready or not
  81277. */
  81278. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  81279. /**
  81280. * Returns the material effect
  81281. * @returns the effect associated with the material
  81282. */
  81283. getEffect(): Nullable<Effect>;
  81284. /**
  81285. * Returns the current scene
  81286. * @returns a Scene
  81287. */
  81288. getScene(): Scene;
  81289. /**
  81290. * Specifies if the material will require alpha blending
  81291. * @returns a boolean specifying if alpha blending is needed
  81292. */
  81293. needAlphaBlending(): boolean;
  81294. /**
  81295. * Specifies if the mesh will require alpha blending
  81296. * @param mesh defines the mesh to check
  81297. * @returns a boolean specifying if alpha blending is needed for the mesh
  81298. */
  81299. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  81300. /**
  81301. * Specifies if this material should be rendered in alpha test mode
  81302. * @returns a boolean specifying if an alpha test is needed.
  81303. */
  81304. needAlphaTesting(): boolean;
  81305. /**
  81306. * Gets the texture used for the alpha test
  81307. * @returns the texture to use for alpha testing
  81308. */
  81309. getAlphaTestTexture(): Nullable<BaseTexture>;
  81310. /**
  81311. * Marks the material to indicate that it needs to be re-calculated
  81312. */
  81313. markDirty(): void;
  81314. /** @hidden */
  81315. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  81316. /**
  81317. * Binds the material to the mesh
  81318. * @param world defines the world transformation matrix
  81319. * @param mesh defines the mesh to bind the material to
  81320. */
  81321. bind(world: Matrix, mesh?: Mesh): void;
  81322. /**
  81323. * Binds the submesh to the material
  81324. * @param world defines the world transformation matrix
  81325. * @param mesh defines the mesh containing the submesh
  81326. * @param subMesh defines the submesh to bind the material to
  81327. */
  81328. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  81329. /**
  81330. * Binds the world matrix to the material
  81331. * @param world defines the world transformation matrix
  81332. */
  81333. bindOnlyWorldMatrix(world: Matrix): void;
  81334. /**
  81335. * Binds the scene's uniform buffer to the effect.
  81336. * @param effect defines the effect to bind to the scene uniform buffer
  81337. * @param sceneUbo defines the uniform buffer storing scene data
  81338. */
  81339. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  81340. /**
  81341. * Binds the view matrix to the effect
  81342. * @param effect defines the effect to bind the view matrix to
  81343. */
  81344. bindView(effect: Effect): void;
  81345. /**
  81346. * Binds the view projection matrix to the effect
  81347. * @param effect defines the effect to bind the view projection matrix to
  81348. */
  81349. bindViewProjection(effect: Effect): void;
  81350. /**
  81351. * Specifies if material alpha testing should be turned on for the mesh
  81352. * @param mesh defines the mesh to check
  81353. */
  81354. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  81355. /**
  81356. * Processes to execute after binding the material to a mesh
  81357. * @param mesh defines the rendered mesh
  81358. */
  81359. protected _afterBind(mesh?: Mesh): void;
  81360. /**
  81361. * Unbinds the material from the mesh
  81362. */
  81363. unbind(): void;
  81364. /**
  81365. * Gets the active textures from the material
  81366. * @returns an array of textures
  81367. */
  81368. getActiveTextures(): BaseTexture[];
  81369. /**
  81370. * Specifies if the material uses a texture
  81371. * @param texture defines the texture to check against the material
  81372. * @returns a boolean specifying if the material uses the texture
  81373. */
  81374. hasTexture(texture: BaseTexture): boolean;
  81375. /**
  81376. * Makes a duplicate of the material, and gives it a new name
  81377. * @param name defines the new name for the duplicated material
  81378. * @returns the cloned material
  81379. */
  81380. clone(name: string): Nullable<Material>;
  81381. /**
  81382. * Gets the meshes bound to the material
  81383. * @returns an array of meshes bound to the material
  81384. */
  81385. getBindedMeshes(): AbstractMesh[];
  81386. /**
  81387. * Force shader compilation
  81388. * @param mesh defines the mesh associated with this material
  81389. * @param onCompiled defines a function to execute once the material is compiled
  81390. * @param options defines the options to configure the compilation
  81391. */
  81392. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  81393. clipPlane: boolean;
  81394. }>): void;
  81395. /**
  81396. * Force shader compilation
  81397. * @param mesh defines the mesh that will use this material
  81398. * @param options defines additional options for compiling the shaders
  81399. * @returns a promise that resolves when the compilation completes
  81400. */
  81401. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  81402. clipPlane: boolean;
  81403. }>): Promise<void>;
  81404. private static readonly _ImageProcessingDirtyCallBack;
  81405. private static readonly _TextureDirtyCallBack;
  81406. private static readonly _FresnelDirtyCallBack;
  81407. private static readonly _MiscDirtyCallBack;
  81408. private static readonly _LightsDirtyCallBack;
  81409. private static readonly _AttributeDirtyCallBack;
  81410. private static _FresnelAndMiscDirtyCallBack;
  81411. private static _TextureAndMiscDirtyCallBack;
  81412. private static readonly _DirtyCallbackArray;
  81413. private static readonly _RunDirtyCallBacks;
  81414. /**
  81415. * Marks a define in the material to indicate that it needs to be re-computed
  81416. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  81417. */
  81418. markAsDirty(flag: number): void;
  81419. /**
  81420. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  81421. * @param func defines a function which checks material defines against the submeshes
  81422. */
  81423. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  81424. /**
  81425. * Indicates that image processing needs to be re-calculated for all submeshes
  81426. */
  81427. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  81428. /**
  81429. * Indicates that textures need to be re-calculated for all submeshes
  81430. */
  81431. protected _markAllSubMeshesAsTexturesDirty(): void;
  81432. /**
  81433. * Indicates that fresnel needs to be re-calculated for all submeshes
  81434. */
  81435. protected _markAllSubMeshesAsFresnelDirty(): void;
  81436. /**
  81437. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  81438. */
  81439. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  81440. /**
  81441. * Indicates that lights need to be re-calculated for all submeshes
  81442. */
  81443. protected _markAllSubMeshesAsLightsDirty(): void;
  81444. /**
  81445. * Indicates that attributes need to be re-calculated for all submeshes
  81446. */
  81447. protected _markAllSubMeshesAsAttributesDirty(): void;
  81448. /**
  81449. * Indicates that misc needs to be re-calculated for all submeshes
  81450. */
  81451. protected _markAllSubMeshesAsMiscDirty(): void;
  81452. /**
  81453. * Indicates that textures and misc need to be re-calculated for all submeshes
  81454. */
  81455. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  81456. /**
  81457. * Disposes the material
  81458. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  81459. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  81460. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  81461. */
  81462. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  81463. /** @hidden */
  81464. private releaseVertexArrayObject;
  81465. /**
  81466. * Serializes this material
  81467. * @returns the serialized material object
  81468. */
  81469. serialize(): any;
  81470. /**
  81471. * Creates a material from parsed material data
  81472. * @param parsedMaterial defines parsed material data
  81473. * @param scene defines the hosting scene
  81474. * @param rootUrl defines the root URL to use to load textures
  81475. * @returns a new material
  81476. */
  81477. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  81478. }
  81479. }
  81480. declare module BABYLON {
  81481. /**
  81482. * Base class for submeshes
  81483. */
  81484. export class BaseSubMesh {
  81485. /** @hidden */
  81486. _materialDefines: Nullable<MaterialDefines>;
  81487. /** @hidden */
  81488. _materialEffect: Nullable<Effect>;
  81489. /**
  81490. * Gets associated effect
  81491. */
  81492. readonly effect: Nullable<Effect>;
  81493. /**
  81494. * Sets associated effect (effect used to render this submesh)
  81495. * @param effect defines the effect to associate with
  81496. * @param defines defines the set of defines used to compile this effect
  81497. */
  81498. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  81499. }
  81500. /**
  81501. * Defines a subdivision inside a mesh
  81502. */
  81503. export class SubMesh extends BaseSubMesh implements ICullable {
  81504. /** the material index to use */
  81505. materialIndex: number;
  81506. /** vertex index start */
  81507. verticesStart: number;
  81508. /** vertices count */
  81509. verticesCount: number;
  81510. /** index start */
  81511. indexStart: number;
  81512. /** indices count */
  81513. indexCount: number;
  81514. /** @hidden */
  81515. _linesIndexCount: number;
  81516. private _mesh;
  81517. private _renderingMesh;
  81518. private _boundingInfo;
  81519. private _linesIndexBuffer;
  81520. /** @hidden */
  81521. _lastColliderWorldVertices: Nullable<Vector3[]>;
  81522. /** @hidden */
  81523. _trianglePlanes: Plane[];
  81524. /** @hidden */
  81525. _lastColliderTransformMatrix: Matrix;
  81526. /** @hidden */
  81527. _renderId: number;
  81528. /** @hidden */
  81529. _alphaIndex: number;
  81530. /** @hidden */
  81531. _distanceToCamera: number;
  81532. /** @hidden */
  81533. _id: number;
  81534. private _currentMaterial;
  81535. /**
  81536. * Add a new submesh to a mesh
  81537. * @param materialIndex defines the material index to use
  81538. * @param verticesStart defines vertex index start
  81539. * @param verticesCount defines vertices count
  81540. * @param indexStart defines index start
  81541. * @param indexCount defines indices count
  81542. * @param mesh defines the parent mesh
  81543. * @param renderingMesh defines an optional rendering mesh
  81544. * @param createBoundingBox defines if bounding box should be created for this submesh
  81545. * @returns the new submesh
  81546. */
  81547. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  81548. /**
  81549. * Creates a new submesh
  81550. * @param materialIndex defines the material index to use
  81551. * @param verticesStart defines vertex index start
  81552. * @param verticesCount defines vertices count
  81553. * @param indexStart defines index start
  81554. * @param indexCount defines indices count
  81555. * @param mesh defines the parent mesh
  81556. * @param renderingMesh defines an optional rendering mesh
  81557. * @param createBoundingBox defines if bounding box should be created for this submesh
  81558. */
  81559. constructor(
  81560. /** the material index to use */
  81561. materialIndex: number,
  81562. /** vertex index start */
  81563. verticesStart: number,
  81564. /** vertices count */
  81565. verticesCount: number,
  81566. /** index start */
  81567. indexStart: number,
  81568. /** indices count */
  81569. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  81570. /**
  81571. * Returns true if this submesh covers the entire parent mesh
  81572. * @ignorenaming
  81573. */
  81574. readonly IsGlobal: boolean;
  81575. /**
  81576. * Returns the submesh BoudingInfo object
  81577. * @returns current bounding info (or mesh's one if the submesh is global)
  81578. */
  81579. getBoundingInfo(): BoundingInfo;
  81580. /**
  81581. * Sets the submesh BoundingInfo
  81582. * @param boundingInfo defines the new bounding info to use
  81583. * @returns the SubMesh
  81584. */
  81585. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  81586. /**
  81587. * Returns the mesh of the current submesh
  81588. * @return the parent mesh
  81589. */
  81590. getMesh(): AbstractMesh;
  81591. /**
  81592. * Returns the rendering mesh of the submesh
  81593. * @returns the rendering mesh (could be different from parent mesh)
  81594. */
  81595. getRenderingMesh(): Mesh;
  81596. /**
  81597. * Returns the submesh material
  81598. * @returns null or the current material
  81599. */
  81600. getMaterial(): Nullable<Material>;
  81601. /**
  81602. * Sets a new updated BoundingInfo object to the submesh
  81603. * @returns the SubMesh
  81604. */
  81605. refreshBoundingInfo(): SubMesh;
  81606. /** @hidden */
  81607. _checkCollision(collider: Collider): boolean;
  81608. /**
  81609. * Updates the submesh BoundingInfo
  81610. * @param world defines the world matrix to use to update the bounding info
  81611. * @returns the submesh
  81612. */
  81613. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  81614. /**
  81615. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  81616. * @param frustumPlanes defines the frustum planes
  81617. * @returns true if the submesh is intersecting with the frustum
  81618. */
  81619. isInFrustum(frustumPlanes: Plane[]): boolean;
  81620. /**
  81621. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  81622. * @param frustumPlanes defines the frustum planes
  81623. * @returns true if the submesh is inside the frustum
  81624. */
  81625. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81626. /**
  81627. * Renders the submesh
  81628. * @param enableAlphaMode defines if alpha needs to be used
  81629. * @returns the submesh
  81630. */
  81631. render(enableAlphaMode: boolean): SubMesh;
  81632. /**
  81633. * @hidden
  81634. */
  81635. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  81636. /**
  81637. * Checks if the submesh intersects with a ray
  81638. * @param ray defines the ray to test
  81639. * @returns true is the passed ray intersects the submesh bounding box
  81640. */
  81641. canIntersects(ray: Ray): boolean;
  81642. /**
  81643. * Intersects current submesh with a ray
  81644. * @param ray defines the ray to test
  81645. * @param positions defines mesh's positions array
  81646. * @param indices defines mesh's indices array
  81647. * @param fastCheck defines if only bounding info should be used
  81648. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81649. * @returns intersection info or null if no intersection
  81650. */
  81651. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  81652. /** @hidden */
  81653. private _intersectLines;
  81654. /** @hidden */
  81655. private _intersectTriangles;
  81656. /** @hidden */
  81657. _rebuild(): void;
  81658. /**
  81659. * Creates a new submesh from the passed mesh
  81660. * @param newMesh defines the new hosting mesh
  81661. * @param newRenderingMesh defines an optional rendering mesh
  81662. * @returns the new submesh
  81663. */
  81664. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  81665. /**
  81666. * Release associated resources
  81667. */
  81668. dispose(): void;
  81669. /**
  81670. * Gets the class name
  81671. * @returns the string "SubMesh".
  81672. */
  81673. getClassName(): string;
  81674. /**
  81675. * Creates a new submesh from indices data
  81676. * @param materialIndex the index of the main mesh material
  81677. * @param startIndex the index where to start the copy in the mesh indices array
  81678. * @param indexCount the number of indices to copy then from the startIndex
  81679. * @param mesh the main mesh to create the submesh from
  81680. * @param renderingMesh the optional rendering mesh
  81681. * @returns a new submesh
  81682. */
  81683. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  81684. }
  81685. }
  81686. declare module BABYLON {
  81687. /**
  81688. * Class used to store geometry data (vertex buffers + index buffer)
  81689. */
  81690. export class Geometry implements IGetSetVerticesData {
  81691. /**
  81692. * Gets or sets the ID of the geometry
  81693. */
  81694. id: string;
  81695. /**
  81696. * Gets or sets the unique ID of the geometry
  81697. */
  81698. uniqueId: number;
  81699. /**
  81700. * Gets the delay loading state of the geometry (none by default which means not delayed)
  81701. */
  81702. delayLoadState: number;
  81703. /**
  81704. * Gets the file containing the data to load when running in delay load state
  81705. */
  81706. delayLoadingFile: Nullable<string>;
  81707. /**
  81708. * Callback called when the geometry is updated
  81709. */
  81710. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  81711. private _scene;
  81712. private _engine;
  81713. private _meshes;
  81714. private _totalVertices;
  81715. /** @hidden */
  81716. _indices: IndicesArray;
  81717. /** @hidden */
  81718. _vertexBuffers: {
  81719. [key: string]: VertexBuffer;
  81720. };
  81721. private _isDisposed;
  81722. private _extend;
  81723. private _boundingBias;
  81724. /** @hidden */
  81725. _delayInfo: Array<string>;
  81726. private _indexBuffer;
  81727. private _indexBufferIsUpdatable;
  81728. /** @hidden */
  81729. _boundingInfo: Nullable<BoundingInfo>;
  81730. /** @hidden */
  81731. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  81732. /** @hidden */
  81733. _softwareSkinningFrameId: number;
  81734. private _vertexArrayObjects;
  81735. private _updatable;
  81736. /** @hidden */
  81737. _positions: Nullable<Vector3[]>;
  81738. /**
  81739. * 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
  81740. */
  81741. /**
  81742. * 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
  81743. */
  81744. boundingBias: Vector2;
  81745. /**
  81746. * Static function used to attach a new empty geometry to a mesh
  81747. * @param mesh defines the mesh to attach the geometry to
  81748. * @returns the new Geometry
  81749. */
  81750. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  81751. /**
  81752. * Creates a new geometry
  81753. * @param id defines the unique ID
  81754. * @param scene defines the hosting scene
  81755. * @param vertexData defines the VertexData used to get geometry data
  81756. * @param updatable defines if geometry must be updatable (false by default)
  81757. * @param mesh defines the mesh that will be associated with the geometry
  81758. */
  81759. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  81760. /**
  81761. * Gets the current extend of the geometry
  81762. */
  81763. readonly extend: {
  81764. minimum: Vector3;
  81765. maximum: Vector3;
  81766. };
  81767. /**
  81768. * Gets the hosting scene
  81769. * @returns the hosting Scene
  81770. */
  81771. getScene(): Scene;
  81772. /**
  81773. * Gets the hosting engine
  81774. * @returns the hosting Engine
  81775. */
  81776. getEngine(): Engine;
  81777. /**
  81778. * Defines if the geometry is ready to use
  81779. * @returns true if the geometry is ready to be used
  81780. */
  81781. isReady(): boolean;
  81782. /**
  81783. * Gets a value indicating that the geometry should not be serialized
  81784. */
  81785. readonly doNotSerialize: boolean;
  81786. /** @hidden */
  81787. _rebuild(): void;
  81788. /**
  81789. * Affects all geometry data in one call
  81790. * @param vertexData defines the geometry data
  81791. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  81792. */
  81793. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  81794. /**
  81795. * Set specific vertex data
  81796. * @param kind defines the data kind (Position, normal, etc...)
  81797. * @param data defines the vertex data to use
  81798. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  81799. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  81800. */
  81801. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  81802. /**
  81803. * Removes a specific vertex data
  81804. * @param kind defines the data kind (Position, normal, etc...)
  81805. */
  81806. removeVerticesData(kind: string): void;
  81807. /**
  81808. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  81809. * @param buffer defines the vertex buffer to use
  81810. * @param totalVertices defines the total number of vertices for position kind (could be null)
  81811. */
  81812. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  81813. /**
  81814. * Update a specific vertex buffer
  81815. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  81816. * It will do nothing if the buffer is not updatable
  81817. * @param kind defines the data kind (Position, normal, etc...)
  81818. * @param data defines the data to use
  81819. * @param offset defines the offset in the target buffer where to store the data
  81820. * @param useBytes set to true if the offset is in bytes
  81821. */
  81822. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  81823. /**
  81824. * Update a specific vertex buffer
  81825. * This function will create a new buffer if the current one is not updatable
  81826. * @param kind defines the data kind (Position, normal, etc...)
  81827. * @param data defines the data to use
  81828. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  81829. */
  81830. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  81831. private _updateBoundingInfo;
  81832. /** @hidden */
  81833. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  81834. /**
  81835. * Gets total number of vertices
  81836. * @returns the total number of vertices
  81837. */
  81838. getTotalVertices(): number;
  81839. /**
  81840. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  81841. * @param kind defines the data kind (Position, normal, etc...)
  81842. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81843. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81844. * @returns a float array containing vertex data
  81845. */
  81846. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81847. /**
  81848. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  81849. * @param kind defines the data kind (Position, normal, etc...)
  81850. * @returns true if the vertex buffer with the specified kind is updatable
  81851. */
  81852. isVertexBufferUpdatable(kind: string): boolean;
  81853. /**
  81854. * Gets a specific vertex buffer
  81855. * @param kind defines the data kind (Position, normal, etc...)
  81856. * @returns a VertexBuffer
  81857. */
  81858. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  81859. /**
  81860. * Returns all vertex buffers
  81861. * @return an object holding all vertex buffers indexed by kind
  81862. */
  81863. getVertexBuffers(): Nullable<{
  81864. [key: string]: VertexBuffer;
  81865. }>;
  81866. /**
  81867. * Gets a boolean indicating if specific vertex buffer is present
  81868. * @param kind defines the data kind (Position, normal, etc...)
  81869. * @returns true if data is present
  81870. */
  81871. isVerticesDataPresent(kind: string): boolean;
  81872. /**
  81873. * Gets a list of all attached data kinds (Position, normal, etc...)
  81874. * @returns a list of string containing all kinds
  81875. */
  81876. getVerticesDataKinds(): string[];
  81877. /**
  81878. * Update index buffer
  81879. * @param indices defines the indices to store in the index buffer
  81880. * @param offset defines the offset in the target buffer where to store the data
  81881. * @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)
  81882. */
  81883. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  81884. /**
  81885. * Creates a new index buffer
  81886. * @param indices defines the indices to store in the index buffer
  81887. * @param totalVertices defines the total number of vertices (could be null)
  81888. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  81889. */
  81890. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  81891. /**
  81892. * Return the total number of indices
  81893. * @returns the total number of indices
  81894. */
  81895. getTotalIndices(): number;
  81896. /**
  81897. * Gets the index buffer array
  81898. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81899. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81900. * @returns the index buffer array
  81901. */
  81902. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81903. /**
  81904. * Gets the index buffer
  81905. * @return the index buffer
  81906. */
  81907. getIndexBuffer(): Nullable<WebGLBuffer>;
  81908. /** @hidden */
  81909. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  81910. /**
  81911. * Release the associated resources for a specific mesh
  81912. * @param mesh defines the source mesh
  81913. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  81914. */
  81915. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  81916. /**
  81917. * Apply current geometry to a given mesh
  81918. * @param mesh defines the mesh to apply geometry to
  81919. */
  81920. applyToMesh(mesh: Mesh): void;
  81921. private _updateExtend;
  81922. private _applyToMesh;
  81923. private notifyUpdate;
  81924. /**
  81925. * Load the geometry if it was flagged as delay loaded
  81926. * @param scene defines the hosting scene
  81927. * @param onLoaded defines a callback called when the geometry is loaded
  81928. */
  81929. load(scene: Scene, onLoaded?: () => void): void;
  81930. private _queueLoad;
  81931. /**
  81932. * Invert the geometry to move from a right handed system to a left handed one.
  81933. */
  81934. toLeftHanded(): void;
  81935. /** @hidden */
  81936. _resetPointsArrayCache(): void;
  81937. /** @hidden */
  81938. _generatePointsArray(): boolean;
  81939. /**
  81940. * Gets a value indicating if the geometry is disposed
  81941. * @returns true if the geometry was disposed
  81942. */
  81943. isDisposed(): boolean;
  81944. private _disposeVertexArrayObjects;
  81945. /**
  81946. * Free all associated resources
  81947. */
  81948. dispose(): void;
  81949. /**
  81950. * Clone the current geometry into a new geometry
  81951. * @param id defines the unique ID of the new geometry
  81952. * @returns a new geometry object
  81953. */
  81954. copy(id: string): Geometry;
  81955. /**
  81956. * Serialize the current geometry info (and not the vertices data) into a JSON object
  81957. * @return a JSON representation of the current geometry data (without the vertices data)
  81958. */
  81959. serialize(): any;
  81960. private toNumberArray;
  81961. /**
  81962. * Serialize all vertices data into a JSON oject
  81963. * @returns a JSON representation of the current geometry data
  81964. */
  81965. serializeVerticeData(): any;
  81966. /**
  81967. * Extracts a clone of a mesh geometry
  81968. * @param mesh defines the source mesh
  81969. * @param id defines the unique ID of the new geometry object
  81970. * @returns the new geometry object
  81971. */
  81972. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  81973. /**
  81974. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  81975. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  81976. * Be aware Math.random() could cause collisions, but:
  81977. * "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"
  81978. * @returns a string containing a new GUID
  81979. */
  81980. static RandomId(): string;
  81981. /** @hidden */
  81982. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  81983. private static _CleanMatricesWeights;
  81984. /**
  81985. * Create a new geometry from persisted data (Using .babylon file format)
  81986. * @param parsedVertexData defines the persisted data
  81987. * @param scene defines the hosting scene
  81988. * @param rootUrl defines the root url to use to load assets (like delayed data)
  81989. * @returns the new geometry object
  81990. */
  81991. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  81992. }
  81993. }
  81994. declare module BABYLON {
  81995. /**
  81996. * Define an interface for all classes that will get and set the data on vertices
  81997. */
  81998. export interface IGetSetVerticesData {
  81999. /**
  82000. * Gets a boolean indicating if specific vertex data is present
  82001. * @param kind defines the vertex data kind to use
  82002. * @returns true is data kind is present
  82003. */
  82004. isVerticesDataPresent(kind: string): boolean;
  82005. /**
  82006. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82007. * @param kind defines the data kind (Position, normal, etc...)
  82008. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82009. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82010. * @returns a float array containing vertex data
  82011. */
  82012. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82013. /**
  82014. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  82015. * @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.
  82016. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82017. * @returns the indices array or an empty array if the mesh has no geometry
  82018. */
  82019. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82020. /**
  82021. * Set specific vertex data
  82022. * @param kind defines the data kind (Position, normal, etc...)
  82023. * @param data defines the vertex data to use
  82024. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82025. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82026. */
  82027. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  82028. /**
  82029. * Update a specific associated vertex buffer
  82030. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  82031. * - VertexBuffer.PositionKind
  82032. * - VertexBuffer.UVKind
  82033. * - VertexBuffer.UV2Kind
  82034. * - VertexBuffer.UV3Kind
  82035. * - VertexBuffer.UV4Kind
  82036. * - VertexBuffer.UV5Kind
  82037. * - VertexBuffer.UV6Kind
  82038. * - VertexBuffer.ColorKind
  82039. * - VertexBuffer.MatricesIndicesKind
  82040. * - VertexBuffer.MatricesIndicesExtraKind
  82041. * - VertexBuffer.MatricesWeightsKind
  82042. * - VertexBuffer.MatricesWeightsExtraKind
  82043. * @param data defines the data source
  82044. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  82045. * @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)
  82046. */
  82047. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  82048. /**
  82049. * Creates a new index buffer
  82050. * @param indices defines the indices to store in the index buffer
  82051. * @param totalVertices defines the total number of vertices (could be null)
  82052. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82053. */
  82054. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  82055. }
  82056. /**
  82057. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  82058. */
  82059. export class VertexData {
  82060. /**
  82061. * Mesh side orientation : usually the external or front surface
  82062. */
  82063. static readonly FRONTSIDE: number;
  82064. /**
  82065. * Mesh side orientation : usually the internal or back surface
  82066. */
  82067. static readonly BACKSIDE: number;
  82068. /**
  82069. * Mesh side orientation : both internal and external or front and back surfaces
  82070. */
  82071. static readonly DOUBLESIDE: number;
  82072. /**
  82073. * Mesh side orientation : by default, `FRONTSIDE`
  82074. */
  82075. static readonly DEFAULTSIDE: number;
  82076. /**
  82077. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  82078. */
  82079. positions: Nullable<FloatArray>;
  82080. /**
  82081. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  82082. */
  82083. normals: Nullable<FloatArray>;
  82084. /**
  82085. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  82086. */
  82087. tangents: Nullable<FloatArray>;
  82088. /**
  82089. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82090. */
  82091. uvs: Nullable<FloatArray>;
  82092. /**
  82093. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82094. */
  82095. uvs2: Nullable<FloatArray>;
  82096. /**
  82097. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82098. */
  82099. uvs3: Nullable<FloatArray>;
  82100. /**
  82101. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82102. */
  82103. uvs4: Nullable<FloatArray>;
  82104. /**
  82105. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82106. */
  82107. uvs5: Nullable<FloatArray>;
  82108. /**
  82109. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82110. */
  82111. uvs6: Nullable<FloatArray>;
  82112. /**
  82113. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  82114. */
  82115. colors: Nullable<FloatArray>;
  82116. /**
  82117. * 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).
  82118. */
  82119. matricesIndices: Nullable<FloatArray>;
  82120. /**
  82121. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  82122. */
  82123. matricesWeights: Nullable<FloatArray>;
  82124. /**
  82125. * An array extending the number of possible indices
  82126. */
  82127. matricesIndicesExtra: Nullable<FloatArray>;
  82128. /**
  82129. * An array extending the number of possible weights when the number of indices is extended
  82130. */
  82131. matricesWeightsExtra: Nullable<FloatArray>;
  82132. /**
  82133. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  82134. */
  82135. indices: Nullable<IndicesArray>;
  82136. /**
  82137. * Uses the passed data array to set the set the values for the specified kind of data
  82138. * @param data a linear array of floating numbers
  82139. * @param kind the type of data that is being set, eg positions, colors etc
  82140. */
  82141. set(data: FloatArray, kind: string): void;
  82142. /**
  82143. * Associates the vertexData to the passed Mesh.
  82144. * Sets it as updatable or not (default `false`)
  82145. * @param mesh the mesh the vertexData is applied to
  82146. * @param updatable when used and having the value true allows new data to update the vertexData
  82147. * @returns the VertexData
  82148. */
  82149. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  82150. /**
  82151. * Associates the vertexData to the passed Geometry.
  82152. * Sets it as updatable or not (default `false`)
  82153. * @param geometry the geometry the vertexData is applied to
  82154. * @param updatable when used and having the value true allows new data to update the vertexData
  82155. * @returns VertexData
  82156. */
  82157. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  82158. /**
  82159. * Updates the associated mesh
  82160. * @param mesh the mesh to be updated
  82161. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  82162. * @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
  82163. * @returns VertexData
  82164. */
  82165. updateMesh(mesh: Mesh): VertexData;
  82166. /**
  82167. * Updates the associated geometry
  82168. * @param geometry the geometry to be updated
  82169. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  82170. * @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
  82171. * @returns VertexData.
  82172. */
  82173. updateGeometry(geometry: Geometry): VertexData;
  82174. private _applyTo;
  82175. private _update;
  82176. /**
  82177. * Transforms each position and each normal of the vertexData according to the passed Matrix
  82178. * @param matrix the transforming matrix
  82179. * @returns the VertexData
  82180. */
  82181. transform(matrix: Matrix): VertexData;
  82182. /**
  82183. * Merges the passed VertexData into the current one
  82184. * @param other the VertexData to be merged into the current one
  82185. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  82186. * @returns the modified VertexData
  82187. */
  82188. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  82189. private _mergeElement;
  82190. private _validate;
  82191. /**
  82192. * Serializes the VertexData
  82193. * @returns a serialized object
  82194. */
  82195. serialize(): any;
  82196. /**
  82197. * Extracts the vertexData from a mesh
  82198. * @param mesh the mesh from which to extract the VertexData
  82199. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  82200. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  82201. * @returns the object VertexData associated to the passed mesh
  82202. */
  82203. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  82204. /**
  82205. * Extracts the vertexData from the geometry
  82206. * @param geometry the geometry from which to extract the VertexData
  82207. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  82208. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  82209. * @returns the object VertexData associated to the passed mesh
  82210. */
  82211. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  82212. private static _ExtractFrom;
  82213. /**
  82214. * Creates the VertexData for a Ribbon
  82215. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  82216. * * pathArray array of paths, each of which an array of successive Vector3
  82217. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  82218. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  82219. * * 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
  82220. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82221. * * 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)
  82222. * * 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)
  82223. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  82224. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  82225. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  82226. * @returns the VertexData of the ribbon
  82227. */
  82228. static CreateRibbon(options: {
  82229. pathArray: Vector3[][];
  82230. closeArray?: boolean;
  82231. closePath?: boolean;
  82232. offset?: number;
  82233. sideOrientation?: number;
  82234. frontUVs?: Vector4;
  82235. backUVs?: Vector4;
  82236. invertUV?: boolean;
  82237. uvs?: Vector2[];
  82238. colors?: Color4[];
  82239. }): VertexData;
  82240. /**
  82241. * Creates the VertexData for a box
  82242. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82243. * * size sets the width, height and depth of the box to the value of size, optional default 1
  82244. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  82245. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  82246. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  82247. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  82248. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  82249. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82250. * * 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)
  82251. * * 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)
  82252. * @returns the VertexData of the box
  82253. */
  82254. static CreateBox(options: {
  82255. size?: number;
  82256. width?: number;
  82257. height?: number;
  82258. depth?: number;
  82259. faceUV?: Vector4[];
  82260. faceColors?: Color4[];
  82261. sideOrientation?: number;
  82262. frontUVs?: Vector4;
  82263. backUVs?: Vector4;
  82264. }): VertexData;
  82265. /**
  82266. * Creates the VertexData for an ellipsoid, defaults to a sphere
  82267. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82268. * * segments sets the number of horizontal strips optional, default 32
  82269. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  82270. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  82271. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  82272. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  82273. * * 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
  82274. * * 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
  82275. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82276. * * 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)
  82277. * * 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)
  82278. * @returns the VertexData of the ellipsoid
  82279. */
  82280. static CreateSphere(options: {
  82281. segments?: number;
  82282. diameter?: number;
  82283. diameterX?: number;
  82284. diameterY?: number;
  82285. diameterZ?: number;
  82286. arc?: number;
  82287. slice?: number;
  82288. sideOrientation?: number;
  82289. frontUVs?: Vector4;
  82290. backUVs?: Vector4;
  82291. }): VertexData;
  82292. /**
  82293. * Creates the VertexData for a cylinder, cone or prism
  82294. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82295. * * height sets the height (y direction) of the cylinder, optional, default 2
  82296. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  82297. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  82298. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  82299. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  82300. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  82301. * * 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
  82302. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82303. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82304. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  82305. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  82306. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82307. * * 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)
  82308. * * 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)
  82309. * @returns the VertexData of the cylinder, cone or prism
  82310. */
  82311. static CreateCylinder(options: {
  82312. height?: number;
  82313. diameterTop?: number;
  82314. diameterBottom?: number;
  82315. diameter?: number;
  82316. tessellation?: number;
  82317. subdivisions?: number;
  82318. arc?: number;
  82319. faceColors?: Color4[];
  82320. faceUV?: Vector4[];
  82321. hasRings?: boolean;
  82322. enclose?: boolean;
  82323. sideOrientation?: number;
  82324. frontUVs?: Vector4;
  82325. backUVs?: Vector4;
  82326. }): VertexData;
  82327. /**
  82328. * Creates the VertexData for a torus
  82329. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82330. * * diameter the diameter of the torus, optional default 1
  82331. * * thickness the diameter of the tube forming the torus, optional default 0.5
  82332. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  82333. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82334. * * 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)
  82335. * * 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)
  82336. * @returns the VertexData of the torus
  82337. */
  82338. static CreateTorus(options: {
  82339. diameter?: number;
  82340. thickness?: number;
  82341. tessellation?: number;
  82342. sideOrientation?: number;
  82343. frontUVs?: Vector4;
  82344. backUVs?: Vector4;
  82345. }): VertexData;
  82346. /**
  82347. * Creates the VertexData of the LineSystem
  82348. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  82349. * - lines an array of lines, each line being an array of successive Vector3
  82350. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  82351. * @returns the VertexData of the LineSystem
  82352. */
  82353. static CreateLineSystem(options: {
  82354. lines: Vector3[][];
  82355. colors?: Nullable<Color4[][]>;
  82356. }): VertexData;
  82357. /**
  82358. * Create the VertexData for a DashedLines
  82359. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  82360. * - points an array successive Vector3
  82361. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  82362. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  82363. * - dashNb the intended total number of dashes, optional, default 200
  82364. * @returns the VertexData for the DashedLines
  82365. */
  82366. static CreateDashedLines(options: {
  82367. points: Vector3[];
  82368. dashSize?: number;
  82369. gapSize?: number;
  82370. dashNb?: number;
  82371. }): VertexData;
  82372. /**
  82373. * Creates the VertexData for a Ground
  82374. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  82375. * - width the width (x direction) of the ground, optional, default 1
  82376. * - height the height (z direction) of the ground, optional, default 1
  82377. * - subdivisions the number of subdivisions per side, optional, default 1
  82378. * @returns the VertexData of the Ground
  82379. */
  82380. static CreateGround(options: {
  82381. width?: number;
  82382. height?: number;
  82383. subdivisions?: number;
  82384. subdivisionsX?: number;
  82385. subdivisionsY?: number;
  82386. }): VertexData;
  82387. /**
  82388. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  82389. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  82390. * * xmin the ground minimum X coordinate, optional, default -1
  82391. * * zmin the ground minimum Z coordinate, optional, default -1
  82392. * * xmax the ground maximum X coordinate, optional, default 1
  82393. * * zmax the ground maximum Z coordinate, optional, default 1
  82394. * * 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}
  82395. * * 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}
  82396. * @returns the VertexData of the TiledGround
  82397. */
  82398. static CreateTiledGround(options: {
  82399. xmin: number;
  82400. zmin: number;
  82401. xmax: number;
  82402. zmax: number;
  82403. subdivisions?: {
  82404. w: number;
  82405. h: number;
  82406. };
  82407. precision?: {
  82408. w: number;
  82409. h: number;
  82410. };
  82411. }): VertexData;
  82412. /**
  82413. * Creates the VertexData of the Ground designed from a heightmap
  82414. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  82415. * * width the width (x direction) of the ground
  82416. * * height the height (z direction) of the ground
  82417. * * subdivisions the number of subdivisions per side
  82418. * * minHeight the minimum altitude on the ground, optional, default 0
  82419. * * maxHeight the maximum altitude on the ground, optional default 1
  82420. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  82421. * * buffer the array holding the image color data
  82422. * * bufferWidth the width of image
  82423. * * bufferHeight the height of image
  82424. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  82425. * @returns the VertexData of the Ground designed from a heightmap
  82426. */
  82427. static CreateGroundFromHeightMap(options: {
  82428. width: number;
  82429. height: number;
  82430. subdivisions: number;
  82431. minHeight: number;
  82432. maxHeight: number;
  82433. colorFilter: Color3;
  82434. buffer: Uint8Array;
  82435. bufferWidth: number;
  82436. bufferHeight: number;
  82437. alphaFilter: number;
  82438. }): VertexData;
  82439. /**
  82440. * Creates the VertexData for a Plane
  82441. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  82442. * * size sets the width and height of the plane to the value of size, optional default 1
  82443. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  82444. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  82445. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82446. * * 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)
  82447. * * 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)
  82448. * @returns the VertexData of the box
  82449. */
  82450. static CreatePlane(options: {
  82451. size?: number;
  82452. width?: number;
  82453. height?: number;
  82454. sideOrientation?: number;
  82455. frontUVs?: Vector4;
  82456. backUVs?: Vector4;
  82457. }): VertexData;
  82458. /**
  82459. * Creates the VertexData of the Disc or regular Polygon
  82460. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  82461. * * radius the radius of the disc, optional default 0.5
  82462. * * tessellation the number of polygon sides, optional, default 64
  82463. * * 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
  82464. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82465. * * 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)
  82466. * * 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)
  82467. * @returns the VertexData of the box
  82468. */
  82469. static CreateDisc(options: {
  82470. radius?: number;
  82471. tessellation?: number;
  82472. arc?: number;
  82473. sideOrientation?: number;
  82474. frontUVs?: Vector4;
  82475. backUVs?: Vector4;
  82476. }): VertexData;
  82477. /**
  82478. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  82479. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  82480. * @param polygon a mesh built from polygonTriangulation.build()
  82481. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82482. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82483. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82484. * @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)
  82485. * @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)
  82486. * @returns the VertexData of the Polygon
  82487. */
  82488. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  82489. /**
  82490. * Creates the VertexData of the IcoSphere
  82491. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  82492. * * radius the radius of the IcoSphere, optional default 1
  82493. * * radiusX allows stretching in the x direction, optional, default radius
  82494. * * radiusY allows stretching in the y direction, optional, default radius
  82495. * * radiusZ allows stretching in the z direction, optional, default radius
  82496. * * flat when true creates a flat shaded mesh, optional, default true
  82497. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  82498. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82499. * * 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)
  82500. * * 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)
  82501. * @returns the VertexData of the IcoSphere
  82502. */
  82503. static CreateIcoSphere(options: {
  82504. radius?: number;
  82505. radiusX?: number;
  82506. radiusY?: number;
  82507. radiusZ?: number;
  82508. flat?: boolean;
  82509. subdivisions?: number;
  82510. sideOrientation?: number;
  82511. frontUVs?: Vector4;
  82512. backUVs?: Vector4;
  82513. }): VertexData;
  82514. /**
  82515. * Creates the VertexData for a Polyhedron
  82516. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  82517. * * type provided types are:
  82518. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  82519. * * 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)
  82520. * * size the size of the IcoSphere, optional default 1
  82521. * * sizeX allows stretching in the x direction, optional, default size
  82522. * * sizeY allows stretching in the y direction, optional, default size
  82523. * * sizeZ allows stretching in the z direction, optional, default size
  82524. * * 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
  82525. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82526. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82527. * * flat when true creates a flat shaded mesh, optional, default true
  82528. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  82529. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82530. * * 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)
  82531. * * 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)
  82532. * @returns the VertexData of the Polyhedron
  82533. */
  82534. static CreatePolyhedron(options: {
  82535. type?: number;
  82536. size?: number;
  82537. sizeX?: number;
  82538. sizeY?: number;
  82539. sizeZ?: number;
  82540. custom?: any;
  82541. faceUV?: Vector4[];
  82542. faceColors?: Color4[];
  82543. flat?: boolean;
  82544. sideOrientation?: number;
  82545. frontUVs?: Vector4;
  82546. backUVs?: Vector4;
  82547. }): VertexData;
  82548. /**
  82549. * Creates the VertexData for a TorusKnot
  82550. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  82551. * * radius the radius of the torus knot, optional, default 2
  82552. * * tube the thickness of the tube, optional, default 0.5
  82553. * * radialSegments the number of sides on each tube segments, optional, default 32
  82554. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  82555. * * p the number of windings around the z axis, optional, default 2
  82556. * * q the number of windings around the x axis, optional, default 3
  82557. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82558. * * 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)
  82559. * * 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)
  82560. * @returns the VertexData of the Torus Knot
  82561. */
  82562. static CreateTorusKnot(options: {
  82563. radius?: number;
  82564. tube?: number;
  82565. radialSegments?: number;
  82566. tubularSegments?: number;
  82567. p?: number;
  82568. q?: number;
  82569. sideOrientation?: number;
  82570. frontUVs?: Vector4;
  82571. backUVs?: Vector4;
  82572. }): VertexData;
  82573. /**
  82574. * Compute normals for given positions and indices
  82575. * @param positions an array of vertex positions, [...., x, y, z, ......]
  82576. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  82577. * @param normals an array of vertex normals, [...., x, y, z, ......]
  82578. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  82579. * * facetNormals : optional array of facet normals (vector3)
  82580. * * facetPositions : optional array of facet positions (vector3)
  82581. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  82582. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  82583. * * bInfo : optional bounding info, required for facetPartitioning computation
  82584. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  82585. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  82586. * * useRightHandedSystem: optional boolean to for right handed system computation
  82587. * * depthSort : optional boolean to enable the facet depth sort computation
  82588. * * distanceTo : optional Vector3 to compute the facet depth from this location
  82589. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  82590. */
  82591. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  82592. facetNormals?: any;
  82593. facetPositions?: any;
  82594. facetPartitioning?: any;
  82595. ratio?: number;
  82596. bInfo?: any;
  82597. bbSize?: Vector3;
  82598. subDiv?: any;
  82599. useRightHandedSystem?: boolean;
  82600. depthSort?: boolean;
  82601. distanceTo?: Vector3;
  82602. depthSortedFacets?: any;
  82603. }): void;
  82604. /** @hidden */
  82605. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  82606. /**
  82607. * Applies VertexData created from the imported parameters to the geometry
  82608. * @param parsedVertexData the parsed data from an imported file
  82609. * @param geometry the geometry to apply the VertexData to
  82610. */
  82611. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  82612. }
  82613. }
  82614. declare module BABYLON {
  82615. /**
  82616. * Class containing static functions to help procedurally build meshes
  82617. */
  82618. export class DiscBuilder {
  82619. /**
  82620. * Creates a plane polygonal mesh. By default, this is a disc
  82621. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  82622. * * 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
  82623. * * 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
  82624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  82625. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  82626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  82627. * @param name defines the name of the mesh
  82628. * @param options defines the options used to create the mesh
  82629. * @param scene defines the hosting scene
  82630. * @returns the plane polygonal mesh
  82631. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  82632. */
  82633. static CreateDisc(name: string, options: {
  82634. radius?: number;
  82635. tessellation?: number;
  82636. arc?: number;
  82637. updatable?: boolean;
  82638. sideOrientation?: number;
  82639. frontUVs?: Vector4;
  82640. backUVs?: Vector4;
  82641. }, scene?: Nullable<Scene>): Mesh;
  82642. }
  82643. }
  82644. declare module BABYLON {
  82645. /**
  82646. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  82647. *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.
  82648. * The SPS is also a particle system. It provides some methods to manage the particles.
  82649. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  82650. *
  82651. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  82652. */
  82653. export class SolidParticleSystem implements IDisposable {
  82654. /**
  82655. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  82656. * Example : var p = SPS.particles[i];
  82657. */
  82658. particles: SolidParticle[];
  82659. /**
  82660. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  82661. */
  82662. nbParticles: number;
  82663. /**
  82664. * If the particles must ever face the camera (default false). Useful for planar particles.
  82665. */
  82666. billboard: boolean;
  82667. /**
  82668. * Recompute normals when adding a shape
  82669. */
  82670. recomputeNormals: boolean;
  82671. /**
  82672. * This a counter ofr your own usage. It's not set by any SPS functions.
  82673. */
  82674. counter: number;
  82675. /**
  82676. * The SPS name. This name is also given to the underlying mesh.
  82677. */
  82678. name: string;
  82679. /**
  82680. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  82681. */
  82682. mesh: Mesh;
  82683. /**
  82684. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  82685. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  82686. */
  82687. vars: any;
  82688. /**
  82689. * This array is populated when the SPS is set as 'pickable'.
  82690. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  82691. * Each element of this array is an object `{idx: int, faceId: int}`.
  82692. * `idx` is the picked particle index in the `SPS.particles` array
  82693. * `faceId` is the picked face index counted within this particle.
  82694. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  82695. */
  82696. pickedParticles: {
  82697. idx: number;
  82698. faceId: number;
  82699. }[];
  82700. /**
  82701. * This array is populated when `enableDepthSort` is set to true.
  82702. * Each element of this array is an instance of the class DepthSortedParticle.
  82703. */
  82704. depthSortedParticles: DepthSortedParticle[];
  82705. /**
  82706. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  82707. * @hidden
  82708. */
  82709. _bSphereOnly: boolean;
  82710. /**
  82711. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  82712. * @hidden
  82713. */
  82714. _bSphereRadiusFactor: number;
  82715. private _scene;
  82716. private _positions;
  82717. private _indices;
  82718. private _normals;
  82719. private _colors;
  82720. private _uvs;
  82721. private _indices32;
  82722. private _positions32;
  82723. private _normals32;
  82724. private _fixedNormal32;
  82725. private _colors32;
  82726. private _uvs32;
  82727. private _index;
  82728. private _updatable;
  82729. private _pickable;
  82730. private _isVisibilityBoxLocked;
  82731. private _alwaysVisible;
  82732. private _depthSort;
  82733. private _shapeCounter;
  82734. private _copy;
  82735. private _color;
  82736. private _computeParticleColor;
  82737. private _computeParticleTexture;
  82738. private _computeParticleRotation;
  82739. private _computeParticleVertex;
  82740. private _computeBoundingBox;
  82741. private _depthSortParticles;
  82742. private _camera;
  82743. private _mustUnrotateFixedNormals;
  82744. private _particlesIntersect;
  82745. private _needs32Bits;
  82746. /**
  82747. * Creates a SPS (Solid Particle System) object.
  82748. * @param name (String) is the SPS name, this will be the underlying mesh name.
  82749. * @param scene (Scene) is the scene in which the SPS is added.
  82750. * @param options defines the options of the sps e.g.
  82751. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  82752. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  82753. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  82754. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  82755. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  82756. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  82757. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  82758. */
  82759. constructor(name: string, scene: Scene, options?: {
  82760. updatable?: boolean;
  82761. isPickable?: boolean;
  82762. enableDepthSort?: boolean;
  82763. particleIntersection?: boolean;
  82764. boundingSphereOnly?: boolean;
  82765. bSphereRadiusFactor?: number;
  82766. });
  82767. /**
  82768. * Builds the SPS underlying mesh. Returns a standard Mesh.
  82769. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  82770. * @returns the created mesh
  82771. */
  82772. buildMesh(): Mesh;
  82773. /**
  82774. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  82775. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  82776. * Thus the particles generated from `digest()` have their property `position` set yet.
  82777. * @param mesh ( Mesh ) is the mesh to be digested
  82778. * @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
  82779. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  82780. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  82781. * @returns the current SPS
  82782. */
  82783. digest(mesh: Mesh, options?: {
  82784. facetNb?: number;
  82785. number?: number;
  82786. delta?: number;
  82787. }): SolidParticleSystem;
  82788. private _unrotateFixedNormals;
  82789. private _resetCopy;
  82790. private _meshBuilder;
  82791. private _posToShape;
  82792. private _uvsToShapeUV;
  82793. private _addParticle;
  82794. /**
  82795. * Adds some particles to the SPS from the model shape. Returns the shape id.
  82796. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  82797. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  82798. * @param nb (positive integer) the number of particles to be created from this model
  82799. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  82800. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  82801. * @returns the number of shapes in the system
  82802. */
  82803. addShape(mesh: Mesh, nb: number, options?: {
  82804. positionFunction?: any;
  82805. vertexFunction?: any;
  82806. }): number;
  82807. private _rebuildParticle;
  82808. /**
  82809. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  82810. * @returns the SPS.
  82811. */
  82812. rebuildMesh(): SolidParticleSystem;
  82813. /**
  82814. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  82815. * This method calls `updateParticle()` for each particle of the SPS.
  82816. * For an animated SPS, it is usually called within the render loop.
  82817. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  82818. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  82819. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  82820. * @returns the SPS.
  82821. */
  82822. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  82823. /**
  82824. * Disposes the SPS.
  82825. */
  82826. dispose(): void;
  82827. /**
  82828. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  82829. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82830. * @returns the SPS.
  82831. */
  82832. refreshVisibleSize(): SolidParticleSystem;
  82833. /**
  82834. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  82835. * @param size the size (float) of the visibility box
  82836. * note : this doesn't lock the SPS mesh bounding box.
  82837. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82838. */
  82839. setVisibilityBox(size: number): void;
  82840. /**
  82841. * Gets whether the SPS as always visible or not
  82842. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82843. */
  82844. /**
  82845. * Sets the SPS as always visible or not
  82846. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82847. */
  82848. isAlwaysVisible: boolean;
  82849. /**
  82850. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  82851. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82852. */
  82853. /**
  82854. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  82855. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82856. */
  82857. isVisibilityBoxLocked: boolean;
  82858. /**
  82859. * Tells to `setParticles()` to compute the particle rotations or not.
  82860. * Default value : true. The SPS is faster when it's set to false.
  82861. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  82862. */
  82863. /**
  82864. * Gets if `setParticles()` computes the particle rotations or not.
  82865. * Default value : true. The SPS is faster when it's set to false.
  82866. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  82867. */
  82868. computeParticleRotation: boolean;
  82869. /**
  82870. * Tells to `setParticles()` to compute the particle colors or not.
  82871. * Default value : true. The SPS is faster when it's set to false.
  82872. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  82873. */
  82874. /**
  82875. * Gets if `setParticles()` computes the particle colors or not.
  82876. * Default value : true. The SPS is faster when it's set to false.
  82877. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  82878. */
  82879. computeParticleColor: boolean;
  82880. /**
  82881. * Gets if `setParticles()` computes the particle textures or not.
  82882. * Default value : true. The SPS is faster when it's set to false.
  82883. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  82884. */
  82885. computeParticleTexture: boolean;
  82886. /**
  82887. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  82888. * Default value : false. The SPS is faster when it's set to false.
  82889. * Note : the particle custom vertex positions aren't stored values.
  82890. */
  82891. /**
  82892. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  82893. * Default value : false. The SPS is faster when it's set to false.
  82894. * Note : the particle custom vertex positions aren't stored values.
  82895. */
  82896. computeParticleVertex: boolean;
  82897. /**
  82898. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  82899. */
  82900. /**
  82901. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  82902. */
  82903. computeBoundingBox: boolean;
  82904. /**
  82905. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  82906. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  82907. * Default : `true`
  82908. */
  82909. /**
  82910. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  82911. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  82912. * Default : `true`
  82913. */
  82914. depthSortParticles: boolean;
  82915. /**
  82916. * This function does nothing. It may be overwritten to set all the particle first values.
  82917. * The SPS doesn't call this function, you may have to call it by your own.
  82918. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82919. */
  82920. initParticles(): void;
  82921. /**
  82922. * This function does nothing. It may be overwritten to recycle a particle.
  82923. * The SPS doesn't call this function, you may have to call it by your own.
  82924. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82925. * @param particle The particle to recycle
  82926. * @returns the recycled particle
  82927. */
  82928. recycleParticle(particle: SolidParticle): SolidParticle;
  82929. /**
  82930. * Updates a particle : this function should be overwritten by the user.
  82931. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  82932. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82933. * @example : just set a particle position or velocity and recycle conditions
  82934. * @param particle The particle to update
  82935. * @returns the updated particle
  82936. */
  82937. updateParticle(particle: SolidParticle): SolidParticle;
  82938. /**
  82939. * Updates a vertex of a particle : it can be overwritten by the user.
  82940. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  82941. * @param particle the current particle
  82942. * @param vertex the current index of the current particle
  82943. * @param pt the index of the current vertex in the particle shape
  82944. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  82945. * @example : just set a vertex particle position
  82946. * @returns the updated vertex
  82947. */
  82948. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  82949. /**
  82950. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  82951. * This does nothing and may be overwritten by the user.
  82952. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82953. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82954. * @param update the boolean update value actually passed to setParticles()
  82955. */
  82956. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  82957. /**
  82958. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  82959. * This will be passed three parameters.
  82960. * This does nothing and may be overwritten by the user.
  82961. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82962. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82963. * @param update the boolean update value actually passed to setParticles()
  82964. */
  82965. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  82966. }
  82967. }
  82968. declare module BABYLON {
  82969. /**
  82970. * Represents one particle of a solid particle system.
  82971. */
  82972. export class SolidParticle {
  82973. /**
  82974. * particle global index
  82975. */
  82976. idx: number;
  82977. /**
  82978. * The color of the particle
  82979. */
  82980. color: Nullable<Color4>;
  82981. /**
  82982. * The world space position of the particle.
  82983. */
  82984. position: Vector3;
  82985. /**
  82986. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  82987. */
  82988. rotation: Vector3;
  82989. /**
  82990. * The world space rotation quaternion of the particle.
  82991. */
  82992. rotationQuaternion: Nullable<Quaternion>;
  82993. /**
  82994. * The scaling of the particle.
  82995. */
  82996. scaling: Vector3;
  82997. /**
  82998. * The uvs of the particle.
  82999. */
  83000. uvs: Vector4;
  83001. /**
  83002. * The current speed of the particle.
  83003. */
  83004. velocity: Vector3;
  83005. /**
  83006. * The pivot point in the particle local space.
  83007. */
  83008. pivot: Vector3;
  83009. /**
  83010. * Must the particle be translated from its pivot point in its local space ?
  83011. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  83012. * Default : false
  83013. */
  83014. translateFromPivot: boolean;
  83015. /**
  83016. * Is the particle active or not ?
  83017. */
  83018. alive: boolean;
  83019. /**
  83020. * Is the particle visible or not ?
  83021. */
  83022. isVisible: boolean;
  83023. /**
  83024. * Index of this particle in the global "positions" array (Internal use)
  83025. * @hidden
  83026. */
  83027. _pos: number;
  83028. /**
  83029. * @hidden Index of this particle in the global "indices" array (Internal use)
  83030. */
  83031. _ind: number;
  83032. /**
  83033. * @hidden ModelShape of this particle (Internal use)
  83034. */
  83035. _model: ModelShape;
  83036. /**
  83037. * ModelShape id of this particle
  83038. */
  83039. shapeId: number;
  83040. /**
  83041. * Index of the particle in its shape id (Internal use)
  83042. */
  83043. idxInShape: number;
  83044. /**
  83045. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  83046. */
  83047. _modelBoundingInfo: BoundingInfo;
  83048. /**
  83049. * @hidden Particle BoundingInfo object (Internal use)
  83050. */
  83051. _boundingInfo: BoundingInfo;
  83052. /**
  83053. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  83054. */
  83055. _sps: SolidParticleSystem;
  83056. /**
  83057. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  83058. */
  83059. _stillInvisible: boolean;
  83060. /**
  83061. * @hidden Last computed particle rotation matrix
  83062. */
  83063. _rotationMatrix: number[];
  83064. /**
  83065. * Parent particle Id, if any.
  83066. * Default null.
  83067. */
  83068. parentId: Nullable<number>;
  83069. /**
  83070. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  83071. * The possible values are :
  83072. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  83073. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83074. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  83075. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  83076. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83077. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  83078. * */
  83079. cullingStrategy: number;
  83080. /**
  83081. * @hidden Internal global position in the SPS.
  83082. */
  83083. _globalPosition: Vector3;
  83084. /**
  83085. * Creates a Solid Particle object.
  83086. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  83087. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  83088. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  83089. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  83090. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  83091. * @param shapeId (integer) is the model shape identifier in the SPS.
  83092. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  83093. * @param sps defines the sps it is associated to
  83094. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  83095. */
  83096. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  83097. /**
  83098. * Legacy support, changed scale to scaling
  83099. */
  83100. /**
  83101. * Legacy support, changed scale to scaling
  83102. */
  83103. scale: Vector3;
  83104. /**
  83105. * Legacy support, changed quaternion to rotationQuaternion
  83106. */
  83107. /**
  83108. * Legacy support, changed quaternion to rotationQuaternion
  83109. */
  83110. quaternion: Nullable<Quaternion>;
  83111. /**
  83112. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  83113. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  83114. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  83115. * @returns true if it intersects
  83116. */
  83117. intersectsMesh(target: Mesh | SolidParticle): boolean;
  83118. /**
  83119. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  83120. * A particle is in the frustum if its bounding box intersects the frustum
  83121. * @param frustumPlanes defines the frustum to test
  83122. * @returns true if the particle is in the frustum planes
  83123. */
  83124. isInFrustum(frustumPlanes: Plane[]): boolean;
  83125. /**
  83126. * get the rotation matrix of the particle
  83127. * @hidden
  83128. */
  83129. getRotationMatrix(m: Matrix): void;
  83130. }
  83131. /**
  83132. * Represents the shape of the model used by one particle of a solid particle system.
  83133. * SPS internal tool, don't use it manually.
  83134. */
  83135. export class ModelShape {
  83136. /**
  83137. * The shape id
  83138. * @hidden
  83139. */
  83140. shapeID: number;
  83141. /**
  83142. * flat array of model positions (internal use)
  83143. * @hidden
  83144. */
  83145. _shape: Vector3[];
  83146. /**
  83147. * flat array of model UVs (internal use)
  83148. * @hidden
  83149. */
  83150. _shapeUV: number[];
  83151. /**
  83152. * length of the shape in the model indices array (internal use)
  83153. * @hidden
  83154. */
  83155. _indicesLength: number;
  83156. /**
  83157. * Custom position function (internal use)
  83158. * @hidden
  83159. */
  83160. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  83161. /**
  83162. * Custom vertex function (internal use)
  83163. * @hidden
  83164. */
  83165. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  83166. /**
  83167. * 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.
  83168. * SPS internal tool, don't use it manually.
  83169. * @hidden
  83170. */
  83171. 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>);
  83172. }
  83173. /**
  83174. * Represents a Depth Sorted Particle in the solid particle system.
  83175. */
  83176. export class DepthSortedParticle {
  83177. /**
  83178. * Index of the particle in the "indices" array
  83179. */
  83180. ind: number;
  83181. /**
  83182. * Length of the particle shape in the "indices" array
  83183. */
  83184. indicesLength: number;
  83185. /**
  83186. * Squared distance from the particle to the camera
  83187. */
  83188. sqDistance: number;
  83189. }
  83190. }
  83191. declare module BABYLON {
  83192. /**
  83193. * Class used to store all common mesh properties
  83194. */
  83195. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  83196. /** No occlusion */
  83197. static OCCLUSION_TYPE_NONE: number;
  83198. /** Occlusion set to optimisitic */
  83199. static OCCLUSION_TYPE_OPTIMISTIC: number;
  83200. /** Occlusion set to strict */
  83201. static OCCLUSION_TYPE_STRICT: number;
  83202. /** Use an accurante occlusion algorithm */
  83203. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  83204. /** Use a conservative occlusion algorithm */
  83205. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  83206. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  83207. * Test order :
  83208. * Is the bounding sphere outside the frustum ?
  83209. * If not, are the bounding box vertices outside the frustum ?
  83210. * It not, then the cullable object is in the frustum.
  83211. */
  83212. static readonly CULLINGSTRATEGY_STANDARD: number;
  83213. /** Culling strategy : Bounding Sphere Only.
  83214. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  83215. * It's also less accurate than the standard because some not visible objects can still be selected.
  83216. * Test : is the bounding sphere outside the frustum ?
  83217. * If not, then the cullable object is in the frustum.
  83218. */
  83219. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  83220. /** Culling strategy : Optimistic Inclusion.
  83221. * This in an inclusion test first, then the standard exclusion test.
  83222. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  83223. * 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.
  83224. * Anyway, it's as accurate as the standard strategy.
  83225. * Test :
  83226. * Is the cullable object bounding sphere center in the frustum ?
  83227. * If not, apply the default culling strategy.
  83228. */
  83229. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  83230. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  83231. * This in an inclusion test first, then the bounding sphere only exclusion test.
  83232. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  83233. * 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.
  83234. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  83235. * Test :
  83236. * Is the cullable object bounding sphere center in the frustum ?
  83237. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  83238. */
  83239. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  83240. /**
  83241. * No billboard
  83242. */
  83243. static readonly BILLBOARDMODE_NONE: number;
  83244. /** Billboard on X axis */
  83245. static readonly BILLBOARDMODE_X: number;
  83246. /** Billboard on Y axis */
  83247. static readonly BILLBOARDMODE_Y: number;
  83248. /** Billboard on Z axis */
  83249. static readonly BILLBOARDMODE_Z: number;
  83250. /** Billboard on all axes */
  83251. static readonly BILLBOARDMODE_ALL: number;
  83252. private _facetData;
  83253. /**
  83254. * The culling strategy to use to check whether the mesh must be rendered or not.
  83255. * This value can be changed at any time and will be used on the next render mesh selection.
  83256. * The possible values are :
  83257. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  83258. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83259. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  83260. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  83261. * Please read each static variable documentation to get details about the culling process.
  83262. * */
  83263. cullingStrategy: number;
  83264. /**
  83265. * Gets the number of facets in the mesh
  83266. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  83267. */
  83268. readonly facetNb: number;
  83269. /**
  83270. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  83271. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  83272. */
  83273. partitioningSubdivisions: number;
  83274. /**
  83275. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  83276. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  83277. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  83278. */
  83279. partitioningBBoxRatio: number;
  83280. /**
  83281. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  83282. * Works only for updatable meshes.
  83283. * Doesn't work with multi-materials
  83284. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  83285. */
  83286. mustDepthSortFacets: boolean;
  83287. /**
  83288. * The location (Vector3) where the facet depth sort must be computed from.
  83289. * By default, the active camera position.
  83290. * Used only when facet depth sort is enabled
  83291. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  83292. */
  83293. facetDepthSortFrom: Vector3;
  83294. /**
  83295. * gets a boolean indicating if facetData is enabled
  83296. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  83297. */
  83298. readonly isFacetDataEnabled: boolean;
  83299. /** @hidden */
  83300. _updateNonUniformScalingState(value: boolean): boolean;
  83301. /**
  83302. * An event triggered when this mesh collides with another one
  83303. */
  83304. onCollideObservable: Observable<AbstractMesh>;
  83305. private _onCollideObserver;
  83306. /** Set a function to call when this mesh collides with another one */
  83307. onCollide: () => void;
  83308. /**
  83309. * An event triggered when the collision's position changes
  83310. */
  83311. onCollisionPositionChangeObservable: Observable<Vector3>;
  83312. private _onCollisionPositionChangeObserver;
  83313. /** Set a function to call when the collision's position changes */
  83314. onCollisionPositionChange: () => void;
  83315. /**
  83316. * An event triggered when material is changed
  83317. */
  83318. onMaterialChangedObservable: Observable<AbstractMesh>;
  83319. /**
  83320. * Gets or sets the orientation for POV movement & rotation
  83321. */
  83322. definedFacingForward: boolean;
  83323. /** @hidden */
  83324. _occlusionQuery: Nullable<WebGLQuery>;
  83325. private _visibility;
  83326. /**
  83327. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  83328. */
  83329. /**
  83330. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  83331. */
  83332. visibility: number;
  83333. /** Gets or sets the alpha index used to sort transparent meshes
  83334. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  83335. */
  83336. alphaIndex: number;
  83337. /**
  83338. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  83339. */
  83340. isVisible: boolean;
  83341. /**
  83342. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83343. */
  83344. isPickable: boolean;
  83345. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  83346. showSubMeshesBoundingBox: boolean;
  83347. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  83348. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  83349. */
  83350. isBlocker: boolean;
  83351. /**
  83352. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  83353. */
  83354. enablePointerMoveEvents: boolean;
  83355. /**
  83356. * Specifies the rendering group id for this mesh (0 by default)
  83357. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83358. */
  83359. renderingGroupId: number;
  83360. private _material;
  83361. /** Gets or sets current material */
  83362. material: Nullable<Material>;
  83363. private _receiveShadows;
  83364. /**
  83365. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  83366. * @see http://doc.babylonjs.com/babylon101/shadows
  83367. */
  83368. receiveShadows: boolean;
  83369. /** Defines color to use when rendering outline */
  83370. outlineColor: Color3;
  83371. /** Define width to use when rendering outline */
  83372. outlineWidth: number;
  83373. /** Defines color to use when rendering overlay */
  83374. overlayColor: Color3;
  83375. /** Defines alpha to use when rendering overlay */
  83376. overlayAlpha: number;
  83377. private _hasVertexAlpha;
  83378. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  83379. hasVertexAlpha: boolean;
  83380. private _useVertexColors;
  83381. /** 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) */
  83382. useVertexColors: boolean;
  83383. private _computeBonesUsingShaders;
  83384. /**
  83385. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  83386. */
  83387. computeBonesUsingShaders: boolean;
  83388. private _numBoneInfluencers;
  83389. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  83390. numBoneInfluencers: number;
  83391. private _applyFog;
  83392. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  83393. applyFog: boolean;
  83394. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  83395. useOctreeForRenderingSelection: boolean;
  83396. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  83397. useOctreeForPicking: boolean;
  83398. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  83399. useOctreeForCollisions: boolean;
  83400. private _layerMask;
  83401. /**
  83402. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  83403. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  83404. */
  83405. layerMask: number;
  83406. /**
  83407. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  83408. */
  83409. alwaysSelectAsActiveMesh: boolean;
  83410. /**
  83411. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  83412. */
  83413. doNotSyncBoundingInfo: boolean;
  83414. /**
  83415. * Gets or sets the current action manager
  83416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83417. */
  83418. actionManager: Nullable<AbstractActionManager>;
  83419. private _checkCollisions;
  83420. private _collisionMask;
  83421. private _collisionGroup;
  83422. /**
  83423. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  83424. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83425. */
  83426. ellipsoid: Vector3;
  83427. /**
  83428. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  83429. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83430. */
  83431. ellipsoidOffset: Vector3;
  83432. private _collider;
  83433. private _oldPositionForCollisions;
  83434. private _diffPositionForCollisions;
  83435. /**
  83436. * Gets or sets a collision mask used to mask collisions (default is -1).
  83437. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  83438. */
  83439. collisionMask: number;
  83440. /**
  83441. * Gets or sets the current collision group mask (-1 by default).
  83442. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  83443. */
  83444. collisionGroup: number;
  83445. /**
  83446. * Defines edge width used when edgesRenderer is enabled
  83447. * @see https://www.babylonjs-playground.com/#10OJSG#13
  83448. */
  83449. edgesWidth: number;
  83450. /**
  83451. * Defines edge color used when edgesRenderer is enabled
  83452. * @see https://www.babylonjs-playground.com/#10OJSG#13
  83453. */
  83454. edgesColor: Color4;
  83455. /** @hidden */
  83456. _edgesRenderer: Nullable<IEdgesRenderer>;
  83457. /** @hidden */
  83458. _masterMesh: Nullable<AbstractMesh>;
  83459. /** @hidden */
  83460. _boundingInfo: Nullable<BoundingInfo>;
  83461. /** @hidden */
  83462. _renderId: number;
  83463. /**
  83464. * Gets or sets the list of subMeshes
  83465. * @see http://doc.babylonjs.com/how_to/multi_materials
  83466. */
  83467. subMeshes: SubMesh[];
  83468. /** @hidden */
  83469. _intersectionsInProgress: AbstractMesh[];
  83470. /** @hidden */
  83471. _unIndexed: boolean;
  83472. /** @hidden */
  83473. _lightSources: Light[];
  83474. /** @hidden */
  83475. readonly _positions: Nullable<Vector3[]>;
  83476. /** @hidden */
  83477. _waitingActions: any;
  83478. /** @hidden */
  83479. _waitingFreezeWorldMatrix: Nullable<boolean>;
  83480. private _skeleton;
  83481. /** @hidden */
  83482. _bonesTransformMatrices: Nullable<Float32Array>;
  83483. /**
  83484. * Gets or sets a skeleton to apply skining transformations
  83485. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  83486. */
  83487. skeleton: Nullable<Skeleton>;
  83488. /**
  83489. * An event triggered when the mesh is rebuilt.
  83490. */
  83491. onRebuildObservable: Observable<AbstractMesh>;
  83492. /**
  83493. * Creates a new AbstractMesh
  83494. * @param name defines the name of the mesh
  83495. * @param scene defines the hosting scene
  83496. */
  83497. constructor(name: string, scene?: Nullable<Scene>);
  83498. /**
  83499. * Returns the string "AbstractMesh"
  83500. * @returns "AbstractMesh"
  83501. */
  83502. getClassName(): string;
  83503. /**
  83504. * Gets a string representation of the current mesh
  83505. * @param fullDetails defines a boolean indicating if full details must be included
  83506. * @returns a string representation of the current mesh
  83507. */
  83508. toString(fullDetails?: boolean): string;
  83509. /**
  83510. * @hidden
  83511. */
  83512. protected _getEffectiveParent(): Nullable<Node>;
  83513. /** @hidden */
  83514. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  83515. /** @hidden */
  83516. _rebuild(): void;
  83517. /** @hidden */
  83518. _resyncLightSources(): void;
  83519. /** @hidden */
  83520. _resyncLighSource(light: Light): void;
  83521. /** @hidden */
  83522. _unBindEffect(): void;
  83523. /** @hidden */
  83524. _removeLightSource(light: Light): void;
  83525. private _markSubMeshesAsDirty;
  83526. /** @hidden */
  83527. _markSubMeshesAsLightDirty(): void;
  83528. /** @hidden */
  83529. _markSubMeshesAsAttributesDirty(): void;
  83530. /** @hidden */
  83531. _markSubMeshesAsMiscDirty(): void;
  83532. /**
  83533. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  83534. */
  83535. scaling: Vector3;
  83536. /**
  83537. * Returns true if the mesh is blocked. Implemented by child classes
  83538. */
  83539. readonly isBlocked: boolean;
  83540. /**
  83541. * Returns the mesh itself by default. Implemented by child classes
  83542. * @param camera defines the camera to use to pick the right LOD level
  83543. * @returns the currentAbstractMesh
  83544. */
  83545. getLOD(camera: Camera): Nullable<AbstractMesh>;
  83546. /**
  83547. * Returns 0 by default. Implemented by child classes
  83548. * @returns an integer
  83549. */
  83550. getTotalVertices(): number;
  83551. /**
  83552. * Returns a positive integer : the total number of indices in this mesh geometry.
  83553. * @returns the numner of indices or zero if the mesh has no geometry.
  83554. */
  83555. getTotalIndices(): number;
  83556. /**
  83557. * Returns null by default. Implemented by child classes
  83558. * @returns null
  83559. */
  83560. getIndices(): Nullable<IndicesArray>;
  83561. /**
  83562. * Returns the array of the requested vertex data kind. Implemented by child classes
  83563. * @param kind defines the vertex data kind to use
  83564. * @returns null
  83565. */
  83566. getVerticesData(kind: string): Nullable<FloatArray>;
  83567. /**
  83568. * Sets the vertex data of the mesh geometry for the requested `kind`.
  83569. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  83570. * Note that a new underlying VertexBuffer object is created each call.
  83571. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  83572. * @param kind defines vertex data kind:
  83573. * * VertexBuffer.PositionKind
  83574. * * VertexBuffer.UVKind
  83575. * * VertexBuffer.UV2Kind
  83576. * * VertexBuffer.UV3Kind
  83577. * * VertexBuffer.UV4Kind
  83578. * * VertexBuffer.UV5Kind
  83579. * * VertexBuffer.UV6Kind
  83580. * * VertexBuffer.ColorKind
  83581. * * VertexBuffer.MatricesIndicesKind
  83582. * * VertexBuffer.MatricesIndicesExtraKind
  83583. * * VertexBuffer.MatricesWeightsKind
  83584. * * VertexBuffer.MatricesWeightsExtraKind
  83585. * @param data defines the data source
  83586. * @param updatable defines if the data must be flagged as updatable (or static)
  83587. * @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
  83588. * @returns the current mesh
  83589. */
  83590. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  83591. /**
  83592. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  83593. * If the mesh has no geometry, it is simply returned as it is.
  83594. * @param kind defines vertex data kind:
  83595. * * VertexBuffer.PositionKind
  83596. * * VertexBuffer.UVKind
  83597. * * VertexBuffer.UV2Kind
  83598. * * VertexBuffer.UV3Kind
  83599. * * VertexBuffer.UV4Kind
  83600. * * VertexBuffer.UV5Kind
  83601. * * VertexBuffer.UV6Kind
  83602. * * VertexBuffer.ColorKind
  83603. * * VertexBuffer.MatricesIndicesKind
  83604. * * VertexBuffer.MatricesIndicesExtraKind
  83605. * * VertexBuffer.MatricesWeightsKind
  83606. * * VertexBuffer.MatricesWeightsExtraKind
  83607. * @param data defines the data source
  83608. * @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
  83609. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  83610. * @returns the current mesh
  83611. */
  83612. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  83613. /**
  83614. * Sets the mesh indices,
  83615. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  83616. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  83617. * @param totalVertices Defines the total number of vertices
  83618. * @returns the current mesh
  83619. */
  83620. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  83621. /**
  83622. * Gets a boolean indicating if specific vertex data is present
  83623. * @param kind defines the vertex data kind to use
  83624. * @returns true is data kind is present
  83625. */
  83626. isVerticesDataPresent(kind: string): boolean;
  83627. /**
  83628. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  83629. * @returns a BoundingInfo
  83630. */
  83631. getBoundingInfo(): BoundingInfo;
  83632. /**
  83633. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  83634. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  83635. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  83636. * @returns the current mesh
  83637. */
  83638. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  83639. /**
  83640. * Overwrite the current bounding info
  83641. * @param boundingInfo defines the new bounding info
  83642. * @returns the current mesh
  83643. */
  83644. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  83645. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  83646. readonly useBones: boolean;
  83647. /** @hidden */
  83648. _preActivate(): void;
  83649. /** @hidden */
  83650. _preActivateForIntermediateRendering(renderId: number): void;
  83651. /** @hidden */
  83652. _activate(renderId: number): void;
  83653. /**
  83654. * Gets the current world matrix
  83655. * @returns a Matrix
  83656. */
  83657. getWorldMatrix(): Matrix;
  83658. /** @hidden */
  83659. _getWorldMatrixDeterminant(): number;
  83660. /**
  83661. * Perform relative position change from the point of view of behind the front of the mesh.
  83662. * This is performed taking into account the meshes current rotation, so you do not have to care.
  83663. * Supports definition of mesh facing forward or backward
  83664. * @param amountRight defines the distance on the right axis
  83665. * @param amountUp defines the distance on the up axis
  83666. * @param amountForward defines the distance on the forward axis
  83667. * @returns the current mesh
  83668. */
  83669. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  83670. /**
  83671. * Calculate relative position change from the point of view of behind the front of the mesh.
  83672. * This is performed taking into account the meshes current rotation, so you do not have to care.
  83673. * Supports definition of mesh facing forward or backward
  83674. * @param amountRight defines the distance on the right axis
  83675. * @param amountUp defines the distance on the up axis
  83676. * @param amountForward defines the distance on the forward axis
  83677. * @returns the new displacement vector
  83678. */
  83679. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  83680. /**
  83681. * Perform relative rotation change from the point of view of behind the front of the mesh.
  83682. * Supports definition of mesh facing forward or backward
  83683. * @param flipBack defines the flip
  83684. * @param twirlClockwise defines the twirl
  83685. * @param tiltRight defines the tilt
  83686. * @returns the current mesh
  83687. */
  83688. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  83689. /**
  83690. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  83691. * Supports definition of mesh facing forward or backward.
  83692. * @param flipBack defines the flip
  83693. * @param twirlClockwise defines the twirl
  83694. * @param tiltRight defines the tilt
  83695. * @returns the new rotation vector
  83696. */
  83697. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  83698. /**
  83699. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  83700. * @param includeDescendants Include bounding info from descendants as well (true by default)
  83701. * @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
  83702. * @returns the new bounding vectors
  83703. */
  83704. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  83705. min: Vector3;
  83706. max: Vector3;
  83707. };
  83708. /**
  83709. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83710. * This means the mesh underlying bounding box and sphere are recomputed.
  83711. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83712. * @returns the current mesh
  83713. */
  83714. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  83715. /** @hidden */
  83716. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  83717. /** @hidden */
  83718. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  83719. /** @hidden */
  83720. _updateBoundingInfo(): AbstractMesh;
  83721. /** @hidden */
  83722. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  83723. /** @hidden */
  83724. protected _afterComputeWorldMatrix(): void;
  83725. /** @hidden */
  83726. readonly _effectiveMesh: AbstractMesh;
  83727. /**
  83728. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  83729. * A mesh is in the frustum if its bounding box intersects the frustum
  83730. * @param frustumPlanes defines the frustum to test
  83731. * @returns true if the mesh is in the frustum planes
  83732. */
  83733. isInFrustum(frustumPlanes: Plane[]): boolean;
  83734. /**
  83735. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  83736. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  83737. * @param frustumPlanes defines the frustum to test
  83738. * @returns true if the mesh is completely in the frustum planes
  83739. */
  83740. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  83741. /**
  83742. * True if the mesh intersects another mesh or a SolidParticle object
  83743. * @param mesh defines a target mesh or SolidParticle to test
  83744. * @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)
  83745. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  83746. * @returns true if there is an intersection
  83747. */
  83748. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  83749. /**
  83750. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  83751. * @param point defines the point to test
  83752. * @returns true if there is an intersection
  83753. */
  83754. intersectsPoint(point: Vector3): boolean;
  83755. /**
  83756. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  83757. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83758. */
  83759. checkCollisions: boolean;
  83760. /**
  83761. * Gets Collider object used to compute collisions (not physics)
  83762. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83763. */
  83764. readonly collider: Collider;
  83765. /**
  83766. * Move the mesh using collision engine
  83767. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83768. * @param displacement defines the requested displacement vector
  83769. * @returns the current mesh
  83770. */
  83771. moveWithCollisions(displacement: Vector3): AbstractMesh;
  83772. private _onCollisionPositionChange;
  83773. /** @hidden */
  83774. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  83775. /** @hidden */
  83776. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  83777. /** @hidden */
  83778. _checkCollision(collider: Collider): AbstractMesh;
  83779. /** @hidden */
  83780. _generatePointsArray(): boolean;
  83781. /**
  83782. * Checks if the passed Ray intersects with the mesh
  83783. * @param ray defines the ray to use
  83784. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  83785. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  83786. * @returns the picking info
  83787. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  83788. */
  83789. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  83790. /**
  83791. * Clones the current mesh
  83792. * @param name defines the mesh name
  83793. * @param newParent defines the new mesh parent
  83794. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  83795. * @returns the new mesh
  83796. */
  83797. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  83798. /**
  83799. * Disposes all the submeshes of the current meshnp
  83800. * @returns the current mesh
  83801. */
  83802. releaseSubMeshes(): AbstractMesh;
  83803. /**
  83804. * Releases resources associated with this abstract mesh.
  83805. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83806. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83807. */
  83808. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83809. /**
  83810. * Adds the passed mesh as a child to the current mesh
  83811. * @param mesh defines the child mesh
  83812. * @returns the current mesh
  83813. */
  83814. addChild(mesh: AbstractMesh): AbstractMesh;
  83815. /**
  83816. * Removes the passed mesh from the current mesh children list
  83817. * @param mesh defines the child mesh
  83818. * @returns the current mesh
  83819. */
  83820. removeChild(mesh: AbstractMesh): AbstractMesh;
  83821. /** @hidden */
  83822. private _initFacetData;
  83823. /**
  83824. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  83825. * This method can be called within the render loop.
  83826. * 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
  83827. * @returns the current mesh
  83828. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83829. */
  83830. updateFacetData(): AbstractMesh;
  83831. /**
  83832. * Returns the facetLocalNormals array.
  83833. * The normals are expressed in the mesh local spac
  83834. * @returns an array of Vector3
  83835. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83836. */
  83837. getFacetLocalNormals(): Vector3[];
  83838. /**
  83839. * Returns the facetLocalPositions array.
  83840. * The facet positions are expressed in the mesh local space
  83841. * @returns an array of Vector3
  83842. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83843. */
  83844. getFacetLocalPositions(): Vector3[];
  83845. /**
  83846. * Returns the facetLocalPartioning array
  83847. * @returns an array of array of numbers
  83848. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83849. */
  83850. getFacetLocalPartitioning(): number[][];
  83851. /**
  83852. * Returns the i-th facet position in the world system.
  83853. * This method allocates a new Vector3 per call
  83854. * @param i defines the facet index
  83855. * @returns a new Vector3
  83856. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83857. */
  83858. getFacetPosition(i: number): Vector3;
  83859. /**
  83860. * Sets the reference Vector3 with the i-th facet position in the world system
  83861. * @param i defines the facet index
  83862. * @param ref defines the target vector
  83863. * @returns the current mesh
  83864. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83865. */
  83866. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  83867. /**
  83868. * Returns the i-th facet normal in the world system.
  83869. * This method allocates a new Vector3 per call
  83870. * @param i defines the facet index
  83871. * @returns a new Vector3
  83872. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83873. */
  83874. getFacetNormal(i: number): Vector3;
  83875. /**
  83876. * Sets the reference Vector3 with the i-th facet normal in the world system
  83877. * @param i defines the facet index
  83878. * @param ref defines the target vector
  83879. * @returns the current mesh
  83880. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83881. */
  83882. getFacetNormalToRef(i: number, ref: Vector3): this;
  83883. /**
  83884. * 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)
  83885. * @param x defines x coordinate
  83886. * @param y defines y coordinate
  83887. * @param z defines z coordinate
  83888. * @returns the array of facet indexes
  83889. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83890. */
  83891. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  83892. /**
  83893. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  83894. * @param projected sets as the (x,y,z) world projection on the facet
  83895. * @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
  83896. * @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
  83897. * @param x defines x coordinate
  83898. * @param y defines y coordinate
  83899. * @param z defines z coordinate
  83900. * @returns the face index if found (or null instead)
  83901. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83902. */
  83903. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  83904. /**
  83905. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  83906. * @param projected sets as the (x,y,z) local projection on the facet
  83907. * @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
  83908. * @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
  83909. * @param x defines x coordinate
  83910. * @param y defines y coordinate
  83911. * @param z defines z coordinate
  83912. * @returns the face index if found (or null instead)
  83913. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83914. */
  83915. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  83916. /**
  83917. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  83918. * @returns the parameters
  83919. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83920. */
  83921. getFacetDataParameters(): any;
  83922. /**
  83923. * Disables the feature FacetData and frees the related memory
  83924. * @returns the current mesh
  83925. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83926. */
  83927. disableFacetData(): AbstractMesh;
  83928. /**
  83929. * Updates the AbstractMesh indices array
  83930. * @param indices defines the data source
  83931. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  83932. * @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)
  83933. * @returns the current mesh
  83934. */
  83935. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  83936. /**
  83937. * Creates new normals data for the mesh
  83938. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  83939. * @returns the current mesh
  83940. */
  83941. createNormals(updatable: boolean): AbstractMesh;
  83942. /**
  83943. * Align the mesh with a normal
  83944. * @param normal defines the normal to use
  83945. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  83946. * @returns the current mesh
  83947. */
  83948. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  83949. /** @hidden */
  83950. _checkOcclusionQuery(): boolean;
  83951. }
  83952. }
  83953. declare module BABYLON {
  83954. /**
  83955. * Interface used to define ActionEvent
  83956. */
  83957. export interface IActionEvent {
  83958. /** The mesh or sprite that triggered the action */
  83959. source: any;
  83960. /** The X mouse cursor position at the time of the event */
  83961. pointerX: number;
  83962. /** The Y mouse cursor position at the time of the event */
  83963. pointerY: number;
  83964. /** The mesh that is currently pointed at (can be null) */
  83965. meshUnderPointer: Nullable<AbstractMesh>;
  83966. /** the original (browser) event that triggered the ActionEvent */
  83967. sourceEvent?: any;
  83968. /** additional data for the event */
  83969. additionalData?: any;
  83970. }
  83971. /**
  83972. * ActionEvent is the event being sent when an action is triggered.
  83973. */
  83974. export class ActionEvent implements IActionEvent {
  83975. /** The mesh or sprite that triggered the action */
  83976. source: any;
  83977. /** The X mouse cursor position at the time of the event */
  83978. pointerX: number;
  83979. /** The Y mouse cursor position at the time of the event */
  83980. pointerY: number;
  83981. /** The mesh that is currently pointed at (can be null) */
  83982. meshUnderPointer: Nullable<AbstractMesh>;
  83983. /** the original (browser) event that triggered the ActionEvent */
  83984. sourceEvent?: any;
  83985. /** additional data for the event */
  83986. additionalData?: any;
  83987. /**
  83988. * Creates a new ActionEvent
  83989. * @param source The mesh or sprite that triggered the action
  83990. * @param pointerX The X mouse cursor position at the time of the event
  83991. * @param pointerY The Y mouse cursor position at the time of the event
  83992. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  83993. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  83994. * @param additionalData additional data for the event
  83995. */
  83996. constructor(
  83997. /** The mesh or sprite that triggered the action */
  83998. source: any,
  83999. /** The X mouse cursor position at the time of the event */
  84000. pointerX: number,
  84001. /** The Y mouse cursor position at the time of the event */
  84002. pointerY: number,
  84003. /** The mesh that is currently pointed at (can be null) */
  84004. meshUnderPointer: Nullable<AbstractMesh>,
  84005. /** the original (browser) event that triggered the ActionEvent */
  84006. sourceEvent?: any,
  84007. /** additional data for the event */
  84008. additionalData?: any);
  84009. /**
  84010. * Helper function to auto-create an ActionEvent from a source mesh.
  84011. * @param source The source mesh that triggered the event
  84012. * @param evt The original (browser) event
  84013. * @param additionalData additional data for the event
  84014. * @returns the new ActionEvent
  84015. */
  84016. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  84017. /**
  84018. * Helper function to auto-create an ActionEvent from a source sprite
  84019. * @param source The source sprite that triggered the event
  84020. * @param scene Scene associated with the sprite
  84021. * @param evt The original (browser) event
  84022. * @param additionalData additional data for the event
  84023. * @returns the new ActionEvent
  84024. */
  84025. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  84026. /**
  84027. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  84028. * @param scene the scene where the event occurred
  84029. * @param evt The original (browser) event
  84030. * @returns the new ActionEvent
  84031. */
  84032. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  84033. /**
  84034. * Helper function to auto-create an ActionEvent from a primitive
  84035. * @param prim defines the target primitive
  84036. * @param pointerPos defines the pointer position
  84037. * @param evt The original (browser) event
  84038. * @param additionalData additional data for the event
  84039. * @returns the new ActionEvent
  84040. */
  84041. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  84042. }
  84043. }
  84044. declare module BABYLON {
  84045. /**
  84046. * Abstract class used to decouple action Manager from scene and meshes.
  84047. * Do not instantiate.
  84048. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84049. */
  84050. export abstract class AbstractActionManager implements IDisposable {
  84051. /** Gets the list of active triggers */
  84052. static Triggers: {
  84053. [key: string]: number;
  84054. };
  84055. /** Gets the cursor to use when hovering items */
  84056. hoverCursor: string;
  84057. /** Gets the list of actions */
  84058. actions: IAction[];
  84059. /**
  84060. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  84061. */
  84062. isRecursive: boolean;
  84063. /**
  84064. * Releases all associated resources
  84065. */
  84066. abstract dispose(): void;
  84067. /**
  84068. * Does this action manager has pointer triggers
  84069. */
  84070. abstract readonly hasPointerTriggers: boolean;
  84071. /**
  84072. * Does this action manager has pick triggers
  84073. */
  84074. abstract readonly hasPickTriggers: boolean;
  84075. /**
  84076. * Process a specific trigger
  84077. * @param trigger defines the trigger to process
  84078. * @param evt defines the event details to be processed
  84079. */
  84080. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  84081. /**
  84082. * Does this action manager handles actions of any of the given triggers
  84083. * @param triggers defines the triggers to be tested
  84084. * @return a boolean indicating whether one (or more) of the triggers is handled
  84085. */
  84086. abstract hasSpecificTriggers(triggers: number[]): boolean;
  84087. /**
  84088. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  84089. * speed.
  84090. * @param triggerA defines the trigger to be tested
  84091. * @param triggerB defines the trigger to be tested
  84092. * @return a boolean indicating whether one (or more) of the triggers is handled
  84093. */
  84094. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  84095. /**
  84096. * Does this action manager handles actions of a given trigger
  84097. * @param trigger defines the trigger to be tested
  84098. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  84099. * @return whether the trigger is handled
  84100. */
  84101. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  84102. /**
  84103. * Serialize this manager to a JSON object
  84104. * @param name defines the property name to store this manager
  84105. * @returns a JSON representation of this manager
  84106. */
  84107. abstract serialize(name: string): any;
  84108. /**
  84109. * Registers an action to this action manager
  84110. * @param action defines the action to be registered
  84111. * @return the action amended (prepared) after registration
  84112. */
  84113. abstract registerAction(action: IAction): Nullable<IAction>;
  84114. /**
  84115. * Unregisters an action to this action manager
  84116. * @param action defines the action to be unregistered
  84117. * @return a boolean indicating whether the action has been unregistered
  84118. */
  84119. abstract unregisterAction(action: IAction): Boolean;
  84120. /**
  84121. * Does exist one action manager with at least one trigger
  84122. **/
  84123. static readonly HasTriggers: boolean;
  84124. /**
  84125. * Does exist one action manager with at least one pick trigger
  84126. **/
  84127. static readonly HasPickTriggers: boolean;
  84128. /**
  84129. * Does exist one action manager that handles actions of a given trigger
  84130. * @param trigger defines the trigger to be tested
  84131. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  84132. **/
  84133. static HasSpecificTrigger(trigger: number): boolean;
  84134. }
  84135. }
  84136. declare module BABYLON {
  84137. /**
  84138. * Defines how a node can be built from a string name.
  84139. */
  84140. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  84141. /**
  84142. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  84143. */
  84144. export class Node implements IBehaviorAware<Node> {
  84145. /** @hidden */
  84146. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  84147. private static _NodeConstructors;
  84148. /**
  84149. * Add a new node constructor
  84150. * @param type defines the type name of the node to construct
  84151. * @param constructorFunc defines the constructor function
  84152. */
  84153. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  84154. /**
  84155. * Returns a node constructor based on type name
  84156. * @param type defines the type name
  84157. * @param name defines the new node name
  84158. * @param scene defines the hosting scene
  84159. * @param options defines optional options to transmit to constructors
  84160. * @returns the new constructor or null
  84161. */
  84162. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  84163. /**
  84164. * Gets or sets the name of the node
  84165. */
  84166. name: string;
  84167. /**
  84168. * Gets or sets the id of the node
  84169. */
  84170. id: string;
  84171. /**
  84172. * Gets or sets the unique id of the node
  84173. */
  84174. uniqueId: number;
  84175. /**
  84176. * Gets or sets a string used to store user defined state for the node
  84177. */
  84178. state: string;
  84179. /**
  84180. * Gets or sets an object used to store user defined information for the node
  84181. */
  84182. metadata: any;
  84183. /**
  84184. * For internal use only. Please do not use.
  84185. */
  84186. reservedDataStore: any;
  84187. /**
  84188. * List of inspectable custom properties (used by the Inspector)
  84189. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84190. */
  84191. inspectableCustomProperties: IInspectable[];
  84192. /**
  84193. * Gets or sets a boolean used to define if the node must be serialized
  84194. */
  84195. doNotSerialize: boolean;
  84196. /** @hidden */
  84197. _isDisposed: boolean;
  84198. /**
  84199. * Gets a list of Animations associated with the node
  84200. */
  84201. animations: Animation[];
  84202. protected _ranges: {
  84203. [name: string]: Nullable<AnimationRange>;
  84204. };
  84205. /**
  84206. * Callback raised when the node is ready to be used
  84207. */
  84208. onReady: (node: Node) => void;
  84209. private _isEnabled;
  84210. private _isParentEnabled;
  84211. private _isReady;
  84212. /** @hidden */
  84213. _currentRenderId: number;
  84214. private _parentUpdateId;
  84215. protected _childUpdateId: number;
  84216. /** @hidden */
  84217. _waitingParentId: Nullable<string>;
  84218. /** @hidden */
  84219. _scene: Scene;
  84220. /** @hidden */
  84221. _cache: any;
  84222. private _parentNode;
  84223. private _children;
  84224. /** @hidden */
  84225. _worldMatrix: Matrix;
  84226. /** @hidden */
  84227. _worldMatrixDeterminant: number;
  84228. /** @hidden */
  84229. _worldMatrixDeterminantIsDirty: boolean;
  84230. /** @hidden */
  84231. private _sceneRootNodesIndex;
  84232. /**
  84233. * Gets a boolean indicating if the node has been disposed
  84234. * @returns true if the node was disposed
  84235. */
  84236. isDisposed(): boolean;
  84237. /**
  84238. * Gets or sets the parent of the node (without keeping the current position in the scene)
  84239. * @see https://doc.babylonjs.com/how_to/parenting
  84240. */
  84241. parent: Nullable<Node>;
  84242. private addToSceneRootNodes;
  84243. private removeFromSceneRootNodes;
  84244. private _animationPropertiesOverride;
  84245. /**
  84246. * Gets or sets the animation properties override
  84247. */
  84248. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  84249. /**
  84250. * Gets a string idenfifying the name of the class
  84251. * @returns "Node" string
  84252. */
  84253. getClassName(): string;
  84254. /** @hidden */
  84255. readonly _isNode: boolean;
  84256. /**
  84257. * An event triggered when the mesh is disposed
  84258. */
  84259. onDisposeObservable: Observable<Node>;
  84260. private _onDisposeObserver;
  84261. /**
  84262. * Sets a callback that will be raised when the node will be disposed
  84263. */
  84264. onDispose: () => void;
  84265. /**
  84266. * Creates a new Node
  84267. * @param name the name and id to be given to this node
  84268. * @param scene the scene this node will be added to
  84269. * @param addToRootNodes the node will be added to scene.rootNodes
  84270. */
  84271. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  84272. /**
  84273. * Gets the scene of the node
  84274. * @returns a scene
  84275. */
  84276. getScene(): Scene;
  84277. /**
  84278. * Gets the engine of the node
  84279. * @returns a Engine
  84280. */
  84281. getEngine(): Engine;
  84282. private _behaviors;
  84283. /**
  84284. * Attach a behavior to the node
  84285. * @see http://doc.babylonjs.com/features/behaviour
  84286. * @param behavior defines the behavior to attach
  84287. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  84288. * @returns the current Node
  84289. */
  84290. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  84291. /**
  84292. * Remove an attached behavior
  84293. * @see http://doc.babylonjs.com/features/behaviour
  84294. * @param behavior defines the behavior to attach
  84295. * @returns the current Node
  84296. */
  84297. removeBehavior(behavior: Behavior<Node>): Node;
  84298. /**
  84299. * Gets the list of attached behaviors
  84300. * @see http://doc.babylonjs.com/features/behaviour
  84301. */
  84302. readonly behaviors: Behavior<Node>[];
  84303. /**
  84304. * Gets an attached behavior by name
  84305. * @param name defines the name of the behavior to look for
  84306. * @see http://doc.babylonjs.com/features/behaviour
  84307. * @returns null if behavior was not found else the requested behavior
  84308. */
  84309. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  84310. /**
  84311. * Returns the latest update of the World matrix
  84312. * @returns a Matrix
  84313. */
  84314. getWorldMatrix(): Matrix;
  84315. /** @hidden */
  84316. _getWorldMatrixDeterminant(): number;
  84317. /**
  84318. * Returns directly the latest state of the mesh World matrix.
  84319. * A Matrix is returned.
  84320. */
  84321. readonly worldMatrixFromCache: Matrix;
  84322. /** @hidden */
  84323. _initCache(): void;
  84324. /** @hidden */
  84325. updateCache(force?: boolean): void;
  84326. /** @hidden */
  84327. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84328. /** @hidden */
  84329. _updateCache(ignoreParentClass?: boolean): void;
  84330. /** @hidden */
  84331. _isSynchronized(): boolean;
  84332. /** @hidden */
  84333. _markSyncedWithParent(): void;
  84334. /** @hidden */
  84335. isSynchronizedWithParent(): boolean;
  84336. /** @hidden */
  84337. isSynchronized(): boolean;
  84338. /**
  84339. * Is this node ready to be used/rendered
  84340. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84341. * @return true if the node is ready
  84342. */
  84343. isReady(completeCheck?: boolean): boolean;
  84344. /**
  84345. * Is this node enabled?
  84346. * 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
  84347. * @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
  84348. * @return whether this node (and its parent) is enabled
  84349. */
  84350. isEnabled(checkAncestors?: boolean): boolean;
  84351. /** @hidden */
  84352. protected _syncParentEnabledState(): void;
  84353. /**
  84354. * Set the enabled state of this node
  84355. * @param value defines the new enabled state
  84356. */
  84357. setEnabled(value: boolean): void;
  84358. /**
  84359. * Is this node a descendant of the given node?
  84360. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  84361. * @param ancestor defines the parent node to inspect
  84362. * @returns a boolean indicating if this node is a descendant of the given node
  84363. */
  84364. isDescendantOf(ancestor: Node): boolean;
  84365. /** @hidden */
  84366. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  84367. /**
  84368. * Will return all nodes that have this node as ascendant
  84369. * @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
  84370. * @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
  84371. * @return all children nodes of all types
  84372. */
  84373. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  84374. /**
  84375. * Get all child-meshes of this node
  84376. * @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)
  84377. * @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
  84378. * @returns an array of AbstractMesh
  84379. */
  84380. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  84381. /**
  84382. * Get all direct children of this node
  84383. * @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
  84384. * @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)
  84385. * @returns an array of Node
  84386. */
  84387. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  84388. /** @hidden */
  84389. _setReady(state: boolean): void;
  84390. /**
  84391. * Get an animation by name
  84392. * @param name defines the name of the animation to look for
  84393. * @returns null if not found else the requested animation
  84394. */
  84395. getAnimationByName(name: string): Nullable<Animation>;
  84396. /**
  84397. * Creates an animation range for this node
  84398. * @param name defines the name of the range
  84399. * @param from defines the starting key
  84400. * @param to defines the end key
  84401. */
  84402. createAnimationRange(name: string, from: number, to: number): void;
  84403. /**
  84404. * Delete a specific animation range
  84405. * @param name defines the name of the range to delete
  84406. * @param deleteFrames defines if animation frames from the range must be deleted as well
  84407. */
  84408. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  84409. /**
  84410. * Get an animation range by name
  84411. * @param name defines the name of the animation range to look for
  84412. * @returns null if not found else the requested animation range
  84413. */
  84414. getAnimationRange(name: string): Nullable<AnimationRange>;
  84415. /**
  84416. * Gets the list of all animation ranges defined on this node
  84417. * @returns an array
  84418. */
  84419. getAnimationRanges(): Nullable<AnimationRange>[];
  84420. /**
  84421. * Will start the animation sequence
  84422. * @param name defines the range frames for animation sequence
  84423. * @param loop defines if the animation should loop (false by default)
  84424. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  84425. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  84426. * @returns the object created for this animation. If range does not exist, it will return null
  84427. */
  84428. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  84429. /**
  84430. * Serialize animation ranges into a JSON compatible object
  84431. * @returns serialization object
  84432. */
  84433. serializeAnimationRanges(): any;
  84434. /**
  84435. * Computes the world matrix of the node
  84436. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  84437. * @returns the world matrix
  84438. */
  84439. computeWorldMatrix(force?: boolean): Matrix;
  84440. /**
  84441. * Releases resources associated with this node.
  84442. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84443. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84444. */
  84445. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84446. /**
  84447. * Parse animation range data from a serialization object and store them into a given node
  84448. * @param node defines where to store the animation ranges
  84449. * @param parsedNode defines the serialization object to read data from
  84450. * @param scene defines the hosting scene
  84451. */
  84452. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  84453. }
  84454. }
  84455. declare module BABYLON {
  84456. /**
  84457. * Class used to store any kind of animation
  84458. */
  84459. export class Animation {
  84460. /**Name of the animation */
  84461. name: string;
  84462. /**Property to animate */
  84463. targetProperty: string;
  84464. /**The frames per second of the animation */
  84465. framePerSecond: number;
  84466. /**The data type of the animation */
  84467. dataType: number;
  84468. /**The loop mode of the animation */
  84469. loopMode?: number | undefined;
  84470. /**Specifies if blending should be enabled */
  84471. enableBlending?: boolean | undefined;
  84472. /**
  84473. * Use matrix interpolation instead of using direct key value when animating matrices
  84474. */
  84475. static AllowMatricesInterpolation: boolean;
  84476. /**
  84477. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  84478. */
  84479. static AllowMatrixDecomposeForInterpolation: boolean;
  84480. /**
  84481. * Stores the key frames of the animation
  84482. */
  84483. private _keys;
  84484. /**
  84485. * Stores the easing function of the animation
  84486. */
  84487. private _easingFunction;
  84488. /**
  84489. * @hidden Internal use only
  84490. */
  84491. _runtimeAnimations: RuntimeAnimation[];
  84492. /**
  84493. * The set of event that will be linked to this animation
  84494. */
  84495. private _events;
  84496. /**
  84497. * Stores an array of target property paths
  84498. */
  84499. targetPropertyPath: string[];
  84500. /**
  84501. * Stores the blending speed of the animation
  84502. */
  84503. blendingSpeed: number;
  84504. /**
  84505. * Stores the animation ranges for the animation
  84506. */
  84507. private _ranges;
  84508. /**
  84509. * @hidden Internal use
  84510. */
  84511. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  84512. /**
  84513. * Sets up an animation
  84514. * @param property The property to animate
  84515. * @param animationType The animation type to apply
  84516. * @param framePerSecond The frames per second of the animation
  84517. * @param easingFunction The easing function used in the animation
  84518. * @returns The created animation
  84519. */
  84520. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  84521. /**
  84522. * Create and start an animation on a node
  84523. * @param name defines the name of the global animation that will be run on all nodes
  84524. * @param node defines the root node where the animation will take place
  84525. * @param targetProperty defines property to animate
  84526. * @param framePerSecond defines the number of frame per second yo use
  84527. * @param totalFrame defines the number of frames in total
  84528. * @param from defines the initial value
  84529. * @param to defines the final value
  84530. * @param loopMode defines which loop mode you want to use (off by default)
  84531. * @param easingFunction defines the easing function to use (linear by default)
  84532. * @param onAnimationEnd defines the callback to call when animation end
  84533. * @returns the animatable created for this animation
  84534. */
  84535. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  84536. /**
  84537. * Create and start an animation on a node and its descendants
  84538. * @param name defines the name of the global animation that will be run on all nodes
  84539. * @param node defines the root node where the animation will take place
  84540. * @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
  84541. * @param targetProperty defines property to animate
  84542. * @param framePerSecond defines the number of frame per second to use
  84543. * @param totalFrame defines the number of frames in total
  84544. * @param from defines the initial value
  84545. * @param to defines the final value
  84546. * @param loopMode defines which loop mode you want to use (off by default)
  84547. * @param easingFunction defines the easing function to use (linear by default)
  84548. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  84549. * @returns the list of animatables created for all nodes
  84550. * @example https://www.babylonjs-playground.com/#MH0VLI
  84551. */
  84552. 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[]>;
  84553. /**
  84554. * Creates a new animation, merges it with the existing animations and starts it
  84555. * @param name Name of the animation
  84556. * @param node Node which contains the scene that begins the animations
  84557. * @param targetProperty Specifies which property to animate
  84558. * @param framePerSecond The frames per second of the animation
  84559. * @param totalFrame The total number of frames
  84560. * @param from The frame at the beginning of the animation
  84561. * @param to The frame at the end of the animation
  84562. * @param loopMode Specifies the loop mode of the animation
  84563. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  84564. * @param onAnimationEnd Callback to run once the animation is complete
  84565. * @returns Nullable animation
  84566. */
  84567. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  84568. /**
  84569. * Transition property of an host to the target Value
  84570. * @param property The property to transition
  84571. * @param targetValue The target Value of the property
  84572. * @param host The object where the property to animate belongs
  84573. * @param scene Scene used to run the animation
  84574. * @param frameRate Framerate (in frame/s) to use
  84575. * @param transition The transition type we want to use
  84576. * @param duration The duration of the animation, in milliseconds
  84577. * @param onAnimationEnd Callback trigger at the end of the animation
  84578. * @returns Nullable animation
  84579. */
  84580. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  84581. /**
  84582. * Return the array of runtime animations currently using this animation
  84583. */
  84584. readonly runtimeAnimations: RuntimeAnimation[];
  84585. /**
  84586. * Specifies if any of the runtime animations are currently running
  84587. */
  84588. readonly hasRunningRuntimeAnimations: boolean;
  84589. /**
  84590. * Initializes the animation
  84591. * @param name Name of the animation
  84592. * @param targetProperty Property to animate
  84593. * @param framePerSecond The frames per second of the animation
  84594. * @param dataType The data type of the animation
  84595. * @param loopMode The loop mode of the animation
  84596. * @param enableBlending Specifies if blending should be enabled
  84597. */
  84598. constructor(
  84599. /**Name of the animation */
  84600. name: string,
  84601. /**Property to animate */
  84602. targetProperty: string,
  84603. /**The frames per second of the animation */
  84604. framePerSecond: number,
  84605. /**The data type of the animation */
  84606. dataType: number,
  84607. /**The loop mode of the animation */
  84608. loopMode?: number | undefined,
  84609. /**Specifies if blending should be enabled */
  84610. enableBlending?: boolean | undefined);
  84611. /**
  84612. * Converts the animation to a string
  84613. * @param fullDetails support for multiple levels of logging within scene loading
  84614. * @returns String form of the animation
  84615. */
  84616. toString(fullDetails?: boolean): string;
  84617. /**
  84618. * Add an event to this animation
  84619. * @param event Event to add
  84620. */
  84621. addEvent(event: AnimationEvent): void;
  84622. /**
  84623. * Remove all events found at the given frame
  84624. * @param frame The frame to remove events from
  84625. */
  84626. removeEvents(frame: number): void;
  84627. /**
  84628. * Retrieves all the events from the animation
  84629. * @returns Events from the animation
  84630. */
  84631. getEvents(): AnimationEvent[];
  84632. /**
  84633. * Creates an animation range
  84634. * @param name Name of the animation range
  84635. * @param from Starting frame of the animation range
  84636. * @param to Ending frame of the animation
  84637. */
  84638. createRange(name: string, from: number, to: number): void;
  84639. /**
  84640. * Deletes an animation range by name
  84641. * @param name Name of the animation range to delete
  84642. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  84643. */
  84644. deleteRange(name: string, deleteFrames?: boolean): void;
  84645. /**
  84646. * Gets the animation range by name, or null if not defined
  84647. * @param name Name of the animation range
  84648. * @returns Nullable animation range
  84649. */
  84650. getRange(name: string): Nullable<AnimationRange>;
  84651. /**
  84652. * Gets the key frames from the animation
  84653. * @returns The key frames of the animation
  84654. */
  84655. getKeys(): Array<IAnimationKey>;
  84656. /**
  84657. * Gets the highest frame rate of the animation
  84658. * @returns Highest frame rate of the animation
  84659. */
  84660. getHighestFrame(): number;
  84661. /**
  84662. * Gets the easing function of the animation
  84663. * @returns Easing function of the animation
  84664. */
  84665. getEasingFunction(): IEasingFunction;
  84666. /**
  84667. * Sets the easing function of the animation
  84668. * @param easingFunction A custom mathematical formula for animation
  84669. */
  84670. setEasingFunction(easingFunction: EasingFunction): void;
  84671. /**
  84672. * Interpolates a scalar linearly
  84673. * @param startValue Start value of the animation curve
  84674. * @param endValue End value of the animation curve
  84675. * @param gradient Scalar amount to interpolate
  84676. * @returns Interpolated scalar value
  84677. */
  84678. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  84679. /**
  84680. * Interpolates a scalar cubically
  84681. * @param startValue Start value of the animation curve
  84682. * @param outTangent End tangent of the animation
  84683. * @param endValue End value of the animation curve
  84684. * @param inTangent Start tangent of the animation curve
  84685. * @param gradient Scalar amount to interpolate
  84686. * @returns Interpolated scalar value
  84687. */
  84688. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  84689. /**
  84690. * Interpolates a quaternion using a spherical linear interpolation
  84691. * @param startValue Start value of the animation curve
  84692. * @param endValue End value of the animation curve
  84693. * @param gradient Scalar amount to interpolate
  84694. * @returns Interpolated quaternion value
  84695. */
  84696. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  84697. /**
  84698. * Interpolates a quaternion cubically
  84699. * @param startValue Start value of the animation curve
  84700. * @param outTangent End tangent of the animation curve
  84701. * @param endValue End value of the animation curve
  84702. * @param inTangent Start tangent of the animation curve
  84703. * @param gradient Scalar amount to interpolate
  84704. * @returns Interpolated quaternion value
  84705. */
  84706. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  84707. /**
  84708. * Interpolates a Vector3 linearl
  84709. * @param startValue Start value of the animation curve
  84710. * @param endValue End value of the animation curve
  84711. * @param gradient Scalar amount to interpolate
  84712. * @returns Interpolated scalar value
  84713. */
  84714. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  84715. /**
  84716. * Interpolates a Vector3 cubically
  84717. * @param startValue Start value of the animation curve
  84718. * @param outTangent End tangent of the animation
  84719. * @param endValue End value of the animation curve
  84720. * @param inTangent Start tangent of the animation curve
  84721. * @param gradient Scalar amount to interpolate
  84722. * @returns InterpolatedVector3 value
  84723. */
  84724. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  84725. /**
  84726. * Interpolates a Vector2 linearly
  84727. * @param startValue Start value of the animation curve
  84728. * @param endValue End value of the animation curve
  84729. * @param gradient Scalar amount to interpolate
  84730. * @returns Interpolated Vector2 value
  84731. */
  84732. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  84733. /**
  84734. * Interpolates a Vector2 cubically
  84735. * @param startValue Start value of the animation curve
  84736. * @param outTangent End tangent of the animation
  84737. * @param endValue End value of the animation curve
  84738. * @param inTangent Start tangent of the animation curve
  84739. * @param gradient Scalar amount to interpolate
  84740. * @returns Interpolated Vector2 value
  84741. */
  84742. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  84743. /**
  84744. * Interpolates a size linearly
  84745. * @param startValue Start value of the animation curve
  84746. * @param endValue End value of the animation curve
  84747. * @param gradient Scalar amount to interpolate
  84748. * @returns Interpolated Size value
  84749. */
  84750. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  84751. /**
  84752. * Interpolates a Color3 linearly
  84753. * @param startValue Start value of the animation curve
  84754. * @param endValue End value of the animation curve
  84755. * @param gradient Scalar amount to interpolate
  84756. * @returns Interpolated Color3 value
  84757. */
  84758. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  84759. /**
  84760. * @hidden Internal use only
  84761. */
  84762. _getKeyValue(value: any): any;
  84763. /**
  84764. * @hidden Internal use only
  84765. */
  84766. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  84767. /**
  84768. * Defines the function to use to interpolate matrices
  84769. * @param startValue defines the start matrix
  84770. * @param endValue defines the end matrix
  84771. * @param gradient defines the gradient between both matrices
  84772. * @param result defines an optional target matrix where to store the interpolation
  84773. * @returns the interpolated matrix
  84774. */
  84775. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  84776. /**
  84777. * Makes a copy of the animation
  84778. * @returns Cloned animation
  84779. */
  84780. clone(): Animation;
  84781. /**
  84782. * Sets the key frames of the animation
  84783. * @param values The animation key frames to set
  84784. */
  84785. setKeys(values: Array<IAnimationKey>): void;
  84786. /**
  84787. * Serializes the animation to an object
  84788. * @returns Serialized object
  84789. */
  84790. serialize(): any;
  84791. /**
  84792. * Float animation type
  84793. */
  84794. private static _ANIMATIONTYPE_FLOAT;
  84795. /**
  84796. * Vector3 animation type
  84797. */
  84798. private static _ANIMATIONTYPE_VECTOR3;
  84799. /**
  84800. * Quaternion animation type
  84801. */
  84802. private static _ANIMATIONTYPE_QUATERNION;
  84803. /**
  84804. * Matrix animation type
  84805. */
  84806. private static _ANIMATIONTYPE_MATRIX;
  84807. /**
  84808. * Color3 animation type
  84809. */
  84810. private static _ANIMATIONTYPE_COLOR3;
  84811. /**
  84812. * Vector2 animation type
  84813. */
  84814. private static _ANIMATIONTYPE_VECTOR2;
  84815. /**
  84816. * Size animation type
  84817. */
  84818. private static _ANIMATIONTYPE_SIZE;
  84819. /**
  84820. * Relative Loop Mode
  84821. */
  84822. private static _ANIMATIONLOOPMODE_RELATIVE;
  84823. /**
  84824. * Cycle Loop Mode
  84825. */
  84826. private static _ANIMATIONLOOPMODE_CYCLE;
  84827. /**
  84828. * Constant Loop Mode
  84829. */
  84830. private static _ANIMATIONLOOPMODE_CONSTANT;
  84831. /**
  84832. * Get the float animation type
  84833. */
  84834. static readonly ANIMATIONTYPE_FLOAT: number;
  84835. /**
  84836. * Get the Vector3 animation type
  84837. */
  84838. static readonly ANIMATIONTYPE_VECTOR3: number;
  84839. /**
  84840. * Get the Vector2 animation type
  84841. */
  84842. static readonly ANIMATIONTYPE_VECTOR2: number;
  84843. /**
  84844. * Get the Size animation type
  84845. */
  84846. static readonly ANIMATIONTYPE_SIZE: number;
  84847. /**
  84848. * Get the Quaternion animation type
  84849. */
  84850. static readonly ANIMATIONTYPE_QUATERNION: number;
  84851. /**
  84852. * Get the Matrix animation type
  84853. */
  84854. static readonly ANIMATIONTYPE_MATRIX: number;
  84855. /**
  84856. * Get the Color3 animation type
  84857. */
  84858. static readonly ANIMATIONTYPE_COLOR3: number;
  84859. /**
  84860. * Get the Relative Loop Mode
  84861. */
  84862. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  84863. /**
  84864. * Get the Cycle Loop Mode
  84865. */
  84866. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  84867. /**
  84868. * Get the Constant Loop Mode
  84869. */
  84870. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  84871. /** @hidden */
  84872. static _UniversalLerp(left: any, right: any, amount: number): any;
  84873. /**
  84874. * Parses an animation object and creates an animation
  84875. * @param parsedAnimation Parsed animation object
  84876. * @returns Animation object
  84877. */
  84878. static Parse(parsedAnimation: any): Animation;
  84879. /**
  84880. * Appends the serialized animations from the source animations
  84881. * @param source Source containing the animations
  84882. * @param destination Target to store the animations
  84883. */
  84884. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  84885. }
  84886. }
  84887. declare module BABYLON {
  84888. /**
  84889. * Base class of all the textures in babylon.
  84890. * It groups all the common properties the materials, post process, lights... might need
  84891. * in order to make a correct use of the texture.
  84892. */
  84893. export class BaseTexture implements IAnimatable {
  84894. /**
  84895. * Default anisotropic filtering level for the application.
  84896. * It is set to 4 as a good tradeoff between perf and quality.
  84897. */
  84898. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  84899. /**
  84900. * Gets or sets the unique id of the texture
  84901. */
  84902. uniqueId: number;
  84903. /**
  84904. * Define the name of the texture.
  84905. */
  84906. name: string;
  84907. /**
  84908. * Gets or sets an object used to store user defined information.
  84909. */
  84910. metadata: any;
  84911. /**
  84912. * For internal use only. Please do not use.
  84913. */
  84914. reservedDataStore: any;
  84915. private _hasAlpha;
  84916. /**
  84917. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  84918. */
  84919. hasAlpha: boolean;
  84920. /**
  84921. * Defines if the alpha value should be determined via the rgb values.
  84922. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  84923. */
  84924. getAlphaFromRGB: boolean;
  84925. /**
  84926. * Intensity or strength of the texture.
  84927. * It is commonly used by materials to fine tune the intensity of the texture
  84928. */
  84929. level: number;
  84930. /**
  84931. * Define the UV chanel to use starting from 0 and defaulting to 0.
  84932. * This is part of the texture as textures usually maps to one uv set.
  84933. */
  84934. coordinatesIndex: number;
  84935. private _coordinatesMode;
  84936. /**
  84937. * How a texture is mapped.
  84938. *
  84939. * | Value | Type | Description |
  84940. * | ----- | ----------------------------------- | ----------- |
  84941. * | 0 | EXPLICIT_MODE | |
  84942. * | 1 | SPHERICAL_MODE | |
  84943. * | 2 | PLANAR_MODE | |
  84944. * | 3 | CUBIC_MODE | |
  84945. * | 4 | PROJECTION_MODE | |
  84946. * | 5 | SKYBOX_MODE | |
  84947. * | 6 | INVCUBIC_MODE | |
  84948. * | 7 | EQUIRECTANGULAR_MODE | |
  84949. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  84950. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  84951. */
  84952. coordinatesMode: number;
  84953. /**
  84954. * | Value | Type | Description |
  84955. * | ----- | ------------------ | ----------- |
  84956. * | 0 | CLAMP_ADDRESSMODE | |
  84957. * | 1 | WRAP_ADDRESSMODE | |
  84958. * | 2 | MIRROR_ADDRESSMODE | |
  84959. */
  84960. wrapU: number;
  84961. /**
  84962. * | Value | Type | Description |
  84963. * | ----- | ------------------ | ----------- |
  84964. * | 0 | CLAMP_ADDRESSMODE | |
  84965. * | 1 | WRAP_ADDRESSMODE | |
  84966. * | 2 | MIRROR_ADDRESSMODE | |
  84967. */
  84968. wrapV: number;
  84969. /**
  84970. * | Value | Type | Description |
  84971. * | ----- | ------------------ | ----------- |
  84972. * | 0 | CLAMP_ADDRESSMODE | |
  84973. * | 1 | WRAP_ADDRESSMODE | |
  84974. * | 2 | MIRROR_ADDRESSMODE | |
  84975. */
  84976. wrapR: number;
  84977. /**
  84978. * With compliant hardware and browser (supporting anisotropic filtering)
  84979. * this defines the level of anisotropic filtering in the texture.
  84980. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  84981. */
  84982. anisotropicFilteringLevel: number;
  84983. /**
  84984. * Define if the texture is a cube texture or if false a 2d texture.
  84985. */
  84986. isCube: boolean;
  84987. /**
  84988. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  84989. */
  84990. is3D: boolean;
  84991. /**
  84992. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  84993. * HDR texture are usually stored in linear space.
  84994. * This only impacts the PBR and Background materials
  84995. */
  84996. gammaSpace: boolean;
  84997. /**
  84998. * Gets whether or not the texture contains RGBD data.
  84999. */
  85000. readonly isRGBD: boolean;
  85001. /**
  85002. * Is Z inverted in the texture (useful in a cube texture).
  85003. */
  85004. invertZ: boolean;
  85005. /**
  85006. * Are mip maps generated for this texture or not.
  85007. */
  85008. readonly noMipmap: boolean;
  85009. /**
  85010. * @hidden
  85011. */
  85012. lodLevelInAlpha: boolean;
  85013. /**
  85014. * With prefiltered texture, defined the offset used during the prefiltering steps.
  85015. */
  85016. lodGenerationOffset: number;
  85017. /**
  85018. * With prefiltered texture, defined the scale used during the prefiltering steps.
  85019. */
  85020. lodGenerationScale: number;
  85021. /**
  85022. * Define if the texture is a render target.
  85023. */
  85024. isRenderTarget: boolean;
  85025. /**
  85026. * Define the unique id of the texture in the scene.
  85027. */
  85028. readonly uid: string;
  85029. /**
  85030. * Return a string representation of the texture.
  85031. * @returns the texture as a string
  85032. */
  85033. toString(): string;
  85034. /**
  85035. * Get the class name of the texture.
  85036. * @returns "BaseTexture"
  85037. */
  85038. getClassName(): string;
  85039. /**
  85040. * Define the list of animation attached to the texture.
  85041. */
  85042. animations: Animation[];
  85043. /**
  85044. * An event triggered when the texture is disposed.
  85045. */
  85046. onDisposeObservable: Observable<BaseTexture>;
  85047. private _onDisposeObserver;
  85048. /**
  85049. * Callback triggered when the texture has been disposed.
  85050. * Kept for back compatibility, you can use the onDisposeObservable instead.
  85051. */
  85052. onDispose: () => void;
  85053. /**
  85054. * Define the current state of the loading sequence when in delayed load mode.
  85055. */
  85056. delayLoadState: number;
  85057. private _scene;
  85058. /** @hidden */
  85059. _texture: Nullable<InternalTexture>;
  85060. private _uid;
  85061. /**
  85062. * Define if the texture is preventinga material to render or not.
  85063. * If not and the texture is not ready, the engine will use a default black texture instead.
  85064. */
  85065. readonly isBlocking: boolean;
  85066. /**
  85067. * Instantiates a new BaseTexture.
  85068. * Base class of all the textures in babylon.
  85069. * It groups all the common properties the materials, post process, lights... might need
  85070. * in order to make a correct use of the texture.
  85071. * @param scene Define the scene the texture blongs to
  85072. */
  85073. constructor(scene: Nullable<Scene>);
  85074. /**
  85075. * Get the scene the texture belongs to.
  85076. * @returns the scene or null if undefined
  85077. */
  85078. getScene(): Nullable<Scene>;
  85079. /**
  85080. * Get the texture transform matrix used to offset tile the texture for istance.
  85081. * @returns the transformation matrix
  85082. */
  85083. getTextureMatrix(): Matrix;
  85084. /**
  85085. * Get the texture reflection matrix used to rotate/transform the reflection.
  85086. * @returns the reflection matrix
  85087. */
  85088. getReflectionTextureMatrix(): Matrix;
  85089. /**
  85090. * Get the underlying lower level texture from Babylon.
  85091. * @returns the insternal texture
  85092. */
  85093. getInternalTexture(): Nullable<InternalTexture>;
  85094. /**
  85095. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  85096. * @returns true if ready or not blocking
  85097. */
  85098. isReadyOrNotBlocking(): boolean;
  85099. /**
  85100. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  85101. * @returns true if fully ready
  85102. */
  85103. isReady(): boolean;
  85104. private _cachedSize;
  85105. /**
  85106. * Get the size of the texture.
  85107. * @returns the texture size.
  85108. */
  85109. getSize(): ISize;
  85110. /**
  85111. * Get the base size of the texture.
  85112. * It can be different from the size if the texture has been resized for POT for instance
  85113. * @returns the base size
  85114. */
  85115. getBaseSize(): ISize;
  85116. /**
  85117. * Update the sampling mode of the texture.
  85118. * Default is Trilinear mode.
  85119. *
  85120. * | Value | Type | Description |
  85121. * | ----- | ------------------ | ----------- |
  85122. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  85123. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  85124. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  85125. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  85126. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  85127. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  85128. * | 7 | NEAREST_LINEAR | |
  85129. * | 8 | NEAREST_NEAREST | |
  85130. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  85131. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  85132. * | 11 | LINEAR_LINEAR | |
  85133. * | 12 | LINEAR_NEAREST | |
  85134. *
  85135. * > _mag_: magnification filter (close to the viewer)
  85136. * > _min_: minification filter (far from the viewer)
  85137. * > _mip_: filter used between mip map levels
  85138. *@param samplingMode Define the new sampling mode of the texture
  85139. */
  85140. updateSamplingMode(samplingMode: number): void;
  85141. /**
  85142. * Scales the texture if is `canRescale()`
  85143. * @param ratio the resize factor we want to use to rescale
  85144. */
  85145. scale(ratio: number): void;
  85146. /**
  85147. * Get if the texture can rescale.
  85148. */
  85149. readonly canRescale: boolean;
  85150. /** @hidden */
  85151. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  85152. /** @hidden */
  85153. _rebuild(): void;
  85154. /**
  85155. * Triggers the load sequence in delayed load mode.
  85156. */
  85157. delayLoad(): void;
  85158. /**
  85159. * Clones the texture.
  85160. * @returns the cloned texture
  85161. */
  85162. clone(): Nullable<BaseTexture>;
  85163. /**
  85164. * Get the texture underlying type (INT, FLOAT...)
  85165. */
  85166. readonly textureType: number;
  85167. /**
  85168. * Get the texture underlying format (RGB, RGBA...)
  85169. */
  85170. readonly textureFormat: number;
  85171. /**
  85172. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  85173. * This will returns an RGBA array buffer containing either in values (0-255) or
  85174. * float values (0-1) depending of the underlying buffer type.
  85175. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  85176. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  85177. * @param buffer defines a user defined buffer to fill with data (can be null)
  85178. * @returns The Array buffer containing the pixels data.
  85179. */
  85180. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  85181. /**
  85182. * Release and destroy the underlying lower level texture aka internalTexture.
  85183. */
  85184. releaseInternalTexture(): void;
  85185. /**
  85186. * Get the polynomial representation of the texture data.
  85187. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  85188. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  85189. */
  85190. sphericalPolynomial: Nullable<SphericalPolynomial>;
  85191. /** @hidden */
  85192. readonly _lodTextureHigh: Nullable<BaseTexture>;
  85193. /** @hidden */
  85194. readonly _lodTextureMid: Nullable<BaseTexture>;
  85195. /** @hidden */
  85196. readonly _lodTextureLow: Nullable<BaseTexture>;
  85197. /**
  85198. * Dispose the texture and release its associated resources.
  85199. */
  85200. dispose(): void;
  85201. /**
  85202. * Serialize the texture into a JSON representation that can be parsed later on.
  85203. * @returns the JSON representation of the texture
  85204. */
  85205. serialize(): any;
  85206. /**
  85207. * Helper function to be called back once a list of texture contains only ready textures.
  85208. * @param textures Define the list of textures to wait for
  85209. * @param callback Define the callback triggered once the entire list will be ready
  85210. */
  85211. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  85212. }
  85213. }
  85214. declare module BABYLON {
  85215. /**
  85216. * Uniform buffer objects.
  85217. *
  85218. * Handles blocks of uniform on the GPU.
  85219. *
  85220. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85221. *
  85222. * For more information, please refer to :
  85223. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85224. */
  85225. export class UniformBuffer {
  85226. private _engine;
  85227. private _buffer;
  85228. private _data;
  85229. private _bufferData;
  85230. private _dynamic?;
  85231. private _uniformLocations;
  85232. private _uniformSizes;
  85233. private _uniformLocationPointer;
  85234. private _needSync;
  85235. private _noUBO;
  85236. private _currentEffect;
  85237. private static _MAX_UNIFORM_SIZE;
  85238. private static _tempBuffer;
  85239. /**
  85240. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  85241. * This is dynamic to allow compat with webgl 1 and 2.
  85242. * You will need to pass the name of the uniform as well as the value.
  85243. */
  85244. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  85245. /**
  85246. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  85247. * This is dynamic to allow compat with webgl 1 and 2.
  85248. * You will need to pass the name of the uniform as well as the value.
  85249. */
  85250. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  85251. /**
  85252. * Lambda to Update a single float in a uniform buffer.
  85253. * This is dynamic to allow compat with webgl 1 and 2.
  85254. * You will need to pass the name of the uniform as well as the value.
  85255. */
  85256. updateFloat: (name: string, x: number) => void;
  85257. /**
  85258. * Lambda to Update a vec2 of float in a uniform buffer.
  85259. * This is dynamic to allow compat with webgl 1 and 2.
  85260. * You will need to pass the name of the uniform as well as the value.
  85261. */
  85262. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  85263. /**
  85264. * Lambda to Update a vec3 of float in a uniform buffer.
  85265. * This is dynamic to allow compat with webgl 1 and 2.
  85266. * You will need to pass the name of the uniform as well as the value.
  85267. */
  85268. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  85269. /**
  85270. * Lambda to Update a vec4 of float in a uniform buffer.
  85271. * This is dynamic to allow compat with webgl 1 and 2.
  85272. * You will need to pass the name of the uniform as well as the value.
  85273. */
  85274. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  85275. /**
  85276. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  85277. * This is dynamic to allow compat with webgl 1 and 2.
  85278. * You will need to pass the name of the uniform as well as the value.
  85279. */
  85280. updateMatrix: (name: string, mat: Matrix) => void;
  85281. /**
  85282. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  85283. * This is dynamic to allow compat with webgl 1 and 2.
  85284. * You will need to pass the name of the uniform as well as the value.
  85285. */
  85286. updateVector3: (name: string, vector: Vector3) => void;
  85287. /**
  85288. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  85289. * This is dynamic to allow compat with webgl 1 and 2.
  85290. * You will need to pass the name of the uniform as well as the value.
  85291. */
  85292. updateVector4: (name: string, vector: Vector4) => void;
  85293. /**
  85294. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  85295. * This is dynamic to allow compat with webgl 1 and 2.
  85296. * You will need to pass the name of the uniform as well as the value.
  85297. */
  85298. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  85299. /**
  85300. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  85301. * This is dynamic to allow compat with webgl 1 and 2.
  85302. * You will need to pass the name of the uniform as well as the value.
  85303. */
  85304. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  85305. /**
  85306. * Instantiates a new Uniform buffer objects.
  85307. *
  85308. * Handles blocks of uniform on the GPU.
  85309. *
  85310. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85311. *
  85312. * For more information, please refer to :
  85313. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85314. * @param engine Define the engine the buffer is associated with
  85315. * @param data Define the data contained in the buffer
  85316. * @param dynamic Define if the buffer is updatable
  85317. */
  85318. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  85319. /**
  85320. * Indicates if the buffer is using the WebGL2 UBO implementation,
  85321. * or just falling back on setUniformXXX calls.
  85322. */
  85323. readonly useUbo: boolean;
  85324. /**
  85325. * Indicates if the WebGL underlying uniform buffer is in sync
  85326. * with the javascript cache data.
  85327. */
  85328. readonly isSync: boolean;
  85329. /**
  85330. * Indicates if the WebGL underlying uniform buffer is dynamic.
  85331. * Also, a dynamic UniformBuffer will disable cache verification and always
  85332. * update the underlying WebGL uniform buffer to the GPU.
  85333. * @returns if Dynamic, otherwise false
  85334. */
  85335. isDynamic(): boolean;
  85336. /**
  85337. * The data cache on JS side.
  85338. * @returns the underlying data as a float array
  85339. */
  85340. getData(): Float32Array;
  85341. /**
  85342. * The underlying WebGL Uniform buffer.
  85343. * @returns the webgl buffer
  85344. */
  85345. getBuffer(): Nullable<WebGLBuffer>;
  85346. /**
  85347. * std140 layout specifies how to align data within an UBO structure.
  85348. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  85349. * for specs.
  85350. */
  85351. private _fillAlignment;
  85352. /**
  85353. * Adds an uniform in the buffer.
  85354. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  85355. * for the layout to be correct !
  85356. * @param name Name of the uniform, as used in the uniform block in the shader.
  85357. * @param size Data size, or data directly.
  85358. */
  85359. addUniform(name: string, size: number | number[]): void;
  85360. /**
  85361. * Adds a Matrix 4x4 to the uniform buffer.
  85362. * @param name Name of the uniform, as used in the uniform block in the shader.
  85363. * @param mat A 4x4 matrix.
  85364. */
  85365. addMatrix(name: string, mat: Matrix): void;
  85366. /**
  85367. * Adds a vec2 to the uniform buffer.
  85368. * @param name Name of the uniform, as used in the uniform block in the shader.
  85369. * @param x Define the x component value of the vec2
  85370. * @param y Define the y component value of the vec2
  85371. */
  85372. addFloat2(name: string, x: number, y: number): void;
  85373. /**
  85374. * Adds a vec3 to the uniform buffer.
  85375. * @param name Name of the uniform, as used in the uniform block in the shader.
  85376. * @param x Define the x component value of the vec3
  85377. * @param y Define the y component value of the vec3
  85378. * @param z Define the z component value of the vec3
  85379. */
  85380. addFloat3(name: string, x: number, y: number, z: number): void;
  85381. /**
  85382. * Adds a vec3 to the uniform buffer.
  85383. * @param name Name of the uniform, as used in the uniform block in the shader.
  85384. * @param color Define the vec3 from a Color
  85385. */
  85386. addColor3(name: string, color: Color3): void;
  85387. /**
  85388. * Adds a vec4 to the uniform buffer.
  85389. * @param name Name of the uniform, as used in the uniform block in the shader.
  85390. * @param color Define the rgb components from a Color
  85391. * @param alpha Define the a component of the vec4
  85392. */
  85393. addColor4(name: string, color: Color3, alpha: number): void;
  85394. /**
  85395. * Adds a vec3 to the uniform buffer.
  85396. * @param name Name of the uniform, as used in the uniform block in the shader.
  85397. * @param vector Define the vec3 components from a Vector
  85398. */
  85399. addVector3(name: string, vector: Vector3): void;
  85400. /**
  85401. * Adds a Matrix 3x3 to the uniform buffer.
  85402. * @param name Name of the uniform, as used in the uniform block in the shader.
  85403. */
  85404. addMatrix3x3(name: string): void;
  85405. /**
  85406. * Adds a Matrix 2x2 to the uniform buffer.
  85407. * @param name Name of the uniform, as used in the uniform block in the shader.
  85408. */
  85409. addMatrix2x2(name: string): void;
  85410. /**
  85411. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  85412. */
  85413. create(): void;
  85414. /** @hidden */
  85415. _rebuild(): void;
  85416. /**
  85417. * Updates the WebGL Uniform Buffer on the GPU.
  85418. * If the `dynamic` flag is set to true, no cache comparison is done.
  85419. * Otherwise, the buffer will be updated only if the cache differs.
  85420. */
  85421. update(): void;
  85422. /**
  85423. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  85424. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85425. * @param data Define the flattened data
  85426. * @param size Define the size of the data.
  85427. */
  85428. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  85429. private _updateMatrix3x3ForUniform;
  85430. private _updateMatrix3x3ForEffect;
  85431. private _updateMatrix2x2ForEffect;
  85432. private _updateMatrix2x2ForUniform;
  85433. private _updateFloatForEffect;
  85434. private _updateFloatForUniform;
  85435. private _updateFloat2ForEffect;
  85436. private _updateFloat2ForUniform;
  85437. private _updateFloat3ForEffect;
  85438. private _updateFloat3ForUniform;
  85439. private _updateFloat4ForEffect;
  85440. private _updateFloat4ForUniform;
  85441. private _updateMatrixForEffect;
  85442. private _updateMatrixForUniform;
  85443. private _updateVector3ForEffect;
  85444. private _updateVector3ForUniform;
  85445. private _updateVector4ForEffect;
  85446. private _updateVector4ForUniform;
  85447. private _updateColor3ForEffect;
  85448. private _updateColor3ForUniform;
  85449. private _updateColor4ForEffect;
  85450. private _updateColor4ForUniform;
  85451. /**
  85452. * Sets a sampler uniform on the effect.
  85453. * @param name Define the name of the sampler.
  85454. * @param texture Define the texture to set in the sampler
  85455. */
  85456. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  85457. /**
  85458. * Directly updates the value of the uniform in the cache AND on the GPU.
  85459. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85460. * @param data Define the flattened data
  85461. */
  85462. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  85463. /**
  85464. * Binds this uniform buffer to an effect.
  85465. * @param effect Define the effect to bind the buffer to
  85466. * @param name Name of the uniform block in the shader.
  85467. */
  85468. bindToEffect(effect: Effect, name: string): void;
  85469. /**
  85470. * Disposes the uniform buffer.
  85471. */
  85472. dispose(): void;
  85473. }
  85474. }
  85475. declare module BABYLON {
  85476. /**
  85477. * This represents the required contract to create a new type of texture loader.
  85478. */
  85479. export interface IInternalTextureLoader {
  85480. /**
  85481. * Defines wether the loader supports cascade loading the different faces.
  85482. */
  85483. supportCascades: boolean;
  85484. /**
  85485. * This returns if the loader support the current file information.
  85486. * @param extension defines the file extension of the file being loaded
  85487. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85488. * @param fallback defines the fallback internal texture if any
  85489. * @param isBase64 defines whether the texture is encoded as a base64
  85490. * @param isBuffer defines whether the texture data are stored as a buffer
  85491. * @returns true if the loader can load the specified file
  85492. */
  85493. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  85494. /**
  85495. * Transform the url before loading if required.
  85496. * @param rootUrl the url of the texture
  85497. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85498. * @returns the transformed texture
  85499. */
  85500. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  85501. /**
  85502. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  85503. * @param rootUrl the url of the texture
  85504. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85505. * @returns the fallback texture
  85506. */
  85507. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  85508. /**
  85509. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  85510. * @param data contains the texture data
  85511. * @param texture defines the BabylonJS internal texture
  85512. * @param createPolynomials will be true if polynomials have been requested
  85513. * @param onLoad defines the callback to trigger once the texture is ready
  85514. * @param onError defines the callback to trigger in case of error
  85515. */
  85516. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  85517. /**
  85518. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  85519. * @param data contains the texture data
  85520. * @param texture defines the BabylonJS internal texture
  85521. * @param callback defines the method to call once ready to upload
  85522. */
  85523. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  85524. }
  85525. }
  85526. declare module BABYLON {
  85527. /**
  85528. * Creation options of the multi render target texture.
  85529. */
  85530. export interface IMultiRenderTargetOptions {
  85531. /**
  85532. * Define if the texture needs to create mip maps after render.
  85533. */
  85534. generateMipMaps?: boolean;
  85535. /**
  85536. * Define the types of all the draw buffers we want to create
  85537. */
  85538. types?: number[];
  85539. /**
  85540. * Define the sampling modes of all the draw buffers we want to create
  85541. */
  85542. samplingModes?: number[];
  85543. /**
  85544. * Define if a depth buffer is required
  85545. */
  85546. generateDepthBuffer?: boolean;
  85547. /**
  85548. * Define if a stencil buffer is required
  85549. */
  85550. generateStencilBuffer?: boolean;
  85551. /**
  85552. * Define if a depth texture is required instead of a depth buffer
  85553. */
  85554. generateDepthTexture?: boolean;
  85555. /**
  85556. * Define the number of desired draw buffers
  85557. */
  85558. textureCount?: number;
  85559. /**
  85560. * Define if aspect ratio should be adapted to the texture or stay the scene one
  85561. */
  85562. doNotChangeAspectRatio?: boolean;
  85563. /**
  85564. * Define the default type of the buffers we are creating
  85565. */
  85566. defaultType?: number;
  85567. }
  85568. /**
  85569. * A multi render target, like a render target provides the ability to render to a texture.
  85570. * Unlike the render target, it can render to several draw buffers in one draw.
  85571. * This is specially interesting in deferred rendering or for any effects requiring more than
  85572. * just one color from a single pass.
  85573. */
  85574. export class MultiRenderTarget extends RenderTargetTexture {
  85575. private _internalTextures;
  85576. private _textures;
  85577. private _multiRenderTargetOptions;
  85578. /**
  85579. * Get if draw buffers are currently supported by the used hardware and browser.
  85580. */
  85581. readonly isSupported: boolean;
  85582. /**
  85583. * Get the list of textures generated by the multi render target.
  85584. */
  85585. readonly textures: Texture[];
  85586. /**
  85587. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  85588. */
  85589. readonly depthTexture: Texture;
  85590. /**
  85591. * Set the wrapping mode on U of all the textures we are rendering to.
  85592. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  85593. */
  85594. wrapU: number;
  85595. /**
  85596. * Set the wrapping mode on V of all the textures we are rendering to.
  85597. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  85598. */
  85599. wrapV: number;
  85600. /**
  85601. * Instantiate a new multi render target texture.
  85602. * A multi render target, like a render target provides the ability to render to a texture.
  85603. * Unlike the render target, it can render to several draw buffers in one draw.
  85604. * This is specially interesting in deferred rendering or for any effects requiring more than
  85605. * just one color from a single pass.
  85606. * @param name Define the name of the texture
  85607. * @param size Define the size of the buffers to render to
  85608. * @param count Define the number of target we are rendering into
  85609. * @param scene Define the scene the texture belongs to
  85610. * @param options Define the options used to create the multi render target
  85611. */
  85612. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  85613. /** @hidden */
  85614. _rebuild(): void;
  85615. private _createInternalTextures;
  85616. private _createTextures;
  85617. /**
  85618. * Define the number of samples used if MSAA is enabled.
  85619. */
  85620. samples: number;
  85621. /**
  85622. * Resize all the textures in the multi render target.
  85623. * Be carrefull as it will recreate all the data in the new texture.
  85624. * @param size Define the new size
  85625. */
  85626. resize(size: any): void;
  85627. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  85628. /**
  85629. * Dispose the render targets and their associated resources
  85630. */
  85631. dispose(): void;
  85632. /**
  85633. * Release all the underlying texture used as draw buffers.
  85634. */
  85635. releaseInternalTextures(): void;
  85636. }
  85637. }
  85638. declare module BABYLON {
  85639. /**
  85640. * Class used to work with sound analyzer using fast fourier transform (FFT)
  85641. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85642. */
  85643. export class Analyser {
  85644. /**
  85645. * Gets or sets the smoothing
  85646. * @ignorenaming
  85647. */
  85648. SMOOTHING: number;
  85649. /**
  85650. * Gets or sets the FFT table size
  85651. * @ignorenaming
  85652. */
  85653. FFT_SIZE: number;
  85654. /**
  85655. * Gets or sets the bar graph amplitude
  85656. * @ignorenaming
  85657. */
  85658. BARGRAPHAMPLITUDE: number;
  85659. /**
  85660. * Gets or sets the position of the debug canvas
  85661. * @ignorenaming
  85662. */
  85663. DEBUGCANVASPOS: {
  85664. x: number;
  85665. y: number;
  85666. };
  85667. /**
  85668. * Gets or sets the debug canvas size
  85669. * @ignorenaming
  85670. */
  85671. DEBUGCANVASSIZE: {
  85672. width: number;
  85673. height: number;
  85674. };
  85675. private _byteFreqs;
  85676. private _byteTime;
  85677. private _floatFreqs;
  85678. private _webAudioAnalyser;
  85679. private _debugCanvas;
  85680. private _debugCanvasContext;
  85681. private _scene;
  85682. private _registerFunc;
  85683. private _audioEngine;
  85684. /**
  85685. * Creates a new analyser
  85686. * @param scene defines hosting scene
  85687. */
  85688. constructor(scene: Scene);
  85689. /**
  85690. * Get the number of data values you will have to play with for the visualization
  85691. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  85692. * @returns a number
  85693. */
  85694. getFrequencyBinCount(): number;
  85695. /**
  85696. * Gets the current frequency data as a byte array
  85697. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  85698. * @returns a Uint8Array
  85699. */
  85700. getByteFrequencyData(): Uint8Array;
  85701. /**
  85702. * Gets the current waveform as a byte array
  85703. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  85704. * @returns a Uint8Array
  85705. */
  85706. getByteTimeDomainData(): Uint8Array;
  85707. /**
  85708. * Gets the current frequency data as a float array
  85709. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  85710. * @returns a Float32Array
  85711. */
  85712. getFloatFrequencyData(): Float32Array;
  85713. /**
  85714. * Renders the debug canvas
  85715. */
  85716. drawDebugCanvas(): void;
  85717. /**
  85718. * Stops rendering the debug canvas and removes it
  85719. */
  85720. stopDebugCanvas(): void;
  85721. /**
  85722. * Connects two audio nodes
  85723. * @param inputAudioNode defines first node to connect
  85724. * @param outputAudioNode defines second node to connect
  85725. */
  85726. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  85727. /**
  85728. * Releases all associated resources
  85729. */
  85730. dispose(): void;
  85731. }
  85732. }
  85733. declare module BABYLON {
  85734. /**
  85735. * This represents an audio engine and it is responsible
  85736. * to play, synchronize and analyse sounds throughout the application.
  85737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85738. */
  85739. export interface IAudioEngine extends IDisposable {
  85740. /**
  85741. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  85742. */
  85743. readonly canUseWebAudio: boolean;
  85744. /**
  85745. * Gets the current AudioContext if available.
  85746. */
  85747. readonly audioContext: Nullable<AudioContext>;
  85748. /**
  85749. * The master gain node defines the global audio volume of your audio engine.
  85750. */
  85751. readonly masterGain: GainNode;
  85752. /**
  85753. * Gets whether or not mp3 are supported by your browser.
  85754. */
  85755. readonly isMP3supported: boolean;
  85756. /**
  85757. * Gets whether or not ogg are supported by your browser.
  85758. */
  85759. readonly isOGGsupported: boolean;
  85760. /**
  85761. * Defines if Babylon should emit a warning if WebAudio is not supported.
  85762. * @ignoreNaming
  85763. */
  85764. WarnedWebAudioUnsupported: boolean;
  85765. /**
  85766. * Defines if the audio engine relies on a custom unlocked button.
  85767. * In this case, the embedded button will not be displayed.
  85768. */
  85769. useCustomUnlockedButton: boolean;
  85770. /**
  85771. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  85772. */
  85773. readonly unlocked: boolean;
  85774. /**
  85775. * Event raised when audio has been unlocked on the browser.
  85776. */
  85777. onAudioUnlockedObservable: Observable<AudioEngine>;
  85778. /**
  85779. * Event raised when audio has been locked on the browser.
  85780. */
  85781. onAudioLockedObservable: Observable<AudioEngine>;
  85782. /**
  85783. * Flags the audio engine in Locked state.
  85784. * This happens due to new browser policies preventing audio to autoplay.
  85785. */
  85786. lock(): void;
  85787. /**
  85788. * Unlocks the audio engine once a user action has been done on the dom.
  85789. * This is helpful to resume play once browser policies have been satisfied.
  85790. */
  85791. unlock(): void;
  85792. }
  85793. /**
  85794. * This represents the default audio engine used in babylon.
  85795. * It is responsible to play, synchronize and analyse sounds throughout the application.
  85796. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85797. */
  85798. export class AudioEngine implements IAudioEngine {
  85799. private _audioContext;
  85800. private _audioContextInitialized;
  85801. private _muteButton;
  85802. private _hostElement;
  85803. /**
  85804. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  85805. */
  85806. canUseWebAudio: boolean;
  85807. /**
  85808. * The master gain node defines the global audio volume of your audio engine.
  85809. */
  85810. masterGain: GainNode;
  85811. /**
  85812. * Defines if Babylon should emit a warning if WebAudio is not supported.
  85813. * @ignoreNaming
  85814. */
  85815. WarnedWebAudioUnsupported: boolean;
  85816. /**
  85817. * Gets whether or not mp3 are supported by your browser.
  85818. */
  85819. isMP3supported: boolean;
  85820. /**
  85821. * Gets whether or not ogg are supported by your browser.
  85822. */
  85823. isOGGsupported: boolean;
  85824. /**
  85825. * Gets whether audio has been unlocked on the device.
  85826. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  85827. * a user interaction has happened.
  85828. */
  85829. unlocked: boolean;
  85830. /**
  85831. * Defines if the audio engine relies on a custom unlocked button.
  85832. * In this case, the embedded button will not be displayed.
  85833. */
  85834. useCustomUnlockedButton: boolean;
  85835. /**
  85836. * Event raised when audio has been unlocked on the browser.
  85837. */
  85838. onAudioUnlockedObservable: Observable<AudioEngine>;
  85839. /**
  85840. * Event raised when audio has been locked on the browser.
  85841. */
  85842. onAudioLockedObservable: Observable<AudioEngine>;
  85843. /**
  85844. * Gets the current AudioContext if available.
  85845. */
  85846. readonly audioContext: Nullable<AudioContext>;
  85847. private _connectedAnalyser;
  85848. /**
  85849. * Instantiates a new audio engine.
  85850. *
  85851. * There should be only one per page as some browsers restrict the number
  85852. * of audio contexts you can create.
  85853. * @param hostElement defines the host element where to display the mute icon if necessary
  85854. */
  85855. constructor(hostElement?: Nullable<HTMLElement>);
  85856. /**
  85857. * Flags the audio engine in Locked state.
  85858. * This happens due to new browser policies preventing audio to autoplay.
  85859. */
  85860. lock(): void;
  85861. /**
  85862. * Unlocks the audio engine once a user action has been done on the dom.
  85863. * This is helpful to resume play once browser policies have been satisfied.
  85864. */
  85865. unlock(): void;
  85866. private _resumeAudioContext;
  85867. private _initializeAudioContext;
  85868. private _tryToRun;
  85869. private _triggerRunningState;
  85870. private _triggerSuspendedState;
  85871. private _displayMuteButton;
  85872. private _moveButtonToTopLeft;
  85873. private _onResize;
  85874. private _hideMuteButton;
  85875. /**
  85876. * Destroy and release the resources associated with the audio ccontext.
  85877. */
  85878. dispose(): void;
  85879. /**
  85880. * Gets the global volume sets on the master gain.
  85881. * @returns the global volume if set or -1 otherwise
  85882. */
  85883. getGlobalVolume(): number;
  85884. /**
  85885. * Sets the global volume of your experience (sets on the master gain).
  85886. * @param newVolume Defines the new global volume of the application
  85887. */
  85888. setGlobalVolume(newVolume: number): void;
  85889. /**
  85890. * Connect the audio engine to an audio analyser allowing some amazing
  85891. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  85892. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  85893. * @param analyser The analyser to connect to the engine
  85894. */
  85895. connectToAnalyser(analyser: Analyser): void;
  85896. }
  85897. }
  85898. declare module BABYLON {
  85899. /**
  85900. * Interface used to present a loading screen while loading a scene
  85901. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85902. */
  85903. export interface ILoadingScreen {
  85904. /**
  85905. * Function called to display the loading screen
  85906. */
  85907. displayLoadingUI: () => void;
  85908. /**
  85909. * Function called to hide the loading screen
  85910. */
  85911. hideLoadingUI: () => void;
  85912. /**
  85913. * Gets or sets the color to use for the background
  85914. */
  85915. loadingUIBackgroundColor: string;
  85916. /**
  85917. * Gets or sets the text to display while loading
  85918. */
  85919. loadingUIText: string;
  85920. }
  85921. /**
  85922. * Class used for the default loading screen
  85923. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85924. */
  85925. export class DefaultLoadingScreen implements ILoadingScreen {
  85926. private _renderingCanvas;
  85927. private _loadingText;
  85928. private _loadingDivBackgroundColor;
  85929. private _loadingDiv;
  85930. private _loadingTextDiv;
  85931. /**
  85932. * Creates a new default loading screen
  85933. * @param _renderingCanvas defines the canvas used to render the scene
  85934. * @param _loadingText defines the default text to display
  85935. * @param _loadingDivBackgroundColor defines the default background color
  85936. */
  85937. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  85938. /**
  85939. * Function called to display the loading screen
  85940. */
  85941. displayLoadingUI(): void;
  85942. /**
  85943. * Function called to hide the loading screen
  85944. */
  85945. hideLoadingUI(): void;
  85946. /**
  85947. * Gets or sets the text to display while loading
  85948. */
  85949. loadingUIText: string;
  85950. /**
  85951. * Gets or sets the color to use for the background
  85952. */
  85953. loadingUIBackgroundColor: string;
  85954. private _resizeLoadingUI;
  85955. }
  85956. }
  85957. declare module BABYLON {
  85958. /**
  85959. * Settings for finer control over video usage
  85960. */
  85961. export interface VideoTextureSettings {
  85962. /**
  85963. * Applies `autoplay` to video, if specified
  85964. */
  85965. autoPlay?: boolean;
  85966. /**
  85967. * Applies `loop` to video, if specified
  85968. */
  85969. loop?: boolean;
  85970. /**
  85971. * Automatically updates internal texture from video at every frame in the render loop
  85972. */
  85973. autoUpdateTexture: boolean;
  85974. /**
  85975. * Image src displayed during the video loading or until the user interacts with the video.
  85976. */
  85977. poster?: string;
  85978. }
  85979. /**
  85980. * If you want to display a video in your scene, this is the special texture for that.
  85981. * This special texture works similar to other textures, with the exception of a few parameters.
  85982. * @see https://doc.babylonjs.com/how_to/video_texture
  85983. */
  85984. export class VideoTexture extends Texture {
  85985. /**
  85986. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  85987. */
  85988. readonly autoUpdateTexture: boolean;
  85989. /**
  85990. * The video instance used by the texture internally
  85991. */
  85992. readonly video: HTMLVideoElement;
  85993. private _onUserActionRequestedObservable;
  85994. /**
  85995. * Event triggerd when a dom action is required by the user to play the video.
  85996. * This happens due to recent changes in browser policies preventing video to auto start.
  85997. */
  85998. readonly onUserActionRequestedObservable: Observable<Texture>;
  85999. private _generateMipMaps;
  86000. private _engine;
  86001. private _stillImageCaptured;
  86002. private _displayingPosterTexture;
  86003. private _settings;
  86004. private _createInternalTextureOnEvent;
  86005. /**
  86006. * Creates a video texture.
  86007. * If you want to display a video in your scene, this is the special texture for that.
  86008. * This special texture works similar to other textures, with the exception of a few parameters.
  86009. * @see https://doc.babylonjs.com/how_to/video_texture
  86010. * @param name optional name, will detect from video source, if not defined
  86011. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  86012. * @param scene is obviously the current scene.
  86013. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  86014. * @param invertY is false by default but can be used to invert video on Y axis
  86015. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  86016. * @param settings allows finer control over video usage
  86017. */
  86018. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  86019. private _getName;
  86020. private _getVideo;
  86021. private _createInternalTexture;
  86022. private reset;
  86023. /**
  86024. * @hidden Internal method to initiate `update`.
  86025. */
  86026. _rebuild(): void;
  86027. /**
  86028. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  86029. */
  86030. update(): void;
  86031. /**
  86032. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  86033. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  86034. */
  86035. updateTexture(isVisible: boolean): void;
  86036. protected _updateInternalTexture: () => void;
  86037. /**
  86038. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  86039. * @param url New url.
  86040. */
  86041. updateURL(url: string): void;
  86042. /**
  86043. * Dispose the texture and release its associated resources.
  86044. */
  86045. dispose(): void;
  86046. /**
  86047. * Creates a video texture straight from a stream.
  86048. * @param scene Define the scene the texture should be created in
  86049. * @param stream Define the stream the texture should be created from
  86050. * @returns The created video texture as a promise
  86051. */
  86052. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  86053. /**
  86054. * Creates a video texture straight from your WebCam video feed.
  86055. * @param scene Define the scene the texture should be created in
  86056. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86057. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86058. * @returns The created video texture as a promise
  86059. */
  86060. static CreateFromWebCamAsync(scene: Scene, constraints: {
  86061. minWidth: number;
  86062. maxWidth: number;
  86063. minHeight: number;
  86064. maxHeight: number;
  86065. deviceId: string;
  86066. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  86067. /**
  86068. * Creates a video texture straight from your WebCam video feed.
  86069. * @param scene Define the scene the texture should be created in
  86070. * @param onReady Define a callback to triggered once the texture will be ready
  86071. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86072. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86073. */
  86074. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  86075. minWidth: number;
  86076. maxWidth: number;
  86077. minHeight: number;
  86078. maxHeight: number;
  86079. deviceId: string;
  86080. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  86081. }
  86082. }
  86083. declare module BABYLON {
  86084. /**
  86085. * Interface for attribute information associated with buffer instanciation
  86086. */
  86087. export class InstancingAttributeInfo {
  86088. /**
  86089. * Index/offset of the attribute in the vertex shader
  86090. */
  86091. index: number;
  86092. /**
  86093. * size of the attribute, 1, 2, 3 or 4
  86094. */
  86095. attributeSize: number;
  86096. /**
  86097. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  86098. * default is FLOAT
  86099. */
  86100. attribyteType: number;
  86101. /**
  86102. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  86103. */
  86104. normalized: boolean;
  86105. /**
  86106. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  86107. */
  86108. offset: number;
  86109. /**
  86110. * Name of the GLSL attribute, for debugging purpose only
  86111. */
  86112. attributeName: string;
  86113. }
  86114. /**
  86115. * Define options used to create a depth texture
  86116. */
  86117. export class DepthTextureCreationOptions {
  86118. /** Specifies whether or not a stencil should be allocated in the texture */
  86119. generateStencil?: boolean;
  86120. /** Specifies whether or not bilinear filtering is enable on the texture */
  86121. bilinearFiltering?: boolean;
  86122. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86123. comparisonFunction?: number;
  86124. /** Specifies if the created texture is a cube texture */
  86125. isCube?: boolean;
  86126. }
  86127. /**
  86128. * Class used to describe the capabilities of the engine relatively to the current browser
  86129. */
  86130. export class EngineCapabilities {
  86131. /** Maximum textures units per fragment shader */
  86132. maxTexturesImageUnits: number;
  86133. /** Maximum texture units per vertex shader */
  86134. maxVertexTextureImageUnits: number;
  86135. /** Maximum textures units in the entire pipeline */
  86136. maxCombinedTexturesImageUnits: number;
  86137. /** Maximum texture size */
  86138. maxTextureSize: number;
  86139. /** Maximum cube texture size */
  86140. maxCubemapTextureSize: number;
  86141. /** Maximum render texture size */
  86142. maxRenderTextureSize: number;
  86143. /** Maximum number of vertex attributes */
  86144. maxVertexAttribs: number;
  86145. /** Maximum number of varyings */
  86146. maxVaryingVectors: number;
  86147. /** Maximum number of uniforms per vertex shader */
  86148. maxVertexUniformVectors: number;
  86149. /** Maximum number of uniforms per fragment shader */
  86150. maxFragmentUniformVectors: number;
  86151. /** Defines if standard derivates (dx/dy) are supported */
  86152. standardDerivatives: boolean;
  86153. /** Defines if s3tc texture compression is supported */
  86154. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  86155. /** Defines if pvrtc texture compression is supported */
  86156. pvrtc: any;
  86157. /** Defines if etc1 texture compression is supported */
  86158. etc1: any;
  86159. /** Defines if etc2 texture compression is supported */
  86160. etc2: any;
  86161. /** Defines if astc texture compression is supported */
  86162. astc: any;
  86163. /** Defines if float textures are supported */
  86164. textureFloat: boolean;
  86165. /** Defines if vertex array objects are supported */
  86166. vertexArrayObject: boolean;
  86167. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  86168. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  86169. /** Gets the maximum level of anisotropy supported */
  86170. maxAnisotropy: number;
  86171. /** Defines if instancing is supported */
  86172. instancedArrays: boolean;
  86173. /** Defines if 32 bits indices are supported */
  86174. uintIndices: boolean;
  86175. /** Defines if high precision shaders are supported */
  86176. highPrecisionShaderSupported: boolean;
  86177. /** Defines if depth reading in the fragment shader is supported */
  86178. fragmentDepthSupported: boolean;
  86179. /** Defines if float texture linear filtering is supported*/
  86180. textureFloatLinearFiltering: boolean;
  86181. /** Defines if rendering to float textures is supported */
  86182. textureFloatRender: boolean;
  86183. /** Defines if half float textures are supported*/
  86184. textureHalfFloat: boolean;
  86185. /** Defines if half float texture linear filtering is supported*/
  86186. textureHalfFloatLinearFiltering: boolean;
  86187. /** Defines if rendering to half float textures is supported */
  86188. textureHalfFloatRender: boolean;
  86189. /** Defines if textureLOD shader command is supported */
  86190. textureLOD: boolean;
  86191. /** Defines if draw buffers extension is supported */
  86192. drawBuffersExtension: boolean;
  86193. /** Defines if depth textures are supported */
  86194. depthTextureExtension: boolean;
  86195. /** Defines if float color buffer are supported */
  86196. colorBufferFloat: boolean;
  86197. /** Gets disjoint timer query extension (null if not supported) */
  86198. timerQuery: EXT_disjoint_timer_query;
  86199. /** Defines if timestamp can be used with timer query */
  86200. canUseTimestampForTimerQuery: boolean;
  86201. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  86202. multiview: any;
  86203. /** Function used to let the system compiles shaders in background */
  86204. parallelShaderCompile: {
  86205. COMPLETION_STATUS_KHR: number;
  86206. };
  86207. }
  86208. /** Interface defining initialization parameters for Engine class */
  86209. export interface EngineOptions extends WebGLContextAttributes {
  86210. /**
  86211. * Defines if the engine should no exceed a specified device ratio
  86212. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  86213. */
  86214. limitDeviceRatio?: number;
  86215. /**
  86216. * Defines if webvr should be enabled automatically
  86217. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86218. */
  86219. autoEnableWebVR?: boolean;
  86220. /**
  86221. * Defines if webgl2 should be turned off even if supported
  86222. * @see http://doc.babylonjs.com/features/webgl2
  86223. */
  86224. disableWebGL2Support?: boolean;
  86225. /**
  86226. * Defines if webaudio should be initialized as well
  86227. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86228. */
  86229. audioEngine?: boolean;
  86230. /**
  86231. * Defines if animations should run using a deterministic lock step
  86232. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86233. */
  86234. deterministicLockstep?: boolean;
  86235. /** Defines the maximum steps to use with deterministic lock step mode */
  86236. lockstepMaxSteps?: number;
  86237. /**
  86238. * Defines that engine should ignore context lost events
  86239. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  86240. */
  86241. doNotHandleContextLost?: boolean;
  86242. /**
  86243. * Defines that engine should ignore modifying touch action attribute and style
  86244. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  86245. */
  86246. doNotHandleTouchAction?: boolean;
  86247. /**
  86248. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  86249. */
  86250. useHighPrecisionFloats?: boolean;
  86251. }
  86252. /**
  86253. * Defines the interface used by display changed events
  86254. */
  86255. export interface IDisplayChangedEventArgs {
  86256. /** Gets the vrDisplay object (if any) */
  86257. vrDisplay: Nullable<any>;
  86258. /** Gets a boolean indicating if webVR is supported */
  86259. vrSupported: boolean;
  86260. }
  86261. /**
  86262. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  86263. */
  86264. export class Engine {
  86265. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  86266. static ExceptionList: ({
  86267. key: string;
  86268. capture: string;
  86269. captureConstraint: number;
  86270. targets: string[];
  86271. } | {
  86272. key: string;
  86273. capture: null;
  86274. captureConstraint: null;
  86275. targets: string[];
  86276. })[];
  86277. /** Gets the list of created engines */
  86278. static readonly Instances: Engine[];
  86279. /**
  86280. * Gets the latest created engine
  86281. */
  86282. static readonly LastCreatedEngine: Nullable<Engine>;
  86283. /**
  86284. * Gets the latest created scene
  86285. */
  86286. static readonly LastCreatedScene: Nullable<Scene>;
  86287. /**
  86288. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  86289. * @param flag defines which part of the materials must be marked as dirty
  86290. * @param predicate defines a predicate used to filter which materials should be affected
  86291. */
  86292. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  86293. /**
  86294. * Hidden
  86295. */
  86296. static _TextureLoaders: IInternalTextureLoader[];
  86297. /** Defines that alpha blending is disabled */
  86298. static readonly ALPHA_DISABLE: number;
  86299. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  86300. static readonly ALPHA_ADD: number;
  86301. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  86302. static readonly ALPHA_COMBINE: number;
  86303. /** Defines that alpha blending to DEST - SRC * DEST */
  86304. static readonly ALPHA_SUBTRACT: number;
  86305. /** Defines that alpha blending to SRC * DEST */
  86306. static readonly ALPHA_MULTIPLY: number;
  86307. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  86308. static readonly ALPHA_MAXIMIZED: number;
  86309. /** Defines that alpha blending to SRC + DEST */
  86310. static readonly ALPHA_ONEONE: number;
  86311. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  86312. static readonly ALPHA_PREMULTIPLIED: number;
  86313. /**
  86314. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  86315. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  86316. */
  86317. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  86318. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  86319. static readonly ALPHA_INTERPOLATE: number;
  86320. /**
  86321. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  86322. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  86323. */
  86324. static readonly ALPHA_SCREENMODE: number;
  86325. /** Defines that the ressource is not delayed*/
  86326. static readonly DELAYLOADSTATE_NONE: number;
  86327. /** Defines that the ressource was successfully delay loaded */
  86328. static readonly DELAYLOADSTATE_LOADED: number;
  86329. /** Defines that the ressource is currently delay loading */
  86330. static readonly DELAYLOADSTATE_LOADING: number;
  86331. /** Defines that the ressource is delayed and has not started loading */
  86332. static readonly DELAYLOADSTATE_NOTLOADED: number;
  86333. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  86334. static readonly NEVER: number;
  86335. /** 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 */
  86336. static readonly ALWAYS: number;
  86337. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  86338. static readonly LESS: number;
  86339. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  86340. static readonly EQUAL: number;
  86341. /** 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 */
  86342. static readonly LEQUAL: number;
  86343. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  86344. static readonly GREATER: number;
  86345. /** 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 */
  86346. static readonly GEQUAL: number;
  86347. /** 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 */
  86348. static readonly NOTEQUAL: number;
  86349. /** Passed to stencilOperation to specify that stencil value must be kept */
  86350. static readonly KEEP: number;
  86351. /** Passed to stencilOperation to specify that stencil value must be replaced */
  86352. static readonly REPLACE: number;
  86353. /** Passed to stencilOperation to specify that stencil value must be incremented */
  86354. static readonly INCR: number;
  86355. /** Passed to stencilOperation to specify that stencil value must be decremented */
  86356. static readonly DECR: number;
  86357. /** Passed to stencilOperation to specify that stencil value must be inverted */
  86358. static readonly INVERT: number;
  86359. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  86360. static readonly INCR_WRAP: number;
  86361. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  86362. static readonly DECR_WRAP: number;
  86363. /** Texture is not repeating outside of 0..1 UVs */
  86364. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  86365. /** Texture is repeating outside of 0..1 UVs */
  86366. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  86367. /** Texture is repeating and mirrored */
  86368. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  86369. /** ALPHA */
  86370. static readonly TEXTUREFORMAT_ALPHA: number;
  86371. /** LUMINANCE */
  86372. static readonly TEXTUREFORMAT_LUMINANCE: number;
  86373. /** LUMINANCE_ALPHA */
  86374. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  86375. /** RGB */
  86376. static readonly TEXTUREFORMAT_RGB: number;
  86377. /** RGBA */
  86378. static readonly TEXTUREFORMAT_RGBA: number;
  86379. /** RED */
  86380. static readonly TEXTUREFORMAT_RED: number;
  86381. /** RED (2nd reference) */
  86382. static readonly TEXTUREFORMAT_R: number;
  86383. /** RG */
  86384. static readonly TEXTUREFORMAT_RG: number;
  86385. /** RED_INTEGER */
  86386. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  86387. /** RED_INTEGER (2nd reference) */
  86388. static readonly TEXTUREFORMAT_R_INTEGER: number;
  86389. /** RG_INTEGER */
  86390. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  86391. /** RGB_INTEGER */
  86392. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  86393. /** RGBA_INTEGER */
  86394. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  86395. /** UNSIGNED_BYTE */
  86396. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  86397. /** UNSIGNED_BYTE (2nd reference) */
  86398. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  86399. /** FLOAT */
  86400. static readonly TEXTURETYPE_FLOAT: number;
  86401. /** HALF_FLOAT */
  86402. static readonly TEXTURETYPE_HALF_FLOAT: number;
  86403. /** BYTE */
  86404. static readonly TEXTURETYPE_BYTE: number;
  86405. /** SHORT */
  86406. static readonly TEXTURETYPE_SHORT: number;
  86407. /** UNSIGNED_SHORT */
  86408. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  86409. /** INT */
  86410. static readonly TEXTURETYPE_INT: number;
  86411. /** UNSIGNED_INT */
  86412. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  86413. /** UNSIGNED_SHORT_4_4_4_4 */
  86414. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  86415. /** UNSIGNED_SHORT_5_5_5_1 */
  86416. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  86417. /** UNSIGNED_SHORT_5_6_5 */
  86418. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  86419. /** UNSIGNED_INT_2_10_10_10_REV */
  86420. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  86421. /** UNSIGNED_INT_24_8 */
  86422. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  86423. /** UNSIGNED_INT_10F_11F_11F_REV */
  86424. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  86425. /** UNSIGNED_INT_5_9_9_9_REV */
  86426. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  86427. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  86428. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  86429. /** nearest is mag = nearest and min = nearest and mip = linear */
  86430. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  86431. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86432. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  86433. /** Trilinear is mag = linear and min = linear and mip = linear */
  86434. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  86435. /** nearest is mag = nearest and min = nearest and mip = linear */
  86436. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  86437. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86438. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  86439. /** Trilinear is mag = linear and min = linear and mip = linear */
  86440. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  86441. /** mag = nearest and min = nearest and mip = nearest */
  86442. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  86443. /** mag = nearest and min = linear and mip = nearest */
  86444. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  86445. /** mag = nearest and min = linear and mip = linear */
  86446. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  86447. /** mag = nearest and min = linear and mip = none */
  86448. static readonly TEXTURE_NEAREST_LINEAR: number;
  86449. /** mag = nearest and min = nearest and mip = none */
  86450. static readonly TEXTURE_NEAREST_NEAREST: number;
  86451. /** mag = linear and min = nearest and mip = nearest */
  86452. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  86453. /** mag = linear and min = nearest and mip = linear */
  86454. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  86455. /** mag = linear and min = linear and mip = none */
  86456. static readonly TEXTURE_LINEAR_LINEAR: number;
  86457. /** mag = linear and min = nearest and mip = none */
  86458. static readonly TEXTURE_LINEAR_NEAREST: number;
  86459. /** Explicit coordinates mode */
  86460. static readonly TEXTURE_EXPLICIT_MODE: number;
  86461. /** Spherical coordinates mode */
  86462. static readonly TEXTURE_SPHERICAL_MODE: number;
  86463. /** Planar coordinates mode */
  86464. static readonly TEXTURE_PLANAR_MODE: number;
  86465. /** Cubic coordinates mode */
  86466. static readonly TEXTURE_CUBIC_MODE: number;
  86467. /** Projection coordinates mode */
  86468. static readonly TEXTURE_PROJECTION_MODE: number;
  86469. /** Skybox coordinates mode */
  86470. static readonly TEXTURE_SKYBOX_MODE: number;
  86471. /** Inverse Cubic coordinates mode */
  86472. static readonly TEXTURE_INVCUBIC_MODE: number;
  86473. /** Equirectangular coordinates mode */
  86474. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  86475. /** Equirectangular Fixed coordinates mode */
  86476. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  86477. /** Equirectangular Fixed Mirrored coordinates mode */
  86478. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  86479. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  86480. static readonly SCALEMODE_FLOOR: number;
  86481. /** Defines that texture rescaling will look for the nearest power of 2 size */
  86482. static readonly SCALEMODE_NEAREST: number;
  86483. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  86484. static readonly SCALEMODE_CEILING: number;
  86485. /**
  86486. * Returns the current npm package of the sdk
  86487. */
  86488. static readonly NpmPackage: string;
  86489. /**
  86490. * Returns the current version of the framework
  86491. */
  86492. static readonly Version: string;
  86493. /**
  86494. * Returns a string describing the current engine
  86495. */
  86496. readonly description: string;
  86497. /**
  86498. * Gets or sets the epsilon value used by collision engine
  86499. */
  86500. static CollisionsEpsilon: number;
  86501. /**
  86502. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  86503. */
  86504. static ShadersRepository: string;
  86505. /**
  86506. * Method called to create the default loading screen.
  86507. * This can be overriden in your own app.
  86508. * @param canvas The rendering canvas element
  86509. * @returns The loading screen
  86510. */
  86511. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  86512. /**
  86513. * Method called to create the default rescale post process on each engine.
  86514. */
  86515. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  86516. /**
  86517. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  86518. */
  86519. forcePOTTextures: boolean;
  86520. /**
  86521. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  86522. */
  86523. isFullscreen: boolean;
  86524. /**
  86525. * Gets a boolean indicating if the pointer is currently locked
  86526. */
  86527. isPointerLock: boolean;
  86528. /**
  86529. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  86530. */
  86531. cullBackFaces: boolean;
  86532. /**
  86533. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  86534. */
  86535. renderEvenInBackground: boolean;
  86536. /**
  86537. * Gets or sets a boolean indicating that cache can be kept between frames
  86538. */
  86539. preventCacheWipeBetweenFrames: boolean;
  86540. /**
  86541. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  86542. **/
  86543. enableOfflineSupport: boolean;
  86544. /**
  86545. * 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)
  86546. **/
  86547. disableManifestCheck: boolean;
  86548. /**
  86549. * Gets the list of created scenes
  86550. */
  86551. scenes: Scene[];
  86552. /**
  86553. * Event raised when a new scene is created
  86554. */
  86555. onNewSceneAddedObservable: Observable<Scene>;
  86556. /**
  86557. * Gets the list of created postprocesses
  86558. */
  86559. postProcesses: PostProcess[];
  86560. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  86561. validateShaderPrograms: boolean;
  86562. /**
  86563. * Observable event triggered each time the rendering canvas is resized
  86564. */
  86565. onResizeObservable: Observable<Engine>;
  86566. /**
  86567. * Observable event triggered each time the canvas loses focus
  86568. */
  86569. onCanvasBlurObservable: Observable<Engine>;
  86570. /**
  86571. * Observable event triggered each time the canvas gains focus
  86572. */
  86573. onCanvasFocusObservable: Observable<Engine>;
  86574. /**
  86575. * Observable event triggered each time the canvas receives pointerout event
  86576. */
  86577. onCanvasPointerOutObservable: Observable<PointerEvent>;
  86578. /**
  86579. * Observable event triggered before each texture is initialized
  86580. */
  86581. onBeforeTextureInitObservable: Observable<Texture>;
  86582. private _vrDisplay;
  86583. private _vrSupported;
  86584. private _oldSize;
  86585. private _oldHardwareScaleFactor;
  86586. private _vrExclusivePointerMode;
  86587. private _webVRInitPromise;
  86588. /**
  86589. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  86590. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  86591. */
  86592. readonly isInVRExclusivePointerMode: boolean;
  86593. /**
  86594. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  86595. */
  86596. disableUniformBuffers: boolean;
  86597. /** @hidden */
  86598. _uniformBuffers: UniformBuffer[];
  86599. /**
  86600. * Gets a boolean indicating that the engine supports uniform buffers
  86601. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86602. */
  86603. readonly supportsUniformBuffers: boolean;
  86604. /**
  86605. * Observable raised when the engine begins a new frame
  86606. */
  86607. onBeginFrameObservable: Observable<Engine>;
  86608. /**
  86609. * If set, will be used to request the next animation frame for the render loop
  86610. */
  86611. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  86612. /**
  86613. * Observable raised when the engine ends the current frame
  86614. */
  86615. onEndFrameObservable: Observable<Engine>;
  86616. /**
  86617. * Observable raised when the engine is about to compile a shader
  86618. */
  86619. onBeforeShaderCompilationObservable: Observable<Engine>;
  86620. /**
  86621. * Observable raised when the engine has jsut compiled a shader
  86622. */
  86623. onAfterShaderCompilationObservable: Observable<Engine>;
  86624. /** @hidden */
  86625. _gl: WebGLRenderingContext;
  86626. private _renderingCanvas;
  86627. private _windowIsBackground;
  86628. private _webGLVersion;
  86629. protected _highPrecisionShadersAllowed: boolean;
  86630. /** @hidden */
  86631. readonly _shouldUseHighPrecisionShader: boolean;
  86632. /**
  86633. * Gets a boolean indicating that only power of 2 textures are supported
  86634. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  86635. */
  86636. readonly needPOTTextures: boolean;
  86637. /** @hidden */
  86638. _badOS: boolean;
  86639. /** @hidden */
  86640. _badDesktopOS: boolean;
  86641. /**
  86642. * Gets the audio engine
  86643. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86644. * @ignorenaming
  86645. */
  86646. static audioEngine: IAudioEngine;
  86647. /**
  86648. * Default AudioEngine factory responsible of creating the Audio Engine.
  86649. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  86650. */
  86651. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  86652. /**
  86653. * Default offline support factory responsible of creating a tool used to store data locally.
  86654. * By default, this will create a Database object if the workload has been embedded.
  86655. */
  86656. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  86657. private _onFocus;
  86658. private _onBlur;
  86659. private _onCanvasPointerOut;
  86660. private _onCanvasBlur;
  86661. private _onCanvasFocus;
  86662. private _onFullscreenChange;
  86663. private _onPointerLockChange;
  86664. private _onVRDisplayPointerRestricted;
  86665. private _onVRDisplayPointerUnrestricted;
  86666. private _onVrDisplayConnect;
  86667. private _onVrDisplayDisconnect;
  86668. private _onVrDisplayPresentChange;
  86669. /**
  86670. * Observable signaled when VR display mode changes
  86671. */
  86672. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  86673. /**
  86674. * Observable signaled when VR request present is complete
  86675. */
  86676. onVRRequestPresentComplete: Observable<boolean>;
  86677. /**
  86678. * Observable signaled when VR request present starts
  86679. */
  86680. onVRRequestPresentStart: Observable<Engine>;
  86681. private _hardwareScalingLevel;
  86682. /** @hidden */
  86683. protected _caps: EngineCapabilities;
  86684. private _pointerLockRequested;
  86685. private _isStencilEnable;
  86686. private _colorWrite;
  86687. private _loadingScreen;
  86688. /** @hidden */
  86689. _drawCalls: PerfCounter;
  86690. private _glVersion;
  86691. private _glRenderer;
  86692. private _glVendor;
  86693. private _videoTextureSupported;
  86694. private _renderingQueueLaunched;
  86695. private _activeRenderLoops;
  86696. private _deterministicLockstep;
  86697. private _lockstepMaxSteps;
  86698. /**
  86699. * Observable signaled when a context lost event is raised
  86700. */
  86701. onContextLostObservable: Observable<Engine>;
  86702. /**
  86703. * Observable signaled when a context restored event is raised
  86704. */
  86705. onContextRestoredObservable: Observable<Engine>;
  86706. private _onContextLost;
  86707. private _onContextRestored;
  86708. private _contextWasLost;
  86709. private _doNotHandleContextLost;
  86710. /**
  86711. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  86712. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  86713. */
  86714. doNotHandleContextLost: boolean;
  86715. private _performanceMonitor;
  86716. private _fps;
  86717. private _deltaTime;
  86718. /**
  86719. * Turn this value on if you want to pause FPS computation when in background
  86720. */
  86721. disablePerformanceMonitorInBackground: boolean;
  86722. /**
  86723. * Gets the performance monitor attached to this engine
  86724. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  86725. */
  86726. readonly performanceMonitor: PerformanceMonitor;
  86727. /**
  86728. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  86729. */
  86730. disableVertexArrayObjects: boolean;
  86731. /** @hidden */
  86732. protected _depthCullingState: _DepthCullingState;
  86733. /** @hidden */
  86734. protected _stencilState: _StencilState;
  86735. /** @hidden */
  86736. protected _alphaState: _AlphaState;
  86737. /** @hidden */
  86738. protected _alphaMode: number;
  86739. protected _internalTexturesCache: InternalTexture[];
  86740. /** @hidden */
  86741. protected _activeChannel: number;
  86742. private _currentTextureChannel;
  86743. /** @hidden */
  86744. protected _boundTexturesCache: {
  86745. [key: string]: Nullable<InternalTexture>;
  86746. };
  86747. /** @hidden */
  86748. protected _currentEffect: Nullable<Effect>;
  86749. /** @hidden */
  86750. protected _currentProgram: Nullable<WebGLProgram>;
  86751. private _compiledEffects;
  86752. private _vertexAttribArraysEnabled;
  86753. /** @hidden */
  86754. protected _cachedViewport: Nullable<Viewport>;
  86755. private _cachedVertexArrayObject;
  86756. /** @hidden */
  86757. protected _cachedVertexBuffers: any;
  86758. /** @hidden */
  86759. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  86760. /** @hidden */
  86761. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  86762. /** @hidden */
  86763. protected _currentRenderTarget: Nullable<InternalTexture>;
  86764. private _uintIndicesCurrentlySet;
  86765. private _currentBoundBuffer;
  86766. /** @hidden */
  86767. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  86768. private _currentBufferPointers;
  86769. private _currentInstanceLocations;
  86770. private _currentInstanceBuffers;
  86771. private _textureUnits;
  86772. private _workingCanvas;
  86773. private _workingContext;
  86774. private _rescalePostProcess;
  86775. private _dummyFramebuffer;
  86776. private _externalData;
  86777. private _bindedRenderFunction;
  86778. private _vaoRecordInProgress;
  86779. private _mustWipeVertexAttributes;
  86780. private _emptyTexture;
  86781. private _emptyCubeTexture;
  86782. private _emptyTexture3D;
  86783. /** @hidden */
  86784. _frameHandler: number;
  86785. private _nextFreeTextureSlots;
  86786. private _maxSimultaneousTextures;
  86787. private _activeRequests;
  86788. private _texturesSupported;
  86789. private _textureFormatInUse;
  86790. /**
  86791. * Gets the list of texture formats supported
  86792. */
  86793. readonly texturesSupported: Array<string>;
  86794. /**
  86795. * Gets the list of texture formats in use
  86796. */
  86797. readonly textureFormatInUse: Nullable<string>;
  86798. /**
  86799. * Gets the current viewport
  86800. */
  86801. readonly currentViewport: Nullable<Viewport>;
  86802. /**
  86803. * Gets the default empty texture
  86804. */
  86805. readonly emptyTexture: InternalTexture;
  86806. /**
  86807. * Gets the default empty 3D texture
  86808. */
  86809. readonly emptyTexture3D: InternalTexture;
  86810. /**
  86811. * Gets the default empty cube texture
  86812. */
  86813. readonly emptyCubeTexture: InternalTexture;
  86814. /**
  86815. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  86816. */
  86817. readonly premultipliedAlpha: boolean;
  86818. /**
  86819. * Creates a new engine
  86820. * @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
  86821. * @param antialias defines enable antialiasing (default: false)
  86822. * @param options defines further options to be sent to the getContext() function
  86823. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  86824. */
  86825. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  86826. private _disableTouchAction;
  86827. private _rebuildInternalTextures;
  86828. private _rebuildEffects;
  86829. /**
  86830. * Gets a boolean indicating if all created effects are ready
  86831. * @returns true if all effects are ready
  86832. */
  86833. areAllEffectsReady(): boolean;
  86834. private _rebuildBuffers;
  86835. private _initGLContext;
  86836. /**
  86837. * Gets version of the current webGL context
  86838. */
  86839. readonly webGLVersion: number;
  86840. /**
  86841. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  86842. */
  86843. readonly isStencilEnable: boolean;
  86844. private _prepareWorkingCanvas;
  86845. /**
  86846. * Reset the texture cache to empty state
  86847. */
  86848. resetTextureCache(): void;
  86849. /**
  86850. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  86851. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86852. * @returns true if engine is in deterministic lock step mode
  86853. */
  86854. isDeterministicLockStep(): boolean;
  86855. /**
  86856. * Gets the max steps when engine is running in deterministic lock step
  86857. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86858. * @returns the max steps
  86859. */
  86860. getLockstepMaxSteps(): number;
  86861. /**
  86862. * Gets an object containing information about the current webGL context
  86863. * @returns an object containing the vender, the renderer and the version of the current webGL context
  86864. */
  86865. getGlInfo(): {
  86866. vendor: string;
  86867. renderer: string;
  86868. version: string;
  86869. };
  86870. /**
  86871. * Gets current aspect ratio
  86872. * @param camera defines the camera to use to get the aspect ratio
  86873. * @param useScreen defines if screen size must be used (or the current render target if any)
  86874. * @returns a number defining the aspect ratio
  86875. */
  86876. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  86877. /**
  86878. * Gets current screen aspect ratio
  86879. * @returns a number defining the aspect ratio
  86880. */
  86881. getScreenAspectRatio(): number;
  86882. /**
  86883. * Gets the current render width
  86884. * @param useScreen defines if screen size must be used (or the current render target if any)
  86885. * @returns a number defining the current render width
  86886. */
  86887. getRenderWidth(useScreen?: boolean): number;
  86888. /**
  86889. * Gets the current render height
  86890. * @param useScreen defines if screen size must be used (or the current render target if any)
  86891. * @returns a number defining the current render height
  86892. */
  86893. getRenderHeight(useScreen?: boolean): number;
  86894. /**
  86895. * Gets the HTML canvas attached with the current webGL context
  86896. * @returns a HTML canvas
  86897. */
  86898. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  86899. /**
  86900. * Gets the client rect of the HTML canvas attached with the current webGL context
  86901. * @returns a client rectanglee
  86902. */
  86903. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  86904. /**
  86905. * Defines the hardware scaling level.
  86906. * By default the hardware scaling level is computed from the window device ratio.
  86907. * 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.
  86908. * @param level defines the level to use
  86909. */
  86910. setHardwareScalingLevel(level: number): void;
  86911. /**
  86912. * Gets the current hardware scaling level.
  86913. * By default the hardware scaling level is computed from the window device ratio.
  86914. * 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.
  86915. * @returns a number indicating the current hardware scaling level
  86916. */
  86917. getHardwareScalingLevel(): number;
  86918. /**
  86919. * Gets the list of loaded textures
  86920. * @returns an array containing all loaded textures
  86921. */
  86922. getLoadedTexturesCache(): InternalTexture[];
  86923. /**
  86924. * Gets the object containing all engine capabilities
  86925. * @returns the EngineCapabilities object
  86926. */
  86927. getCaps(): EngineCapabilities;
  86928. /**
  86929. * Gets the current depth function
  86930. * @returns a number defining the depth function
  86931. */
  86932. getDepthFunction(): Nullable<number>;
  86933. /**
  86934. * Sets the current depth function
  86935. * @param depthFunc defines the function to use
  86936. */
  86937. setDepthFunction(depthFunc: number): void;
  86938. /**
  86939. * Sets the current depth function to GREATER
  86940. */
  86941. setDepthFunctionToGreater(): void;
  86942. /**
  86943. * Sets the current depth function to GEQUAL
  86944. */
  86945. setDepthFunctionToGreaterOrEqual(): void;
  86946. /**
  86947. * Sets the current depth function to LESS
  86948. */
  86949. setDepthFunctionToLess(): void;
  86950. private _cachedStencilBuffer;
  86951. private _cachedStencilFunction;
  86952. private _cachedStencilMask;
  86953. private _cachedStencilOperationPass;
  86954. private _cachedStencilOperationFail;
  86955. private _cachedStencilOperationDepthFail;
  86956. private _cachedStencilReference;
  86957. /**
  86958. * Caches the the state of the stencil buffer
  86959. */
  86960. cacheStencilState(): void;
  86961. /**
  86962. * Restores the state of the stencil buffer
  86963. */
  86964. restoreStencilState(): void;
  86965. /**
  86966. * Sets the current depth function to LEQUAL
  86967. */
  86968. setDepthFunctionToLessOrEqual(): void;
  86969. /**
  86970. * Gets a boolean indicating if stencil buffer is enabled
  86971. * @returns the current stencil buffer state
  86972. */
  86973. getStencilBuffer(): boolean;
  86974. /**
  86975. * Enable or disable the stencil buffer
  86976. * @param enable defines if the stencil buffer must be enabled or disabled
  86977. */
  86978. setStencilBuffer(enable: boolean): void;
  86979. /**
  86980. * Gets the current stencil mask
  86981. * @returns a number defining the new stencil mask to use
  86982. */
  86983. getStencilMask(): number;
  86984. /**
  86985. * Sets the current stencil mask
  86986. * @param mask defines the new stencil mask to use
  86987. */
  86988. setStencilMask(mask: number): void;
  86989. /**
  86990. * Gets the current stencil function
  86991. * @returns a number defining the stencil function to use
  86992. */
  86993. getStencilFunction(): number;
  86994. /**
  86995. * Gets the current stencil reference value
  86996. * @returns a number defining the stencil reference value to use
  86997. */
  86998. getStencilFunctionReference(): number;
  86999. /**
  87000. * Gets the current stencil mask
  87001. * @returns a number defining the stencil mask to use
  87002. */
  87003. getStencilFunctionMask(): number;
  87004. /**
  87005. * Sets the current stencil function
  87006. * @param stencilFunc defines the new stencil function to use
  87007. */
  87008. setStencilFunction(stencilFunc: number): void;
  87009. /**
  87010. * Sets the current stencil reference
  87011. * @param reference defines the new stencil reference to use
  87012. */
  87013. setStencilFunctionReference(reference: number): void;
  87014. /**
  87015. * Sets the current stencil mask
  87016. * @param mask defines the new stencil mask to use
  87017. */
  87018. setStencilFunctionMask(mask: number): void;
  87019. /**
  87020. * Gets the current stencil operation when stencil fails
  87021. * @returns a number defining stencil operation to use when stencil fails
  87022. */
  87023. getStencilOperationFail(): number;
  87024. /**
  87025. * Gets the current stencil operation when depth fails
  87026. * @returns a number defining stencil operation to use when depth fails
  87027. */
  87028. getStencilOperationDepthFail(): number;
  87029. /**
  87030. * Gets the current stencil operation when stencil passes
  87031. * @returns a number defining stencil operation to use when stencil passes
  87032. */
  87033. getStencilOperationPass(): number;
  87034. /**
  87035. * Sets the stencil operation to use when stencil fails
  87036. * @param operation defines the stencil operation to use when stencil fails
  87037. */
  87038. setStencilOperationFail(operation: number): void;
  87039. /**
  87040. * Sets the stencil operation to use when depth fails
  87041. * @param operation defines the stencil operation to use when depth fails
  87042. */
  87043. setStencilOperationDepthFail(operation: number): void;
  87044. /**
  87045. * Sets the stencil operation to use when stencil passes
  87046. * @param operation defines the stencil operation to use when stencil passes
  87047. */
  87048. setStencilOperationPass(operation: number): void;
  87049. /**
  87050. * Sets a boolean indicating if the dithering state is enabled or disabled
  87051. * @param value defines the dithering state
  87052. */
  87053. setDitheringState(value: boolean): void;
  87054. /**
  87055. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  87056. * @param value defines the rasterizer state
  87057. */
  87058. setRasterizerState(value: boolean): void;
  87059. /**
  87060. * stop executing a render loop function and remove it from the execution array
  87061. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  87062. */
  87063. stopRenderLoop(renderFunction?: () => void): void;
  87064. /** @hidden */
  87065. _renderLoop(): void;
  87066. /**
  87067. * Register and execute a render loop. The engine can have more than one render function
  87068. * @param renderFunction defines the function to continuously execute
  87069. */
  87070. runRenderLoop(renderFunction: () => void): void;
  87071. /**
  87072. * Toggle full screen mode
  87073. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87074. */
  87075. switchFullscreen(requestPointerLock: boolean): void;
  87076. /**
  87077. * Enters full screen mode
  87078. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87079. */
  87080. enterFullscreen(requestPointerLock: boolean): void;
  87081. /**
  87082. * Exits full screen mode
  87083. */
  87084. exitFullscreen(): void;
  87085. /**
  87086. * Clear the current render buffer or the current render target (if any is set up)
  87087. * @param color defines the color to use
  87088. * @param backBuffer defines if the back buffer must be cleared
  87089. * @param depth defines if the depth buffer must be cleared
  87090. * @param stencil defines if the stencil buffer must be cleared
  87091. */
  87092. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  87093. /**
  87094. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  87095. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87096. * @param y defines the y-coordinate of the corner of the clear rectangle
  87097. * @param width defines the width of the clear rectangle
  87098. * @param height defines the height of the clear rectangle
  87099. * @param clearColor defines the clear color
  87100. */
  87101. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  87102. /**
  87103. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  87104. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87105. * @param y defines the y-coordinate of the corner of the clear rectangle
  87106. * @param width defines the width of the clear rectangle
  87107. * @param height defines the height of the clear rectangle
  87108. */
  87109. enableScissor(x: number, y: number, width: number, height: number): void;
  87110. /**
  87111. * Disable previously set scissor test rectangle
  87112. */
  87113. disableScissor(): void;
  87114. private _viewportCached;
  87115. /** @hidden */
  87116. _viewport(x: number, y: number, width: number, height: number): void;
  87117. /**
  87118. * Set the WebGL's viewport
  87119. * @param viewport defines the viewport element to be used
  87120. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  87121. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  87122. */
  87123. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  87124. /**
  87125. * Directly set the WebGL Viewport
  87126. * @param x defines the x coordinate of the viewport (in screen space)
  87127. * @param y defines the y coordinate of the viewport (in screen space)
  87128. * @param width defines the width of the viewport (in screen space)
  87129. * @param height defines the height of the viewport (in screen space)
  87130. * @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
  87131. */
  87132. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  87133. /**
  87134. * Begin a new frame
  87135. */
  87136. beginFrame(): void;
  87137. /**
  87138. * Enf the current frame
  87139. */
  87140. endFrame(): void;
  87141. /**
  87142. * Resize the view according to the canvas' size
  87143. */
  87144. resize(): void;
  87145. /**
  87146. * Force a specific size of the canvas
  87147. * @param width defines the new canvas' width
  87148. * @param height defines the new canvas' height
  87149. */
  87150. setSize(width: number, height: number): void;
  87151. /**
  87152. * Gets a boolean indicating if a webVR device was detected
  87153. * @returns true if a webVR device was detected
  87154. */
  87155. isVRDevicePresent(): boolean;
  87156. /**
  87157. * Gets the current webVR device
  87158. * @returns the current webVR device (or null)
  87159. */
  87160. getVRDevice(): any;
  87161. /**
  87162. * Initializes a webVR display and starts listening to display change events
  87163. * The onVRDisplayChangedObservable will be notified upon these changes
  87164. * @returns The onVRDisplayChangedObservable
  87165. */
  87166. initWebVR(): Observable<IDisplayChangedEventArgs>;
  87167. /**
  87168. * Initializes a webVR display and starts listening to display change events
  87169. * The onVRDisplayChangedObservable will be notified upon these changes
  87170. * @returns A promise containing a VRDisplay and if vr is supported
  87171. */
  87172. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  87173. /**
  87174. * Call this function to switch to webVR mode
  87175. * Will do nothing if webVR is not supported or if there is no webVR device
  87176. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87177. */
  87178. enableVR(): void;
  87179. /**
  87180. * Call this function to leave webVR mode
  87181. * Will do nothing if webVR is not supported or if there is no webVR device
  87182. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87183. */
  87184. disableVR(): void;
  87185. private _onVRFullScreenTriggered;
  87186. private _getVRDisplaysAsync;
  87187. /**
  87188. * Binds the frame buffer to the specified texture.
  87189. * @param texture The texture to render to or null for the default canvas
  87190. * @param faceIndex The face of the texture to render to in case of cube texture
  87191. * @param requiredWidth The width of the target to render to
  87192. * @param requiredHeight The height of the target to render to
  87193. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  87194. * @param depthStencilTexture The depth stencil texture to use to render
  87195. * @param lodLevel defines le lod level to bind to the frame buffer
  87196. */
  87197. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  87198. private bindUnboundFramebuffer;
  87199. /**
  87200. * Unbind the current render target texture from the webGL context
  87201. * @param texture defines the render target texture to unbind
  87202. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  87203. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  87204. */
  87205. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  87206. /**
  87207. * Unbind a list of render target textures from the webGL context
  87208. * This is used only when drawBuffer extension or webGL2 are active
  87209. * @param textures defines the render target textures to unbind
  87210. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  87211. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  87212. */
  87213. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  87214. /**
  87215. * Force the mipmap generation for the given render target texture
  87216. * @param texture defines the render target texture to use
  87217. */
  87218. generateMipMapsForCubemap(texture: InternalTexture): void;
  87219. /**
  87220. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  87221. */
  87222. flushFramebuffer(): void;
  87223. /**
  87224. * Unbind the current render target and bind the default framebuffer
  87225. */
  87226. restoreDefaultFramebuffer(): void;
  87227. /**
  87228. * Create an uniform buffer
  87229. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87230. * @param elements defines the content of the uniform buffer
  87231. * @returns the webGL uniform buffer
  87232. */
  87233. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  87234. /**
  87235. * Create a dynamic uniform buffer
  87236. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87237. * @param elements defines the content of the uniform buffer
  87238. * @returns the webGL uniform buffer
  87239. */
  87240. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  87241. /**
  87242. * Update an existing uniform buffer
  87243. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87244. * @param uniformBuffer defines the target uniform buffer
  87245. * @param elements defines the content to update
  87246. * @param offset defines the offset in the uniform buffer where update should start
  87247. * @param count defines the size of the data to update
  87248. */
  87249. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87250. private _resetVertexBufferBinding;
  87251. /**
  87252. * Creates a vertex buffer
  87253. * @param data the data for the vertex buffer
  87254. * @returns the new WebGL static buffer
  87255. */
  87256. createVertexBuffer(data: DataArray): WebGLBuffer;
  87257. /**
  87258. * Creates a dynamic vertex buffer
  87259. * @param data the data for the dynamic vertex buffer
  87260. * @returns the new WebGL dynamic buffer
  87261. */
  87262. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  87263. /**
  87264. * Update a dynamic index buffer
  87265. * @param indexBuffer defines the target index buffer
  87266. * @param indices defines the data to update
  87267. * @param offset defines the offset in the target index buffer where update should start
  87268. */
  87269. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  87270. /**
  87271. * Updates a dynamic vertex buffer.
  87272. * @param vertexBuffer the vertex buffer to update
  87273. * @param data the data used to update the vertex buffer
  87274. * @param byteOffset the byte offset of the data
  87275. * @param byteLength the byte length of the data
  87276. */
  87277. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  87278. private _resetIndexBufferBinding;
  87279. /**
  87280. * Creates a new index buffer
  87281. * @param indices defines the content of the index buffer
  87282. * @param updatable defines if the index buffer must be updatable
  87283. * @returns a new webGL buffer
  87284. */
  87285. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  87286. /**
  87287. * Bind a webGL buffer to the webGL context
  87288. * @param buffer defines the buffer to bind
  87289. */
  87290. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  87291. /**
  87292. * Bind an uniform buffer to the current webGL context
  87293. * @param buffer defines the buffer to bind
  87294. */
  87295. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  87296. /**
  87297. * Bind a buffer to the current webGL context at a given location
  87298. * @param buffer defines the buffer to bind
  87299. * @param location defines the index where to bind the buffer
  87300. */
  87301. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  87302. /**
  87303. * Bind a specific block at a given index in a specific shader program
  87304. * @param shaderProgram defines the shader program
  87305. * @param blockName defines the block name
  87306. * @param index defines the index where to bind the block
  87307. */
  87308. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  87309. private bindIndexBuffer;
  87310. private bindBuffer;
  87311. /**
  87312. * update the bound buffer with the given data
  87313. * @param data defines the data to update
  87314. */
  87315. updateArrayBuffer(data: Float32Array): void;
  87316. private _vertexAttribPointer;
  87317. private _bindIndexBufferWithCache;
  87318. private _bindVertexBuffersAttributes;
  87319. /**
  87320. * Records a vertex array object
  87321. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  87322. * @param vertexBuffers defines the list of vertex buffers to store
  87323. * @param indexBuffer defines the index buffer to store
  87324. * @param effect defines the effect to store
  87325. * @returns the new vertex array object
  87326. */
  87327. recordVertexArrayObject(vertexBuffers: {
  87328. [key: string]: VertexBuffer;
  87329. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  87330. /**
  87331. * Bind a specific vertex array object
  87332. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  87333. * @param vertexArrayObject defines the vertex array object to bind
  87334. * @param indexBuffer defines the index buffer to bind
  87335. */
  87336. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  87337. /**
  87338. * Bind webGl buffers directly to the webGL context
  87339. * @param vertexBuffer defines the vertex buffer to bind
  87340. * @param indexBuffer defines the index buffer to bind
  87341. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  87342. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  87343. * @param effect defines the effect associated with the vertex buffer
  87344. */
  87345. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  87346. private _unbindVertexArrayObject;
  87347. /**
  87348. * Bind a list of vertex buffers to the webGL context
  87349. * @param vertexBuffers defines the list of vertex buffers to bind
  87350. * @param indexBuffer defines the index buffer to bind
  87351. * @param effect defines the effect associated with the vertex buffers
  87352. */
  87353. bindBuffers(vertexBuffers: {
  87354. [key: string]: Nullable<VertexBuffer>;
  87355. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  87356. /**
  87357. * Unbind all instance attributes
  87358. */
  87359. unbindInstanceAttributes(): void;
  87360. /**
  87361. * Release and free the memory of a vertex array object
  87362. * @param vao defines the vertex array object to delete
  87363. */
  87364. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  87365. /** @hidden */
  87366. _releaseBuffer(buffer: WebGLBuffer): boolean;
  87367. /**
  87368. * Creates a webGL buffer to use with instanciation
  87369. * @param capacity defines the size of the buffer
  87370. * @returns the webGL buffer
  87371. */
  87372. createInstancesBuffer(capacity: number): WebGLBuffer;
  87373. /**
  87374. * Delete a webGL buffer used with instanciation
  87375. * @param buffer defines the webGL buffer to delete
  87376. */
  87377. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  87378. /**
  87379. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  87380. * @param instancesBuffer defines the webGL buffer to update and bind
  87381. * @param data defines the data to store in the buffer
  87382. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  87383. */
  87384. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  87385. /**
  87386. * Apply all cached states (depth, culling, stencil and alpha)
  87387. */
  87388. applyStates(): void;
  87389. /**
  87390. * Send a draw order
  87391. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  87392. * @param indexStart defines the starting index
  87393. * @param indexCount defines the number of index to draw
  87394. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87395. */
  87396. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  87397. /**
  87398. * Draw a list of points
  87399. * @param verticesStart defines the index of first vertex to draw
  87400. * @param verticesCount defines the count of vertices to draw
  87401. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87402. */
  87403. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87404. /**
  87405. * Draw a list of unindexed primitives
  87406. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  87407. * @param verticesStart defines the index of first vertex to draw
  87408. * @param verticesCount defines the count of vertices to draw
  87409. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87410. */
  87411. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87412. /**
  87413. * Draw a list of indexed primitives
  87414. * @param fillMode defines the primitive to use
  87415. * @param indexStart defines the starting index
  87416. * @param indexCount defines the number of index to draw
  87417. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87418. */
  87419. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  87420. /**
  87421. * Draw a list of unindexed primitives
  87422. * @param fillMode defines the primitive to use
  87423. * @param verticesStart defines the index of first vertex to draw
  87424. * @param verticesCount defines the count of vertices to draw
  87425. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87426. */
  87427. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87428. private _drawMode;
  87429. /** @hidden */
  87430. _releaseEffect(effect: Effect): void;
  87431. /** @hidden */
  87432. _deleteProgram(program: WebGLProgram): void;
  87433. /**
  87434. * Create a new effect (used to store vertex/fragment shaders)
  87435. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  87436. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  87437. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  87438. * @param samplers defines an array of string used to represent textures
  87439. * @param defines defines the string containing the defines to use to compile the shaders
  87440. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  87441. * @param onCompiled defines a function to call when the effect creation is successful
  87442. * @param onError defines a function to call when the effect creation has failed
  87443. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  87444. * @returns the new Effect
  87445. */
  87446. 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;
  87447. private _compileShader;
  87448. private _compileRawShader;
  87449. /**
  87450. * Directly creates a webGL program
  87451. * @param vertexCode defines the vertex shader code to use
  87452. * @param fragmentCode defines the fragment shader code to use
  87453. * @param context defines the webGL context to use (if not set, the current one will be used)
  87454. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  87455. * @returns the new webGL program
  87456. */
  87457. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  87458. /**
  87459. * Creates a webGL program
  87460. * @param vertexCode defines the vertex shader code to use
  87461. * @param fragmentCode defines the fragment shader code to use
  87462. * @param defines defines the string containing the defines to use to compile the shaders
  87463. * @param context defines the webGL context to use (if not set, the current one will be used)
  87464. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  87465. * @returns the new webGL program
  87466. */
  87467. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  87468. private _createShaderProgram;
  87469. private _finalizeProgram;
  87470. /** @hidden */
  87471. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  87472. /** @hidden */
  87473. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  87474. /**
  87475. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  87476. * @param shaderProgram defines the webGL program to use
  87477. * @param uniformsNames defines the list of uniform names
  87478. * @returns an array of webGL uniform locations
  87479. */
  87480. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  87481. /**
  87482. * Gets the lsit of active attributes for a given webGL program
  87483. * @param shaderProgram defines the webGL program to use
  87484. * @param attributesNames defines the list of attribute names to get
  87485. * @returns an array of indices indicating the offset of each attribute
  87486. */
  87487. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  87488. /**
  87489. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  87490. * @param effect defines the effect to activate
  87491. */
  87492. enableEffect(effect: Nullable<Effect>): void;
  87493. /**
  87494. * Set the value of an uniform to an array of int32
  87495. * @param uniform defines the webGL uniform location where to store the value
  87496. * @param array defines the array of int32 to store
  87497. */
  87498. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87499. /**
  87500. * Set the value of an uniform to an array of int32 (stored as vec2)
  87501. * @param uniform defines the webGL uniform location where to store the value
  87502. * @param array defines the array of int32 to store
  87503. */
  87504. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87505. /**
  87506. * Set the value of an uniform to an array of int32 (stored as vec3)
  87507. * @param uniform defines the webGL uniform location where to store the value
  87508. * @param array defines the array of int32 to store
  87509. */
  87510. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87511. /**
  87512. * Set the value of an uniform to an array of int32 (stored as vec4)
  87513. * @param uniform defines the webGL uniform location where to store the value
  87514. * @param array defines the array of int32 to store
  87515. */
  87516. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87517. /**
  87518. * Set the value of an uniform to an array of float32
  87519. * @param uniform defines the webGL uniform location where to store the value
  87520. * @param array defines the array of float32 to store
  87521. */
  87522. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87523. /**
  87524. * Set the value of an uniform to an array of float32 (stored as vec2)
  87525. * @param uniform defines the webGL uniform location where to store the value
  87526. * @param array defines the array of float32 to store
  87527. */
  87528. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87529. /**
  87530. * Set the value of an uniform to an array of float32 (stored as vec3)
  87531. * @param uniform defines the webGL uniform location where to store the value
  87532. * @param array defines the array of float32 to store
  87533. */
  87534. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87535. /**
  87536. * Set the value of an uniform to an array of float32 (stored as vec4)
  87537. * @param uniform defines the webGL uniform location where to store the value
  87538. * @param array defines the array of float32 to store
  87539. */
  87540. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87541. /**
  87542. * Set the value of an uniform to an array of number
  87543. * @param uniform defines the webGL uniform location where to store the value
  87544. * @param array defines the array of number to store
  87545. */
  87546. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87547. /**
  87548. * Set the value of an uniform to an array of number (stored as vec2)
  87549. * @param uniform defines the webGL uniform location where to store the value
  87550. * @param array defines the array of number to store
  87551. */
  87552. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87553. /**
  87554. * Set the value of an uniform to an array of number (stored as vec3)
  87555. * @param uniform defines the webGL uniform location where to store the value
  87556. * @param array defines the array of number to store
  87557. */
  87558. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87559. /**
  87560. * Set the value of an uniform to an array of number (stored as vec4)
  87561. * @param uniform defines the webGL uniform location where to store the value
  87562. * @param array defines the array of number to store
  87563. */
  87564. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87565. /**
  87566. * Set the value of an uniform to an array of float32 (stored as matrices)
  87567. * @param uniform defines the webGL uniform location where to store the value
  87568. * @param matrices defines the array of float32 to store
  87569. */
  87570. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  87571. /**
  87572. * Set the value of an uniform to a matrix
  87573. * @param uniform defines the webGL uniform location where to store the value
  87574. * @param matrix defines the matrix to store
  87575. */
  87576. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  87577. /**
  87578. * Set the value of an uniform to a matrix (3x3)
  87579. * @param uniform defines the webGL uniform location where to store the value
  87580. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  87581. */
  87582. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  87583. /**
  87584. * Set the value of an uniform to a matrix (2x2)
  87585. * @param uniform defines the webGL uniform location where to store the value
  87586. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  87587. */
  87588. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  87589. /**
  87590. * Set the value of an uniform to a number (int)
  87591. * @param uniform defines the webGL uniform location where to store the value
  87592. * @param value defines the int number to store
  87593. */
  87594. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  87595. /**
  87596. * Set the value of an uniform to a number (float)
  87597. * @param uniform defines the webGL uniform location where to store the value
  87598. * @param value defines the float number to store
  87599. */
  87600. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  87601. /**
  87602. * Set the value of an uniform to a vec2
  87603. * @param uniform defines the webGL uniform location where to store the value
  87604. * @param x defines the 1st component of the value
  87605. * @param y defines the 2nd component of the value
  87606. */
  87607. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  87608. /**
  87609. * Set the value of an uniform to a vec3
  87610. * @param uniform defines the webGL uniform location where to store the value
  87611. * @param x defines the 1st component of the value
  87612. * @param y defines the 2nd component of the value
  87613. * @param z defines the 3rd component of the value
  87614. */
  87615. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  87616. /**
  87617. * Set the value of an uniform to a boolean
  87618. * @param uniform defines the webGL uniform location where to store the value
  87619. * @param bool defines the boolean to store
  87620. */
  87621. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  87622. /**
  87623. * Set the value of an uniform to a vec4
  87624. * @param uniform defines the webGL uniform location where to store the value
  87625. * @param x defines the 1st component of the value
  87626. * @param y defines the 2nd component of the value
  87627. * @param z defines the 3rd component of the value
  87628. * @param w defines the 4th component of the value
  87629. */
  87630. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  87631. /**
  87632. * Set the value of an uniform to a Color3
  87633. * @param uniform defines the webGL uniform location where to store the value
  87634. * @param color3 defines the color to store
  87635. */
  87636. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  87637. /**
  87638. * Set the value of an uniform to a Color3 and an alpha value
  87639. * @param uniform defines the webGL uniform location where to store the value
  87640. * @param color3 defines the color to store
  87641. * @param alpha defines the alpha component to store
  87642. */
  87643. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  87644. /**
  87645. * Sets a Color4 on a uniform variable
  87646. * @param uniform defines the uniform location
  87647. * @param color4 defines the value to be set
  87648. */
  87649. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  87650. /**
  87651. * Set various states to the webGL context
  87652. * @param culling defines backface culling state
  87653. * @param zOffset defines the value to apply to zOffset (0 by default)
  87654. * @param force defines if states must be applied even if cache is up to date
  87655. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  87656. */
  87657. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  87658. /**
  87659. * Set the z offset to apply to current rendering
  87660. * @param value defines the offset to apply
  87661. */
  87662. setZOffset(value: number): void;
  87663. /**
  87664. * Gets the current value of the zOffset
  87665. * @returns the current zOffset state
  87666. */
  87667. getZOffset(): number;
  87668. /**
  87669. * Enable or disable depth buffering
  87670. * @param enable defines the state to set
  87671. */
  87672. setDepthBuffer(enable: boolean): void;
  87673. /**
  87674. * Gets a boolean indicating if depth writing is enabled
  87675. * @returns the current depth writing state
  87676. */
  87677. getDepthWrite(): boolean;
  87678. /**
  87679. * Enable or disable depth writing
  87680. * @param enable defines the state to set
  87681. */
  87682. setDepthWrite(enable: boolean): void;
  87683. /**
  87684. * Enable or disable color writing
  87685. * @param enable defines the state to set
  87686. */
  87687. setColorWrite(enable: boolean): void;
  87688. /**
  87689. * Gets a boolean indicating if color writing is enabled
  87690. * @returns the current color writing state
  87691. */
  87692. getColorWrite(): boolean;
  87693. /**
  87694. * Sets alpha constants used by some alpha blending modes
  87695. * @param r defines the red component
  87696. * @param g defines the green component
  87697. * @param b defines the blue component
  87698. * @param a defines the alpha component
  87699. */
  87700. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  87701. /**
  87702. * Sets the current alpha mode
  87703. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  87704. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  87705. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  87706. */
  87707. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  87708. /**
  87709. * Gets the current alpha mode
  87710. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  87711. * @returns the current alpha mode
  87712. */
  87713. getAlphaMode(): number;
  87714. /**
  87715. * Clears the list of texture accessible through engine.
  87716. * This can help preventing texture load conflict due to name collision.
  87717. */
  87718. clearInternalTexturesCache(): void;
  87719. /**
  87720. * Force the entire cache to be cleared
  87721. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  87722. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  87723. */
  87724. wipeCaches(bruteForce?: boolean): void;
  87725. /**
  87726. * Set the compressed texture format to use, based on the formats you have, and the formats
  87727. * supported by the hardware / browser.
  87728. *
  87729. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  87730. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  87731. * to API arguments needed to compressed textures. This puts the burden on the container
  87732. * generator to house the arcane code for determining these for current & future formats.
  87733. *
  87734. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  87735. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  87736. *
  87737. * Note: The result of this call is not taken into account when a texture is base64.
  87738. *
  87739. * @param formatsAvailable defines the list of those format families you have created
  87740. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  87741. *
  87742. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  87743. * @returns The extension selected.
  87744. */
  87745. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  87746. private _getSamplingParameters;
  87747. private _partialLoadImg;
  87748. private _cascadeLoadImgs;
  87749. /** @hidden */
  87750. _createTexture(): WebGLTexture;
  87751. /**
  87752. * Usually called from Texture.ts.
  87753. * Passed information to create a WebGLTexture
  87754. * @param urlArg defines a value which contains one of the following:
  87755. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  87756. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  87757. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  87758. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  87759. * @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)
  87760. * @param scene needed for loading to the correct scene
  87761. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  87762. * @param onLoad optional callback to be called upon successful completion
  87763. * @param onError optional callback to be called upon failure
  87764. * @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
  87765. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  87766. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  87767. * @param forcedExtension defines the extension to use to pick the right loader
  87768. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  87769. * @returns a InternalTexture for assignment back into BABYLON.Texture
  87770. */
  87771. 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;
  87772. private _rescaleTexture;
  87773. /**
  87774. * Update a raw texture
  87775. * @param texture defines the texture to update
  87776. * @param data defines the data to store in the texture
  87777. * @param format defines the format of the data
  87778. * @param invertY defines if data must be stored with Y axis inverted
  87779. * @param compression defines the compression used (null by default)
  87780. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87781. */
  87782. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  87783. /**
  87784. * Creates a raw texture
  87785. * @param data defines the data to store in the texture
  87786. * @param width defines the width of the texture
  87787. * @param height defines the height of the texture
  87788. * @param format defines the format of the data
  87789. * @param generateMipMaps defines if the engine should generate the mip levels
  87790. * @param invertY defines if data must be stored with Y axis inverted
  87791. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87792. * @param compression defines the compression used (null by default)
  87793. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87794. * @returns the raw texture inside an InternalTexture
  87795. */
  87796. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  87797. private _unpackFlipYCached;
  87798. /**
  87799. * In case you are sharing the context with other applications, it might
  87800. * be interested to not cache the unpack flip y state to ensure a consistent
  87801. * value would be set.
  87802. */
  87803. enableUnpackFlipYCached: boolean;
  87804. /** @hidden */
  87805. _unpackFlipY(value: boolean): void;
  87806. /** @hidden */
  87807. _getUnpackAlignement(): number;
  87808. /**
  87809. * Creates a dynamic texture
  87810. * @param width defines the width of the texture
  87811. * @param height defines the height of the texture
  87812. * @param generateMipMaps defines if the engine should generate the mip levels
  87813. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87814. * @returns the dynamic texture inside an InternalTexture
  87815. */
  87816. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  87817. /**
  87818. * Update the sampling mode of a given texture
  87819. * @param samplingMode defines the required sampling mode
  87820. * @param texture defines the texture to update
  87821. */
  87822. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  87823. /**
  87824. * Update the content of a dynamic texture
  87825. * @param texture defines the texture to update
  87826. * @param canvas defines the canvas containing the source
  87827. * @param invertY defines if data must be stored with Y axis inverted
  87828. * @param premulAlpha defines if alpha is stored as premultiplied
  87829. * @param format defines the format of the data
  87830. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  87831. */
  87832. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  87833. /**
  87834. * Update a video texture
  87835. * @param texture defines the texture to update
  87836. * @param video defines the video element to use
  87837. * @param invertY defines if data must be stored with Y axis inverted
  87838. */
  87839. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  87840. /**
  87841. * Updates a depth texture Comparison Mode and Function.
  87842. * If the comparison Function is equal to 0, the mode will be set to none.
  87843. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  87844. * @param texture The texture to set the comparison function for
  87845. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  87846. */
  87847. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  87848. private _setupDepthStencilTexture;
  87849. /**
  87850. * Creates a depth stencil texture.
  87851. * This is only available in WebGL 2 or with the depth texture extension available.
  87852. * @param size The size of face edge in the texture.
  87853. * @param options The options defining the texture.
  87854. * @returns The texture
  87855. */
  87856. createDepthStencilTexture(size: number | {
  87857. width: number;
  87858. height: number;
  87859. }, options: DepthTextureCreationOptions): InternalTexture;
  87860. /**
  87861. * Creates a depth stencil texture.
  87862. * This is only available in WebGL 2 or with the depth texture extension available.
  87863. * @param size The size of face edge in the texture.
  87864. * @param options The options defining the texture.
  87865. * @returns The texture
  87866. */
  87867. private _createDepthStencilTexture;
  87868. /**
  87869. * Creates a depth stencil cube texture.
  87870. * This is only available in WebGL 2.
  87871. * @param size The size of face edge in the cube texture.
  87872. * @param options The options defining the cube texture.
  87873. * @returns The cube texture
  87874. */
  87875. private _createDepthStencilCubeTexture;
  87876. /**
  87877. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  87878. * @param renderTarget The render target to set the frame buffer for
  87879. */
  87880. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  87881. /**
  87882. * Creates a new render target texture
  87883. * @param size defines the size of the texture
  87884. * @param options defines the options used to create the texture
  87885. * @returns a new render target texture stored in an InternalTexture
  87886. */
  87887. createRenderTargetTexture(size: number | {
  87888. width: number;
  87889. height: number;
  87890. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  87891. /**
  87892. * Create a multi render target texture
  87893. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  87894. * @param size defines the size of the texture
  87895. * @param options defines the creation options
  87896. * @returns the cube texture as an InternalTexture
  87897. */
  87898. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  87899. private _setupFramebufferDepthAttachments;
  87900. /**
  87901. * Updates the sample count of a render target texture
  87902. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  87903. * @param texture defines the texture to update
  87904. * @param samples defines the sample count to set
  87905. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  87906. */
  87907. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  87908. /**
  87909. * Update the sample count for a given multiple render target texture
  87910. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  87911. * @param textures defines the textures to update
  87912. * @param samples defines the sample count to set
  87913. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  87914. */
  87915. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  87916. /** @hidden */
  87917. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87918. /** @hidden */
  87919. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87920. /** @hidden */
  87921. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87922. /** @hidden */
  87923. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  87924. /**
  87925. * Creates a new render target cube texture
  87926. * @param size defines the size of the texture
  87927. * @param options defines the options used to create the texture
  87928. * @returns a new render target cube texture stored in an InternalTexture
  87929. */
  87930. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  87931. /**
  87932. * Creates a cube texture
  87933. * @param rootUrl defines the url where the files to load is located
  87934. * @param scene defines the current scene
  87935. * @param files defines the list of files to load (1 per face)
  87936. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87937. * @param onLoad defines an optional callback raised when the texture is loaded
  87938. * @param onError defines an optional callback raised if there is an issue to load the texture
  87939. * @param format defines the format of the data
  87940. * @param forcedExtension defines the extension to use to pick the right loader
  87941. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87942. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87943. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87944. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  87945. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  87946. * @returns the cube texture as an InternalTexture
  87947. */
  87948. 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;
  87949. /**
  87950. * @hidden
  87951. */
  87952. _setCubeMapTextureParams(loadMipmap: boolean): void;
  87953. /**
  87954. * Update a raw cube texture
  87955. * @param texture defines the texture to udpdate
  87956. * @param data defines the data to store
  87957. * @param format defines the data format
  87958. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87959. * @param invertY defines if data must be stored with Y axis inverted
  87960. * @param compression defines the compression used (null by default)
  87961. * @param level defines which level of the texture to update
  87962. */
  87963. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  87964. /**
  87965. * Creates a new raw cube texture
  87966. * @param data defines the array of data to use to create each face
  87967. * @param size defines the size of the textures
  87968. * @param format defines the format of the data
  87969. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  87970. * @param generateMipMaps defines if the engine should generate the mip levels
  87971. * @param invertY defines if data must be stored with Y axis inverted
  87972. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  87973. * @param compression defines the compression used (null by default)
  87974. * @returns the cube texture as an InternalTexture
  87975. */
  87976. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  87977. /**
  87978. * Creates a new raw cube texture from a specified url
  87979. * @param url defines the url where the data is located
  87980. * @param scene defines the current scene
  87981. * @param size defines the size of the textures
  87982. * @param format defines the format of the data
  87983. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  87984. * @param noMipmap defines if the engine should avoid generating the mip levels
  87985. * @param callback defines a callback used to extract texture data from loaded data
  87986. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  87987. * @param onLoad defines a callback called when texture is loaded
  87988. * @param onError defines a callback called if there is an error
  87989. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  87990. * @param invertY defines if data must be stored with Y axis inverted
  87991. * @returns the cube texture as an InternalTexture
  87992. */
  87993. 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;
  87994. /**
  87995. * Update a raw 3D texture
  87996. * @param texture defines the texture to update
  87997. * @param data defines the data to store
  87998. * @param format defines the data format
  87999. * @param invertY defines if data must be stored with Y axis inverted
  88000. * @param compression defines the used compression (can be null)
  88001. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  88002. */
  88003. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  88004. /**
  88005. * Creates a new raw 3D texture
  88006. * @param data defines the data used to create the texture
  88007. * @param width defines the width of the texture
  88008. * @param height defines the height of the texture
  88009. * @param depth defines the depth of the texture
  88010. * @param format defines the format of the texture
  88011. * @param generateMipMaps defines if the engine must generate mip levels
  88012. * @param invertY defines if data must be stored with Y axis inverted
  88013. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88014. * @param compression defines the compressed used (can be null)
  88015. * @param textureType defines the compressed used (can be null)
  88016. * @returns a new raw 3D texture (stored in an InternalTexture)
  88017. */
  88018. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  88019. private _prepareWebGLTextureContinuation;
  88020. private _prepareWebGLTexture;
  88021. private _convertRGBtoRGBATextureData;
  88022. /** @hidden */
  88023. _releaseFramebufferObjects(texture: InternalTexture): void;
  88024. /** @hidden */
  88025. _releaseTexture(texture: InternalTexture): void;
  88026. private setProgram;
  88027. private _boundUniforms;
  88028. /**
  88029. * Binds an effect to the webGL context
  88030. * @param effect defines the effect to bind
  88031. */
  88032. bindSamplers(effect: Effect): void;
  88033. private _activateCurrentTexture;
  88034. /** @hidden */
  88035. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  88036. /** @hidden */
  88037. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  88038. /**
  88039. * Sets a texture to the webGL context from a postprocess
  88040. * @param channel defines the channel to use
  88041. * @param postProcess defines the source postprocess
  88042. */
  88043. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  88044. /**
  88045. * Binds the output of the passed in post process to the texture channel specified
  88046. * @param channel The channel the texture should be bound to
  88047. * @param postProcess The post process which's output should be bound
  88048. */
  88049. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  88050. /**
  88051. * Unbind all textures from the webGL context
  88052. */
  88053. unbindAllTextures(): void;
  88054. /**
  88055. * Sets a texture to the according uniform.
  88056. * @param channel The texture channel
  88057. * @param uniform The uniform to set
  88058. * @param texture The texture to apply
  88059. */
  88060. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  88061. /**
  88062. * Sets a depth stencil texture from a render target to the according uniform.
  88063. * @param channel The texture channel
  88064. * @param uniform The uniform to set
  88065. * @param texture The render target texture containing the depth stencil texture to apply
  88066. */
  88067. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  88068. private _bindSamplerUniformToChannel;
  88069. private _getTextureWrapMode;
  88070. private _setTexture;
  88071. /**
  88072. * Sets an array of texture to the webGL context
  88073. * @param channel defines the channel where the texture array must be set
  88074. * @param uniform defines the associated uniform location
  88075. * @param textures defines the array of textures to bind
  88076. */
  88077. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  88078. /** @hidden */
  88079. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  88080. private _setTextureParameterFloat;
  88081. private _setTextureParameterInteger;
  88082. /**
  88083. * Reads pixels from the current frame buffer. Please note that this function can be slow
  88084. * @param x defines the x coordinate of the rectangle where pixels must be read
  88085. * @param y defines the y coordinate of the rectangle where pixels must be read
  88086. * @param width defines the width of the rectangle where pixels must be read
  88087. * @param height defines the height of the rectangle where pixels must be read
  88088. * @returns a Uint8Array containing RGBA colors
  88089. */
  88090. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  88091. /**
  88092. * Add an externaly attached data from its key.
  88093. * This method call will fail and return false, if such key already exists.
  88094. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88095. * @param key the unique key that identifies the data
  88096. * @param data the data object to associate to the key for this Engine instance
  88097. * @return true if no such key were already present and the data was added successfully, false otherwise
  88098. */
  88099. addExternalData<T>(key: string, data: T): boolean;
  88100. /**
  88101. * Get an externaly attached data from its key
  88102. * @param key the unique key that identifies the data
  88103. * @return the associated data, if present (can be null), or undefined if not present
  88104. */
  88105. getExternalData<T>(key: string): T;
  88106. /**
  88107. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88108. * @param key the unique key that identifies the data
  88109. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88110. * @return the associated data, can be null if the factory returned null.
  88111. */
  88112. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88113. /**
  88114. * Remove an externaly attached data from the Engine instance
  88115. * @param key the unique key that identifies the data
  88116. * @return true if the data was successfully removed, false if it doesn't exist
  88117. */
  88118. removeExternalData(key: string): boolean;
  88119. /**
  88120. * Unbind all vertex attributes from the webGL context
  88121. */
  88122. unbindAllAttributes(): void;
  88123. /**
  88124. * 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
  88125. */
  88126. releaseEffects(): void;
  88127. /**
  88128. * Dispose and release all associated resources
  88129. */
  88130. dispose(): void;
  88131. /**
  88132. * Display the loading screen
  88133. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88134. */
  88135. displayLoadingUI(): void;
  88136. /**
  88137. * Hide the loading screen
  88138. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88139. */
  88140. hideLoadingUI(): void;
  88141. /**
  88142. * Gets the current loading screen object
  88143. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88144. */
  88145. /**
  88146. * Sets the current loading screen object
  88147. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88148. */
  88149. loadingScreen: ILoadingScreen;
  88150. /**
  88151. * Sets the current loading screen text
  88152. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88153. */
  88154. loadingUIText: string;
  88155. /**
  88156. * Sets the current loading screen background color
  88157. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88158. */
  88159. loadingUIBackgroundColor: string;
  88160. /**
  88161. * Attach a new callback raised when context lost event is fired
  88162. * @param callback defines the callback to call
  88163. */
  88164. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88165. /**
  88166. * Attach a new callback raised when context restored event is fired
  88167. * @param callback defines the callback to call
  88168. */
  88169. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88170. /**
  88171. * Gets the source code of the vertex shader associated with a specific webGL program
  88172. * @param program defines the program to use
  88173. * @returns a string containing the source code of the vertex shader associated with the program
  88174. */
  88175. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  88176. /**
  88177. * Gets the source code of the fragment shader associated with a specific webGL program
  88178. * @param program defines the program to use
  88179. * @returns a string containing the source code of the fragment shader associated with the program
  88180. */
  88181. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  88182. /**
  88183. * Get the current error code of the webGL context
  88184. * @returns the error code
  88185. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  88186. */
  88187. getError(): number;
  88188. /**
  88189. * Gets the current framerate
  88190. * @returns a number representing the framerate
  88191. */
  88192. getFps(): number;
  88193. /**
  88194. * Gets the time spent between current and previous frame
  88195. * @returns a number representing the delta time in ms
  88196. */
  88197. getDeltaTime(): number;
  88198. private _measureFps;
  88199. /** @hidden */
  88200. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  88201. private _canRenderToFloatFramebuffer;
  88202. private _canRenderToHalfFloatFramebuffer;
  88203. private _canRenderToFramebuffer;
  88204. /** @hidden */
  88205. _getWebGLTextureType(type: number): number;
  88206. private _getInternalFormat;
  88207. /** @hidden */
  88208. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  88209. /** @hidden */
  88210. _getRGBAMultiSampleBufferFormat(type: number): number;
  88211. /** @hidden */
  88212. _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;
  88213. /** @hidden */
  88214. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  88215. private _partialLoadFile;
  88216. private _cascadeLoadFiles;
  88217. /**
  88218. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  88219. * @returns true if the engine can be created
  88220. * @ignorenaming
  88221. */
  88222. static isSupported(): boolean;
  88223. }
  88224. }
  88225. declare module BABYLON {
  88226. /**
  88227. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88228. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88229. */
  88230. export class EffectFallbacks {
  88231. private _defines;
  88232. private _currentRank;
  88233. private _maxRank;
  88234. private _mesh;
  88235. /**
  88236. * Removes the fallback from the bound mesh.
  88237. */
  88238. unBindMesh(): void;
  88239. /**
  88240. * Adds a fallback on the specified property.
  88241. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88242. * @param define The name of the define in the shader
  88243. */
  88244. addFallback(rank: number, define: string): void;
  88245. /**
  88246. * Sets the mesh to use CPU skinning when needing to fallback.
  88247. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88248. * @param mesh The mesh to use the fallbacks.
  88249. */
  88250. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88251. /**
  88252. * Checks to see if more fallbacks are still availible.
  88253. */
  88254. readonly isMoreFallbacks: boolean;
  88255. /**
  88256. * Removes the defines that shoould be removed when falling back.
  88257. * @param currentDefines defines the current define statements for the shader.
  88258. * @param effect defines the current effect we try to compile
  88259. * @returns The resulting defines with defines of the current rank removed.
  88260. */
  88261. reduce(currentDefines: string, effect: Effect): string;
  88262. }
  88263. /**
  88264. * Options to be used when creating an effect.
  88265. */
  88266. export class EffectCreationOptions {
  88267. /**
  88268. * Atrributes that will be used in the shader.
  88269. */
  88270. attributes: string[];
  88271. /**
  88272. * Uniform varible names that will be set in the shader.
  88273. */
  88274. uniformsNames: string[];
  88275. /**
  88276. * Uniform buffer varible names that will be set in the shader.
  88277. */
  88278. uniformBuffersNames: string[];
  88279. /**
  88280. * Sampler texture variable names that will be set in the shader.
  88281. */
  88282. samplers: string[];
  88283. /**
  88284. * Define statements that will be set in the shader.
  88285. */
  88286. defines: any;
  88287. /**
  88288. * Possible fallbacks for this effect to improve performance when needed.
  88289. */
  88290. fallbacks: Nullable<EffectFallbacks>;
  88291. /**
  88292. * Callback that will be called when the shader is compiled.
  88293. */
  88294. onCompiled: Nullable<(effect: Effect) => void>;
  88295. /**
  88296. * Callback that will be called if an error occurs during shader compilation.
  88297. */
  88298. onError: Nullable<(effect: Effect, errors: string) => void>;
  88299. /**
  88300. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88301. */
  88302. indexParameters: any;
  88303. /**
  88304. * Max number of lights that can be used in the shader.
  88305. */
  88306. maxSimultaneousLights: number;
  88307. /**
  88308. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  88309. */
  88310. transformFeedbackVaryings: Nullable<string[]>;
  88311. }
  88312. /**
  88313. * Effect containing vertex and fragment shader that can be executed on an object.
  88314. */
  88315. export class Effect {
  88316. /**
  88317. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  88318. */
  88319. static ShadersRepository: string;
  88320. /**
  88321. * Name of the effect.
  88322. */
  88323. name: any;
  88324. /**
  88325. * String container all the define statements that should be set on the shader.
  88326. */
  88327. defines: string;
  88328. /**
  88329. * Callback that will be called when the shader is compiled.
  88330. */
  88331. onCompiled: Nullable<(effect: Effect) => void>;
  88332. /**
  88333. * Callback that will be called if an error occurs during shader compilation.
  88334. */
  88335. onError: Nullable<(effect: Effect, errors: string) => void>;
  88336. /**
  88337. * Callback that will be called when effect is bound.
  88338. */
  88339. onBind: Nullable<(effect: Effect) => void>;
  88340. /**
  88341. * Unique ID of the effect.
  88342. */
  88343. uniqueId: number;
  88344. /**
  88345. * Observable that will be called when the shader is compiled.
  88346. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  88347. */
  88348. onCompileObservable: Observable<Effect>;
  88349. /**
  88350. * Observable that will be called if an error occurs during shader compilation.
  88351. */
  88352. onErrorObservable: Observable<Effect>;
  88353. /** @hidden */
  88354. _onBindObservable: Nullable<Observable<Effect>>;
  88355. /**
  88356. * Observable that will be called when effect is bound.
  88357. */
  88358. readonly onBindObservable: Observable<Effect>;
  88359. /** @hidden */
  88360. _bonesComputationForcedToCPU: boolean;
  88361. private static _uniqueIdSeed;
  88362. private _engine;
  88363. private _uniformBuffersNames;
  88364. private _uniformsNames;
  88365. private _samplers;
  88366. private _isReady;
  88367. private _compilationError;
  88368. private _attributesNames;
  88369. private _attributes;
  88370. private _uniforms;
  88371. /**
  88372. * Key for the effect.
  88373. * @hidden
  88374. */
  88375. _key: string;
  88376. private _indexParameters;
  88377. private _fallbacks;
  88378. private _vertexSourceCode;
  88379. private _fragmentSourceCode;
  88380. private _vertexSourceCodeOverride;
  88381. private _fragmentSourceCodeOverride;
  88382. private _transformFeedbackVaryings;
  88383. /**
  88384. * Compiled shader to webGL program.
  88385. * @hidden
  88386. */
  88387. _program: WebGLProgram;
  88388. private _valueCache;
  88389. private static _baseCache;
  88390. /**
  88391. * Instantiates an effect.
  88392. * An effect can be used to create/manage/execute vertex and fragment shaders.
  88393. * @param baseName Name of the effect.
  88394. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  88395. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  88396. * @param samplers List of sampler variables that will be passed to the shader.
  88397. * @param engine Engine to be used to render the effect
  88398. * @param defines Define statements to be added to the shader.
  88399. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  88400. * @param onCompiled Callback that will be called when the shader is compiled.
  88401. * @param onError Callback that will be called if an error occurs during shader compilation.
  88402. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88403. */
  88404. 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);
  88405. /**
  88406. * Unique key for this effect
  88407. */
  88408. readonly key: string;
  88409. /**
  88410. * If the effect has been compiled and prepared.
  88411. * @returns if the effect is compiled and prepared.
  88412. */
  88413. isReady(): boolean;
  88414. /**
  88415. * The engine the effect was initialized with.
  88416. * @returns the engine.
  88417. */
  88418. getEngine(): Engine;
  88419. /**
  88420. * The compiled webGL program for the effect
  88421. * @returns the webGL program.
  88422. */
  88423. getProgram(): WebGLProgram;
  88424. /**
  88425. * The set of names of attribute variables for the shader.
  88426. * @returns An array of attribute names.
  88427. */
  88428. getAttributesNames(): string[];
  88429. /**
  88430. * Returns the attribute at the given index.
  88431. * @param index The index of the attribute.
  88432. * @returns The location of the attribute.
  88433. */
  88434. getAttributeLocation(index: number): number;
  88435. /**
  88436. * Returns the attribute based on the name of the variable.
  88437. * @param name of the attribute to look up.
  88438. * @returns the attribute location.
  88439. */
  88440. getAttributeLocationByName(name: string): number;
  88441. /**
  88442. * The number of attributes.
  88443. * @returns the numnber of attributes.
  88444. */
  88445. getAttributesCount(): number;
  88446. /**
  88447. * Gets the index of a uniform variable.
  88448. * @param uniformName of the uniform to look up.
  88449. * @returns the index.
  88450. */
  88451. getUniformIndex(uniformName: string): number;
  88452. /**
  88453. * Returns the attribute based on the name of the variable.
  88454. * @param uniformName of the uniform to look up.
  88455. * @returns the location of the uniform.
  88456. */
  88457. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  88458. /**
  88459. * Returns an array of sampler variable names
  88460. * @returns The array of sampler variable neames.
  88461. */
  88462. getSamplers(): string[];
  88463. /**
  88464. * The error from the last compilation.
  88465. * @returns the error string.
  88466. */
  88467. getCompilationError(): string;
  88468. /**
  88469. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  88470. * @param func The callback to be used.
  88471. */
  88472. executeWhenCompiled(func: (effect: Effect) => void): void;
  88473. private _checkIsReady;
  88474. /** @hidden */
  88475. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  88476. /** @hidden */
  88477. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  88478. /** @hidden */
  88479. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  88480. private _processShaderConversion;
  88481. private _processIncludes;
  88482. private _processPrecision;
  88483. /**
  88484. * Recompiles the webGL program
  88485. * @param vertexSourceCode The source code for the vertex shader.
  88486. * @param fragmentSourceCode The source code for the fragment shader.
  88487. * @param onCompiled Callback called when completed.
  88488. * @param onError Callback called on error.
  88489. * @hidden
  88490. */
  88491. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  88492. /**
  88493. * Gets the uniform locations of the the specified variable names
  88494. * @param names THe names of the variables to lookup.
  88495. * @returns Array of locations in the same order as variable names.
  88496. */
  88497. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  88498. /**
  88499. * Prepares the effect
  88500. * @hidden
  88501. */
  88502. _prepareEffect(): void;
  88503. /**
  88504. * Checks if the effect is supported. (Must be called after compilation)
  88505. */
  88506. readonly isSupported: boolean;
  88507. /**
  88508. * Binds a texture to the engine to be used as output of the shader.
  88509. * @param channel Name of the output variable.
  88510. * @param texture Texture to bind.
  88511. * @hidden
  88512. */
  88513. _bindTexture(channel: string, texture: InternalTexture): void;
  88514. /**
  88515. * Sets a texture on the engine to be used in the shader.
  88516. * @param channel Name of the sampler variable.
  88517. * @param texture Texture to set.
  88518. */
  88519. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  88520. /**
  88521. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  88522. * @param channel Name of the sampler variable.
  88523. * @param texture Texture to set.
  88524. */
  88525. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  88526. /**
  88527. * Sets an array of textures on the engine to be used in the shader.
  88528. * @param channel Name of the variable.
  88529. * @param textures Textures to set.
  88530. */
  88531. setTextureArray(channel: string, textures: BaseTexture[]): void;
  88532. /**
  88533. * 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)
  88534. * @param channel Name of the sampler variable.
  88535. * @param postProcess Post process to get the input texture from.
  88536. */
  88537. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  88538. /**
  88539. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  88540. * 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)
  88541. * @param channel Name of the sampler variable.
  88542. * @param postProcess Post process to get the output texture from.
  88543. */
  88544. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  88545. /** @hidden */
  88546. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  88547. /** @hidden */
  88548. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  88549. /** @hidden */
  88550. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  88551. /** @hidden */
  88552. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  88553. /**
  88554. * Binds a buffer to a uniform.
  88555. * @param buffer Buffer to bind.
  88556. * @param name Name of the uniform variable to bind to.
  88557. */
  88558. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  88559. /**
  88560. * Binds block to a uniform.
  88561. * @param blockName Name of the block to bind.
  88562. * @param index Index to bind.
  88563. */
  88564. bindUniformBlock(blockName: string, index: number): void;
  88565. /**
  88566. * Sets an interger value on a uniform variable.
  88567. * @param uniformName Name of the variable.
  88568. * @param value Value to be set.
  88569. * @returns this effect.
  88570. */
  88571. setInt(uniformName: string, value: number): Effect;
  88572. /**
  88573. * Sets an int array on a uniform variable.
  88574. * @param uniformName Name of the variable.
  88575. * @param array array to be set.
  88576. * @returns this effect.
  88577. */
  88578. setIntArray(uniformName: string, array: Int32Array): Effect;
  88579. /**
  88580. * 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)
  88581. * @param uniformName Name of the variable.
  88582. * @param array array to be set.
  88583. * @returns this effect.
  88584. */
  88585. setIntArray2(uniformName: string, array: Int32Array): Effect;
  88586. /**
  88587. * 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)
  88588. * @param uniformName Name of the variable.
  88589. * @param array array to be set.
  88590. * @returns this effect.
  88591. */
  88592. setIntArray3(uniformName: string, array: Int32Array): Effect;
  88593. /**
  88594. * 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)
  88595. * @param uniformName Name of the variable.
  88596. * @param array array to be set.
  88597. * @returns this effect.
  88598. */
  88599. setIntArray4(uniformName: string, array: Int32Array): Effect;
  88600. /**
  88601. * Sets an float array on a uniform variable.
  88602. * @param uniformName Name of the variable.
  88603. * @param array array to be set.
  88604. * @returns this effect.
  88605. */
  88606. setFloatArray(uniformName: string, array: Float32Array): Effect;
  88607. /**
  88608. * 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)
  88609. * @param uniformName Name of the variable.
  88610. * @param array array to be set.
  88611. * @returns this effect.
  88612. */
  88613. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  88614. /**
  88615. * 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)
  88616. * @param uniformName Name of the variable.
  88617. * @param array array to be set.
  88618. * @returns this effect.
  88619. */
  88620. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  88621. /**
  88622. * 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)
  88623. * @param uniformName Name of the variable.
  88624. * @param array array to be set.
  88625. * @returns this effect.
  88626. */
  88627. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  88628. /**
  88629. * Sets an array on a uniform variable.
  88630. * @param uniformName Name of the variable.
  88631. * @param array array to be set.
  88632. * @returns this effect.
  88633. */
  88634. setArray(uniformName: string, array: number[]): Effect;
  88635. /**
  88636. * 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)
  88637. * @param uniformName Name of the variable.
  88638. * @param array array to be set.
  88639. * @returns this effect.
  88640. */
  88641. setArray2(uniformName: string, array: number[]): Effect;
  88642. /**
  88643. * 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)
  88644. * @param uniformName Name of the variable.
  88645. * @param array array to be set.
  88646. * @returns this effect.
  88647. */
  88648. setArray3(uniformName: string, array: number[]): Effect;
  88649. /**
  88650. * 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)
  88651. * @param uniformName Name of the variable.
  88652. * @param array array to be set.
  88653. * @returns this effect.
  88654. */
  88655. setArray4(uniformName: string, array: number[]): Effect;
  88656. /**
  88657. * Sets matrices on a uniform variable.
  88658. * @param uniformName Name of the variable.
  88659. * @param matrices matrices to be set.
  88660. * @returns this effect.
  88661. */
  88662. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  88663. /**
  88664. * Sets matrix on a uniform variable.
  88665. * @param uniformName Name of the variable.
  88666. * @param matrix matrix to be set.
  88667. * @returns this effect.
  88668. */
  88669. setMatrix(uniformName: string, matrix: Matrix): Effect;
  88670. /**
  88671. * 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)
  88672. * @param uniformName Name of the variable.
  88673. * @param matrix matrix to be set.
  88674. * @returns this effect.
  88675. */
  88676. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  88677. /**
  88678. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  88679. * @param uniformName Name of the variable.
  88680. * @param matrix matrix to be set.
  88681. * @returns this effect.
  88682. */
  88683. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  88684. /**
  88685. * Sets a float on a uniform variable.
  88686. * @param uniformName Name of the variable.
  88687. * @param value value to be set.
  88688. * @returns this effect.
  88689. */
  88690. setFloat(uniformName: string, value: number): Effect;
  88691. /**
  88692. * Sets a boolean on a uniform variable.
  88693. * @param uniformName Name of the variable.
  88694. * @param bool value to be set.
  88695. * @returns this effect.
  88696. */
  88697. setBool(uniformName: string, bool: boolean): Effect;
  88698. /**
  88699. * Sets a Vector2 on a uniform variable.
  88700. * @param uniformName Name of the variable.
  88701. * @param vector2 vector2 to be set.
  88702. * @returns this effect.
  88703. */
  88704. setVector2(uniformName: string, vector2: Vector2): Effect;
  88705. /**
  88706. * Sets a float2 on a uniform variable.
  88707. * @param uniformName Name of the variable.
  88708. * @param x First float in float2.
  88709. * @param y Second float in float2.
  88710. * @returns this effect.
  88711. */
  88712. setFloat2(uniformName: string, x: number, y: number): Effect;
  88713. /**
  88714. * Sets a Vector3 on a uniform variable.
  88715. * @param uniformName Name of the variable.
  88716. * @param vector3 Value to be set.
  88717. * @returns this effect.
  88718. */
  88719. setVector3(uniformName: string, vector3: Vector3): Effect;
  88720. /**
  88721. * Sets a float3 on a uniform variable.
  88722. * @param uniformName Name of the variable.
  88723. * @param x First float in float3.
  88724. * @param y Second float in float3.
  88725. * @param z Third float in float3.
  88726. * @returns this effect.
  88727. */
  88728. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  88729. /**
  88730. * Sets a Vector4 on a uniform variable.
  88731. * @param uniformName Name of the variable.
  88732. * @param vector4 Value to be set.
  88733. * @returns this effect.
  88734. */
  88735. setVector4(uniformName: string, vector4: Vector4): Effect;
  88736. /**
  88737. * Sets a float4 on a uniform variable.
  88738. * @param uniformName Name of the variable.
  88739. * @param x First float in float4.
  88740. * @param y Second float in float4.
  88741. * @param z Third float in float4.
  88742. * @param w Fourth float in float4.
  88743. * @returns this effect.
  88744. */
  88745. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  88746. /**
  88747. * Sets a Color3 on a uniform variable.
  88748. * @param uniformName Name of the variable.
  88749. * @param color3 Value to be set.
  88750. * @returns this effect.
  88751. */
  88752. setColor3(uniformName: string, color3: Color3): Effect;
  88753. /**
  88754. * Sets a Color4 on a uniform variable.
  88755. * @param uniformName Name of the variable.
  88756. * @param color3 Value to be set.
  88757. * @param alpha Alpha value to be set.
  88758. * @returns this effect.
  88759. */
  88760. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  88761. /**
  88762. * Sets a Color4 on a uniform variable
  88763. * @param uniformName defines the name of the variable
  88764. * @param color4 defines the value to be set
  88765. * @returns this effect.
  88766. */
  88767. setDirectColor4(uniformName: string, color4: Color4): Effect;
  88768. /**
  88769. * This function will add a new shader to the shader store
  88770. * @param name the name of the shader
  88771. * @param pixelShader optional pixel shader content
  88772. * @param vertexShader optional vertex shader content
  88773. */
  88774. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  88775. /**
  88776. * Store of each shader (The can be looked up using effect.key)
  88777. */
  88778. static ShadersStore: {
  88779. [key: string]: string;
  88780. };
  88781. /**
  88782. * Store of each included file for a shader (The can be looked up using effect.key)
  88783. */
  88784. static IncludesShadersStore: {
  88785. [key: string]: string;
  88786. };
  88787. /**
  88788. * Resets the cache of effects.
  88789. */
  88790. static ResetCache(): void;
  88791. }
  88792. }
  88793. declare module BABYLON {
  88794. /**
  88795. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88796. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88797. * 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;
  88798. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88799. */
  88800. export class ColorCurves {
  88801. private _dirty;
  88802. private _tempColor;
  88803. private _globalCurve;
  88804. private _highlightsCurve;
  88805. private _midtonesCurve;
  88806. private _shadowsCurve;
  88807. private _positiveCurve;
  88808. private _negativeCurve;
  88809. private _globalHue;
  88810. private _globalDensity;
  88811. private _globalSaturation;
  88812. private _globalExposure;
  88813. /**
  88814. * Gets the global Hue value.
  88815. * 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).
  88816. */
  88817. /**
  88818. * Sets the global Hue value.
  88819. * 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).
  88820. */
  88821. globalHue: number;
  88822. /**
  88823. * Gets the global Density value.
  88824. * 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.
  88825. * Values less than zero provide a filter of opposite hue.
  88826. */
  88827. /**
  88828. * Sets the global Density value.
  88829. * 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.
  88830. * Values less than zero provide a filter of opposite hue.
  88831. */
  88832. globalDensity: number;
  88833. /**
  88834. * Gets the global Saturation value.
  88835. * 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.
  88836. */
  88837. /**
  88838. * Sets the global Saturation value.
  88839. * 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.
  88840. */
  88841. globalSaturation: number;
  88842. /**
  88843. * Gets the global Exposure value.
  88844. * 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.
  88845. */
  88846. /**
  88847. * Sets the global Exposure value.
  88848. * 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.
  88849. */
  88850. globalExposure: number;
  88851. private _highlightsHue;
  88852. private _highlightsDensity;
  88853. private _highlightsSaturation;
  88854. private _highlightsExposure;
  88855. /**
  88856. * Gets the highlights Hue value.
  88857. * 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).
  88858. */
  88859. /**
  88860. * Sets the highlights Hue value.
  88861. * 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).
  88862. */
  88863. highlightsHue: number;
  88864. /**
  88865. * Gets the highlights Density value.
  88866. * 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.
  88867. * Values less than zero provide a filter of opposite hue.
  88868. */
  88869. /**
  88870. * Sets the highlights Density value.
  88871. * 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.
  88872. * Values less than zero provide a filter of opposite hue.
  88873. */
  88874. highlightsDensity: number;
  88875. /**
  88876. * Gets the highlights Saturation value.
  88877. * 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.
  88878. */
  88879. /**
  88880. * Sets the highlights Saturation value.
  88881. * 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.
  88882. */
  88883. highlightsSaturation: number;
  88884. /**
  88885. * Gets the highlights Exposure value.
  88886. * 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.
  88887. */
  88888. /**
  88889. * Sets the highlights Exposure value.
  88890. * 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.
  88891. */
  88892. highlightsExposure: number;
  88893. private _midtonesHue;
  88894. private _midtonesDensity;
  88895. private _midtonesSaturation;
  88896. private _midtonesExposure;
  88897. /**
  88898. * Gets the midtones Hue value.
  88899. * 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).
  88900. */
  88901. /**
  88902. * Sets the midtones Hue value.
  88903. * 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).
  88904. */
  88905. midtonesHue: number;
  88906. /**
  88907. * Gets the midtones Density value.
  88908. * 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.
  88909. * Values less than zero provide a filter of opposite hue.
  88910. */
  88911. /**
  88912. * Sets the midtones Density value.
  88913. * 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.
  88914. * Values less than zero provide a filter of opposite hue.
  88915. */
  88916. midtonesDensity: number;
  88917. /**
  88918. * Gets the midtones Saturation value.
  88919. * 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.
  88920. */
  88921. /**
  88922. * Sets the midtones Saturation value.
  88923. * 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.
  88924. */
  88925. midtonesSaturation: number;
  88926. /**
  88927. * Gets the midtones Exposure value.
  88928. * 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.
  88929. */
  88930. /**
  88931. * Sets the midtones Exposure value.
  88932. * 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.
  88933. */
  88934. midtonesExposure: number;
  88935. private _shadowsHue;
  88936. private _shadowsDensity;
  88937. private _shadowsSaturation;
  88938. private _shadowsExposure;
  88939. /**
  88940. * Gets the shadows Hue value.
  88941. * 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).
  88942. */
  88943. /**
  88944. * Sets the shadows Hue value.
  88945. * 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).
  88946. */
  88947. shadowsHue: number;
  88948. /**
  88949. * Gets the shadows Density value.
  88950. * 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.
  88951. * Values less than zero provide a filter of opposite hue.
  88952. */
  88953. /**
  88954. * Sets the shadows Density value.
  88955. * 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.
  88956. * Values less than zero provide a filter of opposite hue.
  88957. */
  88958. shadowsDensity: number;
  88959. /**
  88960. * Gets the shadows Saturation value.
  88961. * 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.
  88962. */
  88963. /**
  88964. * Sets the shadows Saturation value.
  88965. * 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.
  88966. */
  88967. shadowsSaturation: number;
  88968. /**
  88969. * Gets the shadows Exposure value.
  88970. * 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.
  88971. */
  88972. /**
  88973. * Sets the shadows Exposure value.
  88974. * 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.
  88975. */
  88976. shadowsExposure: number;
  88977. /**
  88978. * Returns the class name
  88979. * @returns The class name
  88980. */
  88981. getClassName(): string;
  88982. /**
  88983. * Binds the color curves to the shader.
  88984. * @param colorCurves The color curve to bind
  88985. * @param effect The effect to bind to
  88986. * @param positiveUniform The positive uniform shader parameter
  88987. * @param neutralUniform The neutral uniform shader parameter
  88988. * @param negativeUniform The negative uniform shader parameter
  88989. */
  88990. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88991. /**
  88992. * Prepare the list of uniforms associated with the ColorCurves effects.
  88993. * @param uniformsList The list of uniforms used in the effect
  88994. */
  88995. static PrepareUniforms(uniformsList: string[]): void;
  88996. /**
  88997. * Returns color grading data based on a hue, density, saturation and exposure value.
  88998. * @param filterHue The hue of the color filter.
  88999. * @param filterDensity The density of the color filter.
  89000. * @param saturation The saturation.
  89001. * @param exposure The exposure.
  89002. * @param result The result data container.
  89003. */
  89004. private getColorGradingDataToRef;
  89005. /**
  89006. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89007. * @param value The input slider value in range [-100,100].
  89008. * @returns Adjusted value.
  89009. */
  89010. private static applyColorGradingSliderNonlinear;
  89011. /**
  89012. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89013. * @param hue The hue (H) input.
  89014. * @param saturation The saturation (S) input.
  89015. * @param brightness The brightness (B) input.
  89016. * @result An RGBA color represented as Vector4.
  89017. */
  89018. private static fromHSBToRef;
  89019. /**
  89020. * Returns a value clamped between min and max
  89021. * @param value The value to clamp
  89022. * @param min The minimum of value
  89023. * @param max The maximum of value
  89024. * @returns The clamped value.
  89025. */
  89026. private static clamp;
  89027. /**
  89028. * Clones the current color curve instance.
  89029. * @return The cloned curves
  89030. */
  89031. clone(): ColorCurves;
  89032. /**
  89033. * Serializes the current color curve instance to a json representation.
  89034. * @return a JSON representation
  89035. */
  89036. serialize(): any;
  89037. /**
  89038. * Parses the color curve from a json representation.
  89039. * @param source the JSON source to parse
  89040. * @return The parsed curves
  89041. */
  89042. static Parse(source: any): ColorCurves;
  89043. }
  89044. }
  89045. declare module BABYLON {
  89046. /**
  89047. * Interface to follow in your material defines to integrate easily the
  89048. * Image proccessing functions.
  89049. * @hidden
  89050. */
  89051. export interface IImageProcessingConfigurationDefines {
  89052. IMAGEPROCESSING: boolean;
  89053. VIGNETTE: boolean;
  89054. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89055. VIGNETTEBLENDMODEOPAQUE: boolean;
  89056. TONEMAPPING: boolean;
  89057. TONEMAPPING_ACES: boolean;
  89058. CONTRAST: boolean;
  89059. EXPOSURE: boolean;
  89060. COLORCURVES: boolean;
  89061. COLORGRADING: boolean;
  89062. COLORGRADING3D: boolean;
  89063. SAMPLER3DGREENDEPTH: boolean;
  89064. SAMPLER3DBGRMAP: boolean;
  89065. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89066. }
  89067. /**
  89068. * @hidden
  89069. */
  89070. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89071. IMAGEPROCESSING: boolean;
  89072. VIGNETTE: boolean;
  89073. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89074. VIGNETTEBLENDMODEOPAQUE: boolean;
  89075. TONEMAPPING: boolean;
  89076. TONEMAPPING_ACES: boolean;
  89077. CONTRAST: boolean;
  89078. COLORCURVES: boolean;
  89079. COLORGRADING: boolean;
  89080. COLORGRADING3D: boolean;
  89081. SAMPLER3DGREENDEPTH: boolean;
  89082. SAMPLER3DBGRMAP: boolean;
  89083. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89084. EXPOSURE: boolean;
  89085. constructor();
  89086. }
  89087. /**
  89088. * This groups together the common properties used for image processing either in direct forward pass
  89089. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89090. * or not.
  89091. */
  89092. export class ImageProcessingConfiguration {
  89093. /**
  89094. * Default tone mapping applied in BabylonJS.
  89095. */
  89096. static readonly TONEMAPPING_STANDARD: number;
  89097. /**
  89098. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89099. * to other engines rendering to increase portability.
  89100. */
  89101. static readonly TONEMAPPING_ACES: number;
  89102. /**
  89103. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89104. */
  89105. colorCurves: Nullable<ColorCurves>;
  89106. private _colorCurvesEnabled;
  89107. /**
  89108. * Gets wether the color curves effect is enabled.
  89109. */
  89110. /**
  89111. * Sets wether the color curves effect is enabled.
  89112. */
  89113. colorCurvesEnabled: boolean;
  89114. private _colorGradingTexture;
  89115. /**
  89116. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89117. */
  89118. /**
  89119. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89120. */
  89121. colorGradingTexture: Nullable<BaseTexture>;
  89122. private _colorGradingEnabled;
  89123. /**
  89124. * Gets wether the color grading effect is enabled.
  89125. */
  89126. /**
  89127. * Sets wether the color grading effect is enabled.
  89128. */
  89129. colorGradingEnabled: boolean;
  89130. private _colorGradingWithGreenDepth;
  89131. /**
  89132. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89133. */
  89134. /**
  89135. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89136. */
  89137. colorGradingWithGreenDepth: boolean;
  89138. private _colorGradingBGR;
  89139. /**
  89140. * Gets wether the color grading texture contains BGR values.
  89141. */
  89142. /**
  89143. * Sets wether the color grading texture contains BGR values.
  89144. */
  89145. colorGradingBGR: boolean;
  89146. /** @hidden */
  89147. _exposure: number;
  89148. /**
  89149. * Gets the Exposure used in the effect.
  89150. */
  89151. /**
  89152. * Sets the Exposure used in the effect.
  89153. */
  89154. exposure: number;
  89155. private _toneMappingEnabled;
  89156. /**
  89157. * Gets wether the tone mapping effect is enabled.
  89158. */
  89159. /**
  89160. * Sets wether the tone mapping effect is enabled.
  89161. */
  89162. toneMappingEnabled: boolean;
  89163. private _toneMappingType;
  89164. /**
  89165. * Gets the type of tone mapping effect.
  89166. */
  89167. /**
  89168. * Sets the type of tone mapping effect used in BabylonJS.
  89169. */
  89170. toneMappingType: number;
  89171. protected _contrast: number;
  89172. /**
  89173. * Gets the contrast used in the effect.
  89174. */
  89175. /**
  89176. * Sets the contrast used in the effect.
  89177. */
  89178. contrast: number;
  89179. /**
  89180. * Vignette stretch size.
  89181. */
  89182. vignetteStretch: number;
  89183. /**
  89184. * Vignette centre X Offset.
  89185. */
  89186. vignetteCentreX: number;
  89187. /**
  89188. * Vignette centre Y Offset.
  89189. */
  89190. vignetteCentreY: number;
  89191. /**
  89192. * Vignette weight or intensity of the vignette effect.
  89193. */
  89194. vignetteWeight: number;
  89195. /**
  89196. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89197. * if vignetteEnabled is set to true.
  89198. */
  89199. vignetteColor: Color4;
  89200. /**
  89201. * Camera field of view used by the Vignette effect.
  89202. */
  89203. vignetteCameraFov: number;
  89204. private _vignetteBlendMode;
  89205. /**
  89206. * Gets the vignette blend mode allowing different kind of effect.
  89207. */
  89208. /**
  89209. * Sets the vignette blend mode allowing different kind of effect.
  89210. */
  89211. vignetteBlendMode: number;
  89212. private _vignetteEnabled;
  89213. /**
  89214. * Gets wether the vignette effect is enabled.
  89215. */
  89216. /**
  89217. * Sets wether the vignette effect is enabled.
  89218. */
  89219. vignetteEnabled: boolean;
  89220. private _applyByPostProcess;
  89221. /**
  89222. * Gets wether the image processing is applied through a post process or not.
  89223. */
  89224. /**
  89225. * Sets wether the image processing is applied through a post process or not.
  89226. */
  89227. applyByPostProcess: boolean;
  89228. private _isEnabled;
  89229. /**
  89230. * Gets wether the image processing is enabled or not.
  89231. */
  89232. /**
  89233. * Sets wether the image processing is enabled or not.
  89234. */
  89235. isEnabled: boolean;
  89236. /**
  89237. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89238. */
  89239. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89240. /**
  89241. * Method called each time the image processing information changes requires to recompile the effect.
  89242. */
  89243. protected _updateParameters(): void;
  89244. /**
  89245. * Gets the current class name.
  89246. * @return "ImageProcessingConfiguration"
  89247. */
  89248. getClassName(): string;
  89249. /**
  89250. * Prepare the list of uniforms associated with the Image Processing effects.
  89251. * @param uniforms The list of uniforms used in the effect
  89252. * @param defines the list of defines currently in use
  89253. */
  89254. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89255. /**
  89256. * Prepare the list of samplers associated with the Image Processing effects.
  89257. * @param samplersList The list of uniforms used in the effect
  89258. * @param defines the list of defines currently in use
  89259. */
  89260. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89261. /**
  89262. * Prepare the list of defines associated to the shader.
  89263. * @param defines the list of defines to complete
  89264. * @param forPostProcess Define if we are currently in post process mode or not
  89265. */
  89266. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89267. /**
  89268. * Returns true if all the image processing information are ready.
  89269. * @returns True if ready, otherwise, false
  89270. */
  89271. isReady(): boolean;
  89272. /**
  89273. * Binds the image processing to the shader.
  89274. * @param effect The effect to bind to
  89275. * @param aspectRatio Define the current aspect ratio of the effect
  89276. */
  89277. bind(effect: Effect, aspectRatio?: number): void;
  89278. /**
  89279. * Clones the current image processing instance.
  89280. * @return The cloned image processing
  89281. */
  89282. clone(): ImageProcessingConfiguration;
  89283. /**
  89284. * Serializes the current image processing instance to a json representation.
  89285. * @return a JSON representation
  89286. */
  89287. serialize(): any;
  89288. /**
  89289. * Parses the image processing from a json representation.
  89290. * @param source the JSON source to parse
  89291. * @return The parsed image processing
  89292. */
  89293. static Parse(source: any): ImageProcessingConfiguration;
  89294. private static _VIGNETTEMODE_MULTIPLY;
  89295. private static _VIGNETTEMODE_OPAQUE;
  89296. /**
  89297. * Used to apply the vignette as a mix with the pixel color.
  89298. */
  89299. static readonly VIGNETTEMODE_MULTIPLY: number;
  89300. /**
  89301. * Used to apply the vignette as a replacement of the pixel color.
  89302. */
  89303. static readonly VIGNETTEMODE_OPAQUE: number;
  89304. }
  89305. }
  89306. declare module BABYLON {
  89307. /**
  89308. * This represents all the required information to add a fresnel effect on a material:
  89309. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  89310. */
  89311. export class FresnelParameters {
  89312. private _isEnabled;
  89313. /**
  89314. * Define if the fresnel effect is enable or not.
  89315. */
  89316. isEnabled: boolean;
  89317. /**
  89318. * Define the color used on edges (grazing angle)
  89319. */
  89320. leftColor: Color3;
  89321. /**
  89322. * Define the color used on center
  89323. */
  89324. rightColor: Color3;
  89325. /**
  89326. * Define bias applied to computed fresnel term
  89327. */
  89328. bias: number;
  89329. /**
  89330. * Defined the power exponent applied to fresnel term
  89331. */
  89332. power: number;
  89333. /**
  89334. * Clones the current fresnel and its valuues
  89335. * @returns a clone fresnel configuration
  89336. */
  89337. clone(): FresnelParameters;
  89338. /**
  89339. * Serializes the current fresnel parameters to a JSON representation.
  89340. * @return the JSON serialization
  89341. */
  89342. serialize(): any;
  89343. /**
  89344. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  89345. * @param parsedFresnelParameters Define the JSON representation
  89346. * @returns the parsed parameters
  89347. */
  89348. static Parse(parsedFresnelParameters: any): FresnelParameters;
  89349. }
  89350. }
  89351. declare module BABYLON {
  89352. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  89353. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89354. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89355. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89356. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89357. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89358. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89359. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89360. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89361. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89362. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89363. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89364. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89365. /**
  89366. * Decorator used to define property that can be serialized as reference to a camera
  89367. * @param sourceName defines the name of the property to decorate
  89368. */
  89369. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89370. /**
  89371. * Class used to help serialization objects
  89372. */
  89373. export class SerializationHelper {
  89374. /** hidden */
  89375. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  89376. /** hidden */
  89377. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  89378. /** hidden */
  89379. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  89380. /** hidden */
  89381. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  89382. /**
  89383. * Appends the serialized animations from the source animations
  89384. * @param source Source containing the animations
  89385. * @param destination Target to store the animations
  89386. */
  89387. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  89388. /**
  89389. * Static function used to serialized a specific entity
  89390. * @param entity defines the entity to serialize
  89391. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  89392. * @returns a JSON compatible object representing the serialization of the entity
  89393. */
  89394. static Serialize<T>(entity: T, serializationObject?: any): any;
  89395. /**
  89396. * Creates a new entity from a serialization data object
  89397. * @param creationFunction defines a function used to instanciated the new entity
  89398. * @param source defines the source serialization data
  89399. * @param scene defines the hosting scene
  89400. * @param rootUrl defines the root url for resources
  89401. * @returns a new entity
  89402. */
  89403. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  89404. /**
  89405. * Clones an object
  89406. * @param creationFunction defines the function used to instanciate the new object
  89407. * @param source defines the source object
  89408. * @returns the cloned object
  89409. */
  89410. static Clone<T>(creationFunction: () => T, source: T): T;
  89411. /**
  89412. * Instanciates a new object based on a source one (some data will be shared between both object)
  89413. * @param creationFunction defines the function used to instanciate the new object
  89414. * @param source defines the source object
  89415. * @returns the new object
  89416. */
  89417. static Instanciate<T>(creationFunction: () => T, source: T): T;
  89418. }
  89419. }
  89420. declare module BABYLON {
  89421. /**
  89422. * This is the base class of all the camera used in the application.
  89423. * @see http://doc.babylonjs.com/features/cameras
  89424. */
  89425. export class Camera extends Node {
  89426. /** @hidden */
  89427. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  89428. /**
  89429. * This is the default projection mode used by the cameras.
  89430. * It helps recreating a feeling of perspective and better appreciate depth.
  89431. * This is the best way to simulate real life cameras.
  89432. */
  89433. static readonly PERSPECTIVE_CAMERA: number;
  89434. /**
  89435. * This helps creating camera with an orthographic mode.
  89436. * 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.
  89437. */
  89438. static readonly ORTHOGRAPHIC_CAMERA: number;
  89439. /**
  89440. * This is the default FOV mode for perspective cameras.
  89441. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  89442. */
  89443. static readonly FOVMODE_VERTICAL_FIXED: number;
  89444. /**
  89445. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  89446. */
  89447. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  89448. /**
  89449. * This specifies ther is no need for a camera rig.
  89450. * Basically only one eye is rendered corresponding to the camera.
  89451. */
  89452. static readonly RIG_MODE_NONE: number;
  89453. /**
  89454. * Simulates a camera Rig with one blue eye and one red eye.
  89455. * This can be use with 3d blue and red glasses.
  89456. */
  89457. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  89458. /**
  89459. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  89460. */
  89461. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  89462. /**
  89463. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  89464. */
  89465. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  89466. /**
  89467. * Defines that both eyes of the camera will be rendered over under each other.
  89468. */
  89469. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  89470. /**
  89471. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  89472. */
  89473. static readonly RIG_MODE_VR: number;
  89474. /**
  89475. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  89476. */
  89477. static readonly RIG_MODE_WEBVR: number;
  89478. /**
  89479. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  89480. */
  89481. static readonly RIG_MODE_CUSTOM: number;
  89482. /**
  89483. * Defines if by default attaching controls should prevent the default javascript event to continue.
  89484. */
  89485. static ForceAttachControlToAlwaysPreventDefault: boolean;
  89486. /**
  89487. * Define the input manager associated with the camera.
  89488. */
  89489. inputs: CameraInputsManager<Camera>;
  89490. /** @hidden */
  89491. _position: Vector3;
  89492. /**
  89493. * Define the current local position of the camera in the scene
  89494. */
  89495. position: Vector3;
  89496. /**
  89497. * The vector the camera should consider as up.
  89498. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  89499. */
  89500. upVector: Vector3;
  89501. /**
  89502. * Define the current limit on the left side for an orthographic camera
  89503. * In scene unit
  89504. */
  89505. orthoLeft: Nullable<number>;
  89506. /**
  89507. * Define the current limit on the right side for an orthographic camera
  89508. * In scene unit
  89509. */
  89510. orthoRight: Nullable<number>;
  89511. /**
  89512. * Define the current limit on the bottom side for an orthographic camera
  89513. * In scene unit
  89514. */
  89515. orthoBottom: Nullable<number>;
  89516. /**
  89517. * Define the current limit on the top side for an orthographic camera
  89518. * In scene unit
  89519. */
  89520. orthoTop: Nullable<number>;
  89521. /**
  89522. * Field Of View is set in Radians. (default is 0.8)
  89523. */
  89524. fov: number;
  89525. /**
  89526. * Define the minimum distance the camera can see from.
  89527. * This is important to note that the depth buffer are not infinite and the closer it starts
  89528. * the more your scene might encounter depth fighting issue.
  89529. */
  89530. minZ: number;
  89531. /**
  89532. * Define the maximum distance the camera can see to.
  89533. * This is important to note that the depth buffer are not infinite and the further it end
  89534. * the more your scene might encounter depth fighting issue.
  89535. */
  89536. maxZ: number;
  89537. /**
  89538. * Define the default inertia of the camera.
  89539. * This helps giving a smooth feeling to the camera movement.
  89540. */
  89541. inertia: number;
  89542. /**
  89543. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  89544. */
  89545. mode: number;
  89546. /**
  89547. * Define wether the camera is intermediate.
  89548. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  89549. */
  89550. isIntermediate: boolean;
  89551. /**
  89552. * Define the viewport of the camera.
  89553. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  89554. */
  89555. viewport: Viewport;
  89556. /**
  89557. * Restricts the camera to viewing objects with the same layerMask.
  89558. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  89559. */
  89560. layerMask: number;
  89561. /**
  89562. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  89563. */
  89564. fovMode: number;
  89565. /**
  89566. * Rig mode of the camera.
  89567. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  89568. * This is normally controlled byt the camera themselves as internal use.
  89569. */
  89570. cameraRigMode: number;
  89571. /**
  89572. * Defines the distance between both "eyes" in case of a RIG
  89573. */
  89574. interaxialDistance: number;
  89575. /**
  89576. * Defines if stereoscopic rendering is done side by side or over under.
  89577. */
  89578. isStereoscopicSideBySide: boolean;
  89579. /**
  89580. * 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
  89581. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  89582. * else in the scene.
  89583. */
  89584. customRenderTargets: RenderTargetTexture[];
  89585. /**
  89586. * When set, the camera will render to this render target instead of the default canvas
  89587. */
  89588. outputRenderTarget: Nullable<RenderTargetTexture>;
  89589. /**
  89590. * Observable triggered when the camera view matrix has changed.
  89591. */
  89592. onViewMatrixChangedObservable: Observable<Camera>;
  89593. /**
  89594. * Observable triggered when the camera Projection matrix has changed.
  89595. */
  89596. onProjectionMatrixChangedObservable: Observable<Camera>;
  89597. /**
  89598. * Observable triggered when the inputs have been processed.
  89599. */
  89600. onAfterCheckInputsObservable: Observable<Camera>;
  89601. /**
  89602. * Observable triggered when reset has been called and applied to the camera.
  89603. */
  89604. onRestoreStateObservable: Observable<Camera>;
  89605. /** @hidden */
  89606. _cameraRigParams: any;
  89607. /** @hidden */
  89608. _rigCameras: Camera[];
  89609. /** @hidden */
  89610. _rigPostProcess: Nullable<PostProcess>;
  89611. protected _webvrViewMatrix: Matrix;
  89612. /** @hidden */
  89613. _skipRendering: boolean;
  89614. /** @hidden */
  89615. _projectionMatrix: Matrix;
  89616. /** @hidden */
  89617. _postProcesses: Nullable<PostProcess>[];
  89618. /** @hidden */
  89619. _activeMeshes: SmartArray<AbstractMesh>;
  89620. protected _globalPosition: Vector3;
  89621. /** hidden */
  89622. _computedViewMatrix: Matrix;
  89623. private _doNotComputeProjectionMatrix;
  89624. private _transformMatrix;
  89625. private _frustumPlanes;
  89626. private _refreshFrustumPlanes;
  89627. private _storedFov;
  89628. private _stateStored;
  89629. /**
  89630. * Instantiates a new camera object.
  89631. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  89632. * @see http://doc.babylonjs.com/features/cameras
  89633. * @param name Defines the name of the camera in the scene
  89634. * @param position Defines the position of the camera
  89635. * @param scene Defines the scene the camera belongs too
  89636. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  89637. */
  89638. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  89639. /**
  89640. * Store current camera state (fov, position, etc..)
  89641. * @returns the camera
  89642. */
  89643. storeState(): Camera;
  89644. /**
  89645. * Restores the camera state values if it has been stored. You must call storeState() first
  89646. */
  89647. protected _restoreStateValues(): boolean;
  89648. /**
  89649. * Restored camera state. You must call storeState() first.
  89650. * @returns true if restored and false otherwise
  89651. */
  89652. restoreState(): boolean;
  89653. /**
  89654. * Gets the class name of the camera.
  89655. * @returns the class name
  89656. */
  89657. getClassName(): string;
  89658. /** @hidden */
  89659. readonly _isCamera: boolean;
  89660. /**
  89661. * Gets a string representation of the camera useful for debug purpose.
  89662. * @param fullDetails Defines that a more verboe level of logging is required
  89663. * @returns the string representation
  89664. */
  89665. toString(fullDetails?: boolean): string;
  89666. /**
  89667. * Gets the current world space position of the camera.
  89668. */
  89669. readonly globalPosition: Vector3;
  89670. /**
  89671. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  89672. * @returns the active meshe list
  89673. */
  89674. getActiveMeshes(): SmartArray<AbstractMesh>;
  89675. /**
  89676. * Check wether a mesh is part of the current active mesh list of the camera
  89677. * @param mesh Defines the mesh to check
  89678. * @returns true if active, false otherwise
  89679. */
  89680. isActiveMesh(mesh: Mesh): boolean;
  89681. /**
  89682. * Is this camera ready to be used/rendered
  89683. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  89684. * @return true if the camera is ready
  89685. */
  89686. isReady(completeCheck?: boolean): boolean;
  89687. /** @hidden */
  89688. _initCache(): void;
  89689. /** @hidden */
  89690. _updateCache(ignoreParentClass?: boolean): void;
  89691. /** @hidden */
  89692. _isSynchronized(): boolean;
  89693. /** @hidden */
  89694. _isSynchronizedViewMatrix(): boolean;
  89695. /** @hidden */
  89696. _isSynchronizedProjectionMatrix(): boolean;
  89697. /**
  89698. * Attach the input controls to a specific dom element to get the input from.
  89699. * @param element Defines the element the controls should be listened from
  89700. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  89701. */
  89702. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  89703. /**
  89704. * Detach the current controls from the specified dom element.
  89705. * @param element Defines the element to stop listening the inputs from
  89706. */
  89707. detachControl(element: HTMLElement): void;
  89708. /**
  89709. * Update the camera state according to the different inputs gathered during the frame.
  89710. */
  89711. update(): void;
  89712. /** @hidden */
  89713. _checkInputs(): void;
  89714. /** @hidden */
  89715. readonly rigCameras: Camera[];
  89716. /**
  89717. * Gets the post process used by the rig cameras
  89718. */
  89719. readonly rigPostProcess: Nullable<PostProcess>;
  89720. /**
  89721. * Internal, gets the first post proces.
  89722. * @returns the first post process to be run on this camera.
  89723. */
  89724. _getFirstPostProcess(): Nullable<PostProcess>;
  89725. private _cascadePostProcessesToRigCams;
  89726. /**
  89727. * Attach a post process to the camera.
  89728. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89729. * @param postProcess The post process to attach to the camera
  89730. * @param insertAt The position of the post process in case several of them are in use in the scene
  89731. * @returns the position the post process has been inserted at
  89732. */
  89733. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  89734. /**
  89735. * Detach a post process to the camera.
  89736. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89737. * @param postProcess The post process to detach from the camera
  89738. */
  89739. detachPostProcess(postProcess: PostProcess): void;
  89740. /**
  89741. * Gets the current world matrix of the camera
  89742. */
  89743. getWorldMatrix(): Matrix;
  89744. /** @hidden */
  89745. _getViewMatrix(): Matrix;
  89746. /**
  89747. * Gets the current view matrix of the camera.
  89748. * @param force forces the camera to recompute the matrix without looking at the cached state
  89749. * @returns the view matrix
  89750. */
  89751. getViewMatrix(force?: boolean): Matrix;
  89752. /**
  89753. * Freeze the projection matrix.
  89754. * It will prevent the cache check of the camera projection compute and can speed up perf
  89755. * if no parameter of the camera are meant to change
  89756. * @param projection Defines manually a projection if necessary
  89757. */
  89758. freezeProjectionMatrix(projection?: Matrix): void;
  89759. /**
  89760. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  89761. */
  89762. unfreezeProjectionMatrix(): void;
  89763. /**
  89764. * Gets the current projection matrix of the camera.
  89765. * @param force forces the camera to recompute the matrix without looking at the cached state
  89766. * @returns the projection matrix
  89767. */
  89768. getProjectionMatrix(force?: boolean): Matrix;
  89769. /**
  89770. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  89771. * @returns a Matrix
  89772. */
  89773. getTransformationMatrix(): Matrix;
  89774. private _updateFrustumPlanes;
  89775. /**
  89776. * Checks if a cullable object (mesh...) is in the camera frustum
  89777. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  89778. * @param target The object to check
  89779. * @returns true if the object is in frustum otherwise false
  89780. */
  89781. isInFrustum(target: ICullable): boolean;
  89782. /**
  89783. * Checks if a cullable object (mesh...) is in the camera frustum
  89784. * Unlike isInFrustum this cheks the full bounding box
  89785. * @param target The object to check
  89786. * @returns true if the object is in frustum otherwise false
  89787. */
  89788. isCompletelyInFrustum(target: ICullable): boolean;
  89789. /**
  89790. * Gets a ray in the forward direction from the camera.
  89791. * @param length Defines the length of the ray to create
  89792. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  89793. * @param origin Defines the start point of the ray which defaults to the camera position
  89794. * @returns the forward ray
  89795. */
  89796. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  89797. /**
  89798. * Releases resources associated with this node.
  89799. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89800. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89801. */
  89802. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89803. /** @hidden */
  89804. _isLeftCamera: boolean;
  89805. /**
  89806. * Gets the left camera of a rig setup in case of Rigged Camera
  89807. */
  89808. readonly isLeftCamera: boolean;
  89809. /** @hidden */
  89810. _isRightCamera: boolean;
  89811. /**
  89812. * Gets the right camera of a rig setup in case of Rigged Camera
  89813. */
  89814. readonly isRightCamera: boolean;
  89815. /**
  89816. * Gets the left camera of a rig setup in case of Rigged Camera
  89817. */
  89818. readonly leftCamera: Nullable<FreeCamera>;
  89819. /**
  89820. * Gets the right camera of a rig setup in case of Rigged Camera
  89821. */
  89822. readonly rightCamera: Nullable<FreeCamera>;
  89823. /**
  89824. * Gets the left camera target of a rig setup in case of Rigged Camera
  89825. * @returns the target position
  89826. */
  89827. getLeftTarget(): Nullable<Vector3>;
  89828. /**
  89829. * Gets the right camera target of a rig setup in case of Rigged Camera
  89830. * @returns the target position
  89831. */
  89832. getRightTarget(): Nullable<Vector3>;
  89833. /**
  89834. * @hidden
  89835. */
  89836. setCameraRigMode(mode: number, rigParams: any): void;
  89837. /** @hidden */
  89838. static _setStereoscopicRigMode(camera: Camera): void;
  89839. /** @hidden */
  89840. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  89841. /** @hidden */
  89842. static _setVRRigMode(camera: Camera, rigParams: any): void;
  89843. /** @hidden */
  89844. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  89845. /** @hidden */
  89846. _getVRProjectionMatrix(): Matrix;
  89847. protected _updateCameraRotationMatrix(): void;
  89848. protected _updateWebVRCameraRotationMatrix(): void;
  89849. /**
  89850. * This function MUST be overwritten by the different WebVR cameras available.
  89851. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89852. * @hidden
  89853. */
  89854. _getWebVRProjectionMatrix(): Matrix;
  89855. /**
  89856. * This function MUST be overwritten by the different WebVR cameras available.
  89857. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89858. * @hidden
  89859. */
  89860. _getWebVRViewMatrix(): Matrix;
  89861. /** @hidden */
  89862. setCameraRigParameter(name: string, value: any): void;
  89863. /**
  89864. * needs to be overridden by children so sub has required properties to be copied
  89865. * @hidden
  89866. */
  89867. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  89868. /**
  89869. * May need to be overridden by children
  89870. * @hidden
  89871. */
  89872. _updateRigCameras(): void;
  89873. /** @hidden */
  89874. _setupInputs(): void;
  89875. /**
  89876. * Serialiaze the camera setup to a json represention
  89877. * @returns the JSON representation
  89878. */
  89879. serialize(): any;
  89880. /**
  89881. * Clones the current camera.
  89882. * @param name The cloned camera name
  89883. * @returns the cloned camera
  89884. */
  89885. clone(name: string): Camera;
  89886. /**
  89887. * Gets the direction of the camera relative to a given local axis.
  89888. * @param localAxis Defines the reference axis to provide a relative direction.
  89889. * @return the direction
  89890. */
  89891. getDirection(localAxis: Vector3): Vector3;
  89892. /**
  89893. * Gets the direction of the camera relative to a given local axis into a passed vector.
  89894. * @param localAxis Defines the reference axis to provide a relative direction.
  89895. * @param result Defines the vector to store the result in
  89896. */
  89897. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  89898. /**
  89899. * Gets a camera constructor for a given camera type
  89900. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  89901. * @param name The name of the camera the result will be able to instantiate
  89902. * @param scene The scene the result will construct the camera in
  89903. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  89904. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  89905. * @returns a factory method to construc the camera
  89906. */
  89907. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  89908. /**
  89909. * Compute the world matrix of the camera.
  89910. * @returns the camera workd matrix
  89911. */
  89912. computeWorldMatrix(): Matrix;
  89913. /**
  89914. * Parse a JSON and creates the camera from the parsed information
  89915. * @param parsedCamera The JSON to parse
  89916. * @param scene The scene to instantiate the camera in
  89917. * @returns the newly constructed camera
  89918. */
  89919. static Parse(parsedCamera: any, scene: Scene): Camera;
  89920. }
  89921. }
  89922. declare module BABYLON {
  89923. /**
  89924. * Interface for any object that can request an animation frame
  89925. */
  89926. export interface ICustomAnimationFrameRequester {
  89927. /**
  89928. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  89929. */
  89930. renderFunction?: Function;
  89931. /**
  89932. * Called to request the next frame to render to
  89933. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  89934. */
  89935. requestAnimationFrame: Function;
  89936. /**
  89937. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  89938. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  89939. */
  89940. requestID?: number;
  89941. }
  89942. /**
  89943. * Interface containing an array of animations
  89944. */
  89945. export interface IAnimatable {
  89946. /**
  89947. * Array of animations
  89948. */
  89949. animations: Array<Animation>;
  89950. }
  89951. /** Interface used by value gradients (color, factor, ...) */
  89952. export interface IValueGradient {
  89953. /**
  89954. * Gets or sets the gradient value (between 0 and 1)
  89955. */
  89956. gradient: number;
  89957. }
  89958. /** Class used to store color4 gradient */
  89959. export class ColorGradient implements IValueGradient {
  89960. /**
  89961. * Gets or sets the gradient value (between 0 and 1)
  89962. */
  89963. gradient: number;
  89964. /**
  89965. * Gets or sets first associated color
  89966. */
  89967. color1: Color4;
  89968. /**
  89969. * Gets or sets second associated color
  89970. */
  89971. color2?: Color4;
  89972. /**
  89973. * Will get a color picked randomly between color1 and color2.
  89974. * If color2 is undefined then color1 will be used
  89975. * @param result defines the target Color4 to store the result in
  89976. */
  89977. getColorToRef(result: Color4): void;
  89978. }
  89979. /** Class used to store color 3 gradient */
  89980. export class Color3Gradient implements IValueGradient {
  89981. /**
  89982. * Gets or sets the gradient value (between 0 and 1)
  89983. */
  89984. gradient: number;
  89985. /**
  89986. * Gets or sets the associated color
  89987. */
  89988. color: Color3;
  89989. }
  89990. /** Class used to store factor gradient */
  89991. export class FactorGradient implements IValueGradient {
  89992. /**
  89993. * Gets or sets the gradient value (between 0 and 1)
  89994. */
  89995. gradient: number;
  89996. /**
  89997. * Gets or sets first associated factor
  89998. */
  89999. factor1: number;
  90000. /**
  90001. * Gets or sets second associated factor
  90002. */
  90003. factor2?: number;
  90004. /**
  90005. * Will get a number picked randomly between factor1 and factor2.
  90006. * If factor2 is undefined then factor1 will be used
  90007. * @returns the picked number
  90008. */
  90009. getFactor(): number;
  90010. }
  90011. /**
  90012. * @ignore
  90013. * Application error to support additional information when loading a file
  90014. */
  90015. export class LoadFileError extends Error {
  90016. /** defines the optional web request */
  90017. request?: WebRequest | undefined;
  90018. private static _setPrototypeOf;
  90019. /**
  90020. * Creates a new LoadFileError
  90021. * @param message defines the message of the error
  90022. * @param request defines the optional web request
  90023. */
  90024. constructor(message: string,
  90025. /** defines the optional web request */
  90026. request?: WebRequest | undefined);
  90027. }
  90028. /**
  90029. * Class used to define a retry strategy when error happens while loading assets
  90030. */
  90031. export class RetryStrategy {
  90032. /**
  90033. * Function used to defines an exponential back off strategy
  90034. * @param maxRetries defines the maximum number of retries (3 by default)
  90035. * @param baseInterval defines the interval between retries
  90036. * @returns the strategy function to use
  90037. */
  90038. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  90039. }
  90040. /**
  90041. * File request interface
  90042. */
  90043. export interface IFileRequest {
  90044. /**
  90045. * Raised when the request is complete (success or error).
  90046. */
  90047. onCompleteObservable: Observable<IFileRequest>;
  90048. /**
  90049. * Aborts the request for a file.
  90050. */
  90051. abort: () => void;
  90052. }
  90053. /**
  90054. * Class containing a set of static utilities functions
  90055. */
  90056. export class Tools {
  90057. /**
  90058. * Gets or sets the base URL to use to load assets
  90059. */
  90060. static BaseUrl: string;
  90061. /**
  90062. * Enable/Disable Custom HTTP Request Headers globally.
  90063. * default = false
  90064. * @see CustomRequestHeaders
  90065. */
  90066. static UseCustomRequestHeaders: boolean;
  90067. /**
  90068. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  90069. * i.e. when loading files, where the server/service expects an Authorization header
  90070. */
  90071. static CustomRequestHeaders: {
  90072. [key: string]: string;
  90073. };
  90074. /**
  90075. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  90076. */
  90077. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  90078. /**
  90079. * Default behaviour for cors in the application.
  90080. * It can be a string if the expected behavior is identical in the entire app.
  90081. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  90082. */
  90083. static CorsBehavior: string | ((url: string | string[]) => string);
  90084. /**
  90085. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  90086. * @ignorenaming
  90087. */
  90088. static UseFallbackTexture: boolean;
  90089. /**
  90090. * Use this object to register external classes like custom textures or material
  90091. * to allow the laoders to instantiate them
  90092. */
  90093. static RegisteredExternalClasses: {
  90094. [key: string]: Object;
  90095. };
  90096. /**
  90097. * Texture content used if a texture cannot loaded
  90098. * @ignorenaming
  90099. */
  90100. static fallbackTexture: string;
  90101. /**
  90102. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  90103. * @param u defines the coordinate on X axis
  90104. * @param v defines the coordinate on Y axis
  90105. * @param width defines the width of the source data
  90106. * @param height defines the height of the source data
  90107. * @param pixels defines the source byte array
  90108. * @param color defines the output color
  90109. */
  90110. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  90111. /**
  90112. * Interpolates between a and b via alpha
  90113. * @param a The lower value (returned when alpha = 0)
  90114. * @param b The upper value (returned when alpha = 1)
  90115. * @param alpha The interpolation-factor
  90116. * @return The mixed value
  90117. */
  90118. static Mix(a: number, b: number, alpha: number): number;
  90119. /**
  90120. * Tries to instantiate a new object from a given class name
  90121. * @param className defines the class name to instantiate
  90122. * @returns the new object or null if the system was not able to do the instantiation
  90123. */
  90124. static Instantiate(className: string): any;
  90125. /**
  90126. * Provides a slice function that will work even on IE
  90127. * @param data defines the array to slice
  90128. * @param start defines the start of the data (optional)
  90129. * @param end defines the end of the data (optional)
  90130. * @returns the new sliced array
  90131. */
  90132. static Slice<T>(data: T, start?: number, end?: number): T;
  90133. /**
  90134. * Polyfill for setImmediate
  90135. * @param action defines the action to execute after the current execution block
  90136. */
  90137. static SetImmediate(action: () => void): void;
  90138. /**
  90139. * Function indicating if a number is an exponent of 2
  90140. * @param value defines the value to test
  90141. * @returns true if the value is an exponent of 2
  90142. */
  90143. static IsExponentOfTwo(value: number): boolean;
  90144. private static _tmpFloatArray;
  90145. /**
  90146. * Returns the nearest 32-bit single precision float representation of a Number
  90147. * @param value A Number. If the parameter is of a different type, it will get converted
  90148. * to a number or to NaN if it cannot be converted
  90149. * @returns number
  90150. */
  90151. static FloatRound(value: number): number;
  90152. /**
  90153. * Find the next highest power of two.
  90154. * @param x Number to start search from.
  90155. * @return Next highest power of two.
  90156. */
  90157. static CeilingPOT(x: number): number;
  90158. /**
  90159. * Find the next lowest power of two.
  90160. * @param x Number to start search from.
  90161. * @return Next lowest power of two.
  90162. */
  90163. static FloorPOT(x: number): number;
  90164. /**
  90165. * Find the nearest power of two.
  90166. * @param x Number to start search from.
  90167. * @return Next nearest power of two.
  90168. */
  90169. static NearestPOT(x: number): number;
  90170. /**
  90171. * Get the closest exponent of two
  90172. * @param value defines the value to approximate
  90173. * @param max defines the maximum value to return
  90174. * @param mode defines how to define the closest value
  90175. * @returns closest exponent of two of the given value
  90176. */
  90177. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  90178. /**
  90179. * Extracts the filename from a path
  90180. * @param path defines the path to use
  90181. * @returns the filename
  90182. */
  90183. static GetFilename(path: string): string;
  90184. /**
  90185. * Extracts the "folder" part of a path (everything before the filename).
  90186. * @param uri The URI to extract the info from
  90187. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  90188. * @returns The "folder" part of the path
  90189. */
  90190. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  90191. /**
  90192. * Extracts text content from a DOM element hierarchy
  90193. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  90194. */
  90195. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  90196. /**
  90197. * Convert an angle in radians to degrees
  90198. * @param angle defines the angle to convert
  90199. * @returns the angle in degrees
  90200. */
  90201. static ToDegrees(angle: number): number;
  90202. /**
  90203. * Convert an angle in degrees to radians
  90204. * @param angle defines the angle to convert
  90205. * @returns the angle in radians
  90206. */
  90207. static ToRadians(angle: number): number;
  90208. /**
  90209. * Encode a buffer to a base64 string
  90210. * @param buffer defines the buffer to encode
  90211. * @returns the encoded string
  90212. */
  90213. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  90214. /**
  90215. * Extracts minimum and maximum values from a list of indexed positions
  90216. * @param positions defines the positions to use
  90217. * @param indices defines the indices to the positions
  90218. * @param indexStart defines the start index
  90219. * @param indexCount defines the end index
  90220. * @param bias defines bias value to add to the result
  90221. * @return minimum and maximum values
  90222. */
  90223. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  90224. minimum: Vector3;
  90225. maximum: Vector3;
  90226. };
  90227. /**
  90228. * Extracts minimum and maximum values from a list of positions
  90229. * @param positions defines the positions to use
  90230. * @param start defines the start index in the positions array
  90231. * @param count defines the number of positions to handle
  90232. * @param bias defines bias value to add to the result
  90233. * @param stride defines the stride size to use (distance between two positions in the positions array)
  90234. * @return minimum and maximum values
  90235. */
  90236. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  90237. minimum: Vector3;
  90238. maximum: Vector3;
  90239. };
  90240. /**
  90241. * Returns an array if obj is not an array
  90242. * @param obj defines the object to evaluate as an array
  90243. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  90244. * @returns either obj directly if obj is an array or a new array containing obj
  90245. */
  90246. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  90247. /**
  90248. * Gets the pointer prefix to use
  90249. * @returns "pointer" if touch is enabled. Else returns "mouse"
  90250. */
  90251. static GetPointerPrefix(): string;
  90252. /**
  90253. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  90254. * @param func - the function to be called
  90255. * @param requester - the object that will request the next frame. Falls back to window.
  90256. * @returns frame number
  90257. */
  90258. static QueueNewFrame(func: () => void, requester?: any): number;
  90259. /**
  90260. * Ask the browser to promote the current element to fullscreen rendering mode
  90261. * @param element defines the DOM element to promote
  90262. */
  90263. static RequestFullscreen(element: HTMLElement): void;
  90264. /**
  90265. * Asks the browser to exit fullscreen mode
  90266. */
  90267. static ExitFullscreen(): void;
  90268. /**
  90269. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  90270. * @param url define the url we are trying
  90271. * @param element define the dom element where to configure the cors policy
  90272. */
  90273. static SetCorsBehavior(url: string | string[], element: {
  90274. crossOrigin: string | null;
  90275. }): void;
  90276. /**
  90277. * Removes unwanted characters from an url
  90278. * @param url defines the url to clean
  90279. * @returns the cleaned url
  90280. */
  90281. static CleanUrl(url: string): string;
  90282. /**
  90283. * Gets or sets a function used to pre-process url before using them to load assets
  90284. */
  90285. static PreprocessUrl: (url: string) => string;
  90286. /**
  90287. * Loads an image as an HTMLImageElement.
  90288. * @param input url string, ArrayBuffer, or Blob to load
  90289. * @param onLoad callback called when the image successfully loads
  90290. * @param onError callback called when the image fails to load
  90291. * @param offlineProvider offline provider for caching
  90292. * @returns the HTMLImageElement of the loaded image
  90293. */
  90294. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  90295. /**
  90296. * Loads a file
  90297. * @param url url string, ArrayBuffer, or Blob to load
  90298. * @param onSuccess callback called when the file successfully loads
  90299. * @param onProgress callback called while file is loading (if the server supports this mode)
  90300. * @param offlineProvider defines the offline provider for caching
  90301. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  90302. * @param onError callback called when the file fails to load
  90303. * @returns a file request object
  90304. */
  90305. 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;
  90306. /**
  90307. * Load a script (identified by an url). When the url returns, the
  90308. * content of this file is added into a new script element, attached to the DOM (body element)
  90309. * @param scriptUrl defines the url of the script to laod
  90310. * @param onSuccess defines the callback called when the script is loaded
  90311. * @param onError defines the callback to call if an error occurs
  90312. * @param scriptId defines the id of the script element
  90313. */
  90314. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  90315. /**
  90316. * Load an asynchronous script (identified by an url). When the url returns, the
  90317. * content of this file is added into a new script element, attached to the DOM (body element)
  90318. * @param scriptUrl defines the url of the script to laod
  90319. * @param scriptId defines the id of the script element
  90320. * @returns a promise request object
  90321. */
  90322. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  90323. /**
  90324. * Loads a file from a blob
  90325. * @param fileToLoad defines the blob to use
  90326. * @param callback defines the callback to call when data is loaded
  90327. * @param progressCallback defines the callback to call during loading process
  90328. * @returns a file request object
  90329. */
  90330. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  90331. /**
  90332. * Loads a file
  90333. * @param fileToLoad defines the file to load
  90334. * @param callback defines the callback to call when data is loaded
  90335. * @param progressCallBack defines the callback to call during loading process
  90336. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  90337. * @returns a file request object
  90338. */
  90339. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  90340. /**
  90341. * Creates a data url from a given string content
  90342. * @param content defines the content to convert
  90343. * @returns the new data url link
  90344. */
  90345. static FileAsURL(content: string): string;
  90346. /**
  90347. * Format the given number to a specific decimal format
  90348. * @param value defines the number to format
  90349. * @param decimals defines the number of decimals to use
  90350. * @returns the formatted string
  90351. */
  90352. static Format(value: number, decimals?: number): string;
  90353. /**
  90354. * Checks if a given vector is inside a specific range
  90355. * @param v defines the vector to test
  90356. * @param min defines the minimum range
  90357. * @param max defines the maximum range
  90358. */
  90359. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  90360. /**
  90361. * Tries to copy an object by duplicating every property
  90362. * @param source defines the source object
  90363. * @param destination defines the target object
  90364. * @param doNotCopyList defines a list of properties to avoid
  90365. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  90366. */
  90367. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  90368. /**
  90369. * Gets a boolean indicating if the given object has no own property
  90370. * @param obj defines the object to test
  90371. * @returns true if object has no own property
  90372. */
  90373. static IsEmpty(obj: any): boolean;
  90374. /**
  90375. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  90376. * @param str Source string
  90377. * @param suffix Suffix to search for in the source string
  90378. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  90379. */
  90380. static EndsWith(str: string, suffix: string): boolean;
  90381. /**
  90382. * Function used to register events at window level
  90383. * @param events defines the events to register
  90384. */
  90385. static RegisterTopRootEvents(events: {
  90386. name: string;
  90387. handler: Nullable<(e: FocusEvent) => any>;
  90388. }[]): void;
  90389. /**
  90390. * Function used to unregister events from window level
  90391. * @param events defines the events to unregister
  90392. */
  90393. static UnregisterTopRootEvents(events: {
  90394. name: string;
  90395. handler: Nullable<(e: FocusEvent) => any>;
  90396. }[]): void;
  90397. /**
  90398. * @ignore
  90399. */
  90400. static _ScreenshotCanvas: HTMLCanvasElement;
  90401. /**
  90402. * Dumps the current bound framebuffer
  90403. * @param width defines the rendering width
  90404. * @param height defines the rendering height
  90405. * @param engine defines the hosting engine
  90406. * @param successCallback defines the callback triggered once the data are available
  90407. * @param mimeType defines the mime type of the result
  90408. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  90409. */
  90410. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  90411. /**
  90412. * Converts the canvas data to blob.
  90413. * This acts as a polyfill for browsers not supporting the to blob function.
  90414. * @param canvas Defines the canvas to extract the data from
  90415. * @param successCallback Defines the callback triggered once the data are available
  90416. * @param mimeType Defines the mime type of the result
  90417. */
  90418. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  90419. /**
  90420. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  90421. * @param successCallback defines the callback triggered once the data are available
  90422. * @param mimeType defines the mime type of the result
  90423. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  90424. */
  90425. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  90426. /**
  90427. * Downloads a blob in the browser
  90428. * @param blob defines the blob to download
  90429. * @param fileName defines the name of the downloaded file
  90430. */
  90431. static Download(blob: Blob, fileName: string): void;
  90432. /**
  90433. * Captures a screenshot of the current rendering
  90434. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  90435. * @param engine defines the rendering engine
  90436. * @param camera defines the source camera
  90437. * @param size This parameter can be set to a single number or to an object with the
  90438. * following (optional) properties: precision, width, height. If a single number is passed,
  90439. * it will be used for both width and height. If an object is passed, the screenshot size
  90440. * will be derived from the parameters. The precision property is a multiplier allowing
  90441. * rendering at a higher or lower resolution
  90442. * @param successCallback defines the callback receives a single parameter which contains the
  90443. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  90444. * src parameter of an <img> to display it
  90445. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  90446. * Check your browser for supported MIME types
  90447. */
  90448. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  90449. /**
  90450. * Generates an image screenshot from the specified camera.
  90451. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  90452. * @param engine The engine to use for rendering
  90453. * @param camera The camera to use for rendering
  90454. * @param size This parameter can be set to a single number or to an object with the
  90455. * following (optional) properties: precision, width, height. If a single number is passed,
  90456. * it will be used for both width and height. If an object is passed, the screenshot size
  90457. * will be derived from the parameters. The precision property is a multiplier allowing
  90458. * rendering at a higher or lower resolution
  90459. * @param successCallback The callback receives a single parameter which contains the
  90460. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  90461. * src parameter of an <img> to display it
  90462. * @param mimeType The MIME type of the screenshot image (default: image/png).
  90463. * Check your browser for supported MIME types
  90464. * @param samples Texture samples (default: 1)
  90465. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  90466. * @param fileName A name for for the downloaded file.
  90467. */
  90468. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  90469. /**
  90470. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  90471. * Be aware Math.random() could cause collisions, but:
  90472. * "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"
  90473. * @returns a pseudo random id
  90474. */
  90475. static RandomId(): string;
  90476. /**
  90477. * Test if the given uri is a base64 string
  90478. * @param uri The uri to test
  90479. * @return True if the uri is a base64 string or false otherwise
  90480. */
  90481. static IsBase64(uri: string): boolean;
  90482. /**
  90483. * Decode the given base64 uri.
  90484. * @param uri The uri to decode
  90485. * @return The decoded base64 data.
  90486. */
  90487. static DecodeBase64(uri: string): ArrayBuffer;
  90488. /**
  90489. * Gets the absolute url.
  90490. * @param url the input url
  90491. * @return the absolute url
  90492. */
  90493. static GetAbsoluteUrl(url: string): string;
  90494. /**
  90495. * No log
  90496. */
  90497. static readonly NoneLogLevel: number;
  90498. /**
  90499. * Only message logs
  90500. */
  90501. static readonly MessageLogLevel: number;
  90502. /**
  90503. * Only warning logs
  90504. */
  90505. static readonly WarningLogLevel: number;
  90506. /**
  90507. * Only error logs
  90508. */
  90509. static readonly ErrorLogLevel: number;
  90510. /**
  90511. * All logs
  90512. */
  90513. static readonly AllLogLevel: number;
  90514. /**
  90515. * Gets a value indicating the number of loading errors
  90516. * @ignorenaming
  90517. */
  90518. static readonly errorsCount: number;
  90519. /**
  90520. * Callback called when a new log is added
  90521. */
  90522. static OnNewCacheEntry: (entry: string) => void;
  90523. /**
  90524. * Log a message to the console
  90525. * @param message defines the message to log
  90526. */
  90527. static Log(message: string): void;
  90528. /**
  90529. * Write a warning message to the console
  90530. * @param message defines the message to log
  90531. */
  90532. static Warn(message: string): void;
  90533. /**
  90534. * Write an error message to the console
  90535. * @param message defines the message to log
  90536. */
  90537. static Error(message: string): void;
  90538. /**
  90539. * Gets current log cache (list of logs)
  90540. */
  90541. static readonly LogCache: string;
  90542. /**
  90543. * Clears the log cache
  90544. */
  90545. static ClearLogCache(): void;
  90546. /**
  90547. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  90548. */
  90549. static LogLevels: number;
  90550. /**
  90551. * Checks if the loaded document was accessed via `file:`-Protocol.
  90552. * @returns boolean
  90553. */
  90554. static IsFileURL(): boolean;
  90555. /**
  90556. * Checks if the window object exists
  90557. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  90558. */
  90559. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  90560. /**
  90561. * No performance log
  90562. */
  90563. static readonly PerformanceNoneLogLevel: number;
  90564. /**
  90565. * Use user marks to log performance
  90566. */
  90567. static readonly PerformanceUserMarkLogLevel: number;
  90568. /**
  90569. * Log performance to the console
  90570. */
  90571. static readonly PerformanceConsoleLogLevel: number;
  90572. private static _performance;
  90573. /**
  90574. * Sets the current performance log level
  90575. */
  90576. static PerformanceLogLevel: number;
  90577. private static _StartPerformanceCounterDisabled;
  90578. private static _EndPerformanceCounterDisabled;
  90579. private static _StartUserMark;
  90580. private static _EndUserMark;
  90581. private static _StartPerformanceConsole;
  90582. private static _EndPerformanceConsole;
  90583. /**
  90584. * Starts a performance counter
  90585. */
  90586. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  90587. /**
  90588. * Ends a specific performance coutner
  90589. */
  90590. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  90591. /**
  90592. * Gets either window.performance.now() if supported or Date.now() else
  90593. */
  90594. static readonly Now: number;
  90595. /**
  90596. * This method will return the name of the class used to create the instance of the given object.
  90597. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  90598. * @param object the object to get the class name from
  90599. * @param isType defines if the object is actually a type
  90600. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  90601. */
  90602. static GetClassName(object: any, isType?: boolean): string;
  90603. /**
  90604. * Gets the first element of an array satisfying a given predicate
  90605. * @param array defines the array to browse
  90606. * @param predicate defines the predicate to use
  90607. * @returns null if not found or the element
  90608. */
  90609. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  90610. /**
  90611. * This method will return the name of the full name of the class, including its owning module (if any).
  90612. * 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).
  90613. * @param object the object to get the class name from
  90614. * @param isType defines if the object is actually a type
  90615. * @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.
  90616. * @ignorenaming
  90617. */
  90618. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  90619. /**
  90620. * Returns a promise that resolves after the given amount of time.
  90621. * @param delay Number of milliseconds to delay
  90622. * @returns Promise that resolves after the given amount of time
  90623. */
  90624. static DelayAsync(delay: number): Promise<void>;
  90625. /**
  90626. * Gets the current gradient from an array of IValueGradient
  90627. * @param ratio defines the current ratio to get
  90628. * @param gradients defines the array of IValueGradient
  90629. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  90630. */
  90631. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  90632. }
  90633. /**
  90634. * This class is used to track a performance counter which is number based.
  90635. * The user has access to many properties which give statistics of different nature.
  90636. *
  90637. * The implementer can track two kinds of Performance Counter: time and count.
  90638. * 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.
  90639. * 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.
  90640. */
  90641. export class PerfCounter {
  90642. /**
  90643. * Gets or sets a global boolean to turn on and off all the counters
  90644. */
  90645. static Enabled: boolean;
  90646. /**
  90647. * Returns the smallest value ever
  90648. */
  90649. readonly min: number;
  90650. /**
  90651. * Returns the biggest value ever
  90652. */
  90653. readonly max: number;
  90654. /**
  90655. * Returns the average value since the performance counter is running
  90656. */
  90657. readonly average: number;
  90658. /**
  90659. * Returns the average value of the last second the counter was monitored
  90660. */
  90661. readonly lastSecAverage: number;
  90662. /**
  90663. * Returns the current value
  90664. */
  90665. readonly current: number;
  90666. /**
  90667. * Gets the accumulated total
  90668. */
  90669. readonly total: number;
  90670. /**
  90671. * Gets the total value count
  90672. */
  90673. readonly count: number;
  90674. /**
  90675. * Creates a new counter
  90676. */
  90677. constructor();
  90678. /**
  90679. * Call this method to start monitoring a new frame.
  90680. * 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.
  90681. */
  90682. fetchNewFrame(): void;
  90683. /**
  90684. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  90685. * @param newCount the count value to add to the monitored count
  90686. * @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.
  90687. */
  90688. addCount(newCount: number, fetchResult: boolean): void;
  90689. /**
  90690. * Start monitoring this performance counter
  90691. */
  90692. beginMonitoring(): void;
  90693. /**
  90694. * Compute the time lapsed since the previous beginMonitoring() call.
  90695. * @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
  90696. */
  90697. endMonitoring(newFrame?: boolean): void;
  90698. private _fetchResult;
  90699. private _startMonitoringTime;
  90700. private _min;
  90701. private _max;
  90702. private _average;
  90703. private _current;
  90704. private _totalValueCount;
  90705. private _totalAccumulated;
  90706. private _lastSecAverage;
  90707. private _lastSecAccumulated;
  90708. private _lastSecTime;
  90709. private _lastSecValueCount;
  90710. }
  90711. /**
  90712. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  90713. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  90714. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  90715. * @param name The name of the class, case should be preserved
  90716. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  90717. */
  90718. export function className(name: string, module?: string): (target: Object) => void;
  90719. /**
  90720. * An implementation of a loop for asynchronous functions.
  90721. */
  90722. export class AsyncLoop {
  90723. /**
  90724. * Defines the number of iterations for the loop
  90725. */
  90726. iterations: number;
  90727. /**
  90728. * Defines the current index of the loop.
  90729. */
  90730. index: number;
  90731. private _done;
  90732. private _fn;
  90733. private _successCallback;
  90734. /**
  90735. * Constructor.
  90736. * @param iterations the number of iterations.
  90737. * @param func the function to run each iteration
  90738. * @param successCallback the callback that will be called upon succesful execution
  90739. * @param offset starting offset.
  90740. */
  90741. constructor(
  90742. /**
  90743. * Defines the number of iterations for the loop
  90744. */
  90745. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  90746. /**
  90747. * Execute the next iteration. Must be called after the last iteration was finished.
  90748. */
  90749. executeNext(): void;
  90750. /**
  90751. * Break the loop and run the success callback.
  90752. */
  90753. breakLoop(): void;
  90754. /**
  90755. * Create and run an async loop.
  90756. * @param iterations the number of iterations.
  90757. * @param fn the function to run each iteration
  90758. * @param successCallback the callback that will be called upon succesful execution
  90759. * @param offset starting offset.
  90760. * @returns the created async loop object
  90761. */
  90762. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  90763. /**
  90764. * A for-loop that will run a given number of iterations synchronous and the rest async.
  90765. * @param iterations total number of iterations
  90766. * @param syncedIterations number of synchronous iterations in each async iteration.
  90767. * @param fn the function to call each iteration.
  90768. * @param callback a success call back that will be called when iterating stops.
  90769. * @param breakFunction a break condition (optional)
  90770. * @param timeout timeout settings for the setTimeout function. default - 0.
  90771. * @returns the created async loop object
  90772. */
  90773. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  90774. }
  90775. }
  90776. declare module BABYLON {
  90777. /** @hidden */
  90778. export interface ICollisionCoordinator {
  90779. createCollider(): Collider;
  90780. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  90781. init(scene: Scene): void;
  90782. }
  90783. /** @hidden */
  90784. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  90785. private _scene;
  90786. private _scaledPosition;
  90787. private _scaledVelocity;
  90788. private _finalPosition;
  90789. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  90790. createCollider(): Collider;
  90791. init(scene: Scene): void;
  90792. private _collideWithWorld;
  90793. }
  90794. }
  90795. declare module BABYLON {
  90796. /**
  90797. * This class defines the direct association between an animation and a target
  90798. */
  90799. export class TargetedAnimation {
  90800. /**
  90801. * Animation to perform
  90802. */
  90803. animation: Animation;
  90804. /**
  90805. * Target to animate
  90806. */
  90807. target: any;
  90808. }
  90809. /**
  90810. * Use this class to create coordinated animations on multiple targets
  90811. */
  90812. export class AnimationGroup implements IDisposable {
  90813. /** The name of the animation group */
  90814. name: string;
  90815. private _scene;
  90816. private _targetedAnimations;
  90817. private _animatables;
  90818. private _from;
  90819. private _to;
  90820. private _isStarted;
  90821. private _isPaused;
  90822. private _speedRatio;
  90823. /**
  90824. * Gets or sets the unique id of the node
  90825. */
  90826. uniqueId: number;
  90827. /**
  90828. * This observable will notify when one animation have ended
  90829. */
  90830. onAnimationEndObservable: Observable<TargetedAnimation>;
  90831. /**
  90832. * Observer raised when one animation loops
  90833. */
  90834. onAnimationLoopObservable: Observable<TargetedAnimation>;
  90835. /**
  90836. * This observable will notify when all animations have ended.
  90837. */
  90838. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  90839. /**
  90840. * This observable will notify when all animations have paused.
  90841. */
  90842. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  90843. /**
  90844. * This observable will notify when all animations are playing.
  90845. */
  90846. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  90847. /**
  90848. * Gets the first frame
  90849. */
  90850. readonly from: number;
  90851. /**
  90852. * Gets the last frame
  90853. */
  90854. readonly to: number;
  90855. /**
  90856. * Define if the animations are started
  90857. */
  90858. readonly isStarted: boolean;
  90859. /**
  90860. * Gets a value indicating that the current group is playing
  90861. */
  90862. readonly isPlaying: boolean;
  90863. /**
  90864. * Gets or sets the speed ratio to use for all animations
  90865. */
  90866. /**
  90867. * Gets or sets the speed ratio to use for all animations
  90868. */
  90869. speedRatio: number;
  90870. /**
  90871. * Gets the targeted animations for this animation group
  90872. */
  90873. readonly targetedAnimations: Array<TargetedAnimation>;
  90874. /**
  90875. * returning the list of animatables controlled by this animation group.
  90876. */
  90877. readonly animatables: Array<Animatable>;
  90878. /**
  90879. * Instantiates a new Animation Group.
  90880. * This helps managing several animations at once.
  90881. * @see http://doc.babylonjs.com/how_to/group
  90882. * @param name Defines the name of the group
  90883. * @param scene Defines the scene the group belongs to
  90884. */
  90885. constructor(
  90886. /** The name of the animation group */
  90887. name: string, scene?: Nullable<Scene>);
  90888. /**
  90889. * Add an animation (with its target) in the group
  90890. * @param animation defines the animation we want to add
  90891. * @param target defines the target of the animation
  90892. * @returns the TargetedAnimation object
  90893. */
  90894. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  90895. /**
  90896. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  90897. * It can add constant keys at begin or end
  90898. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  90899. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  90900. * @returns the animation group
  90901. */
  90902. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  90903. /**
  90904. * Start all animations on given targets
  90905. * @param loop defines if animations must loop
  90906. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  90907. * @param from defines the from key (optional)
  90908. * @param to defines the to key (optional)
  90909. * @returns the current animation group
  90910. */
  90911. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  90912. /**
  90913. * Pause all animations
  90914. * @returns the animation group
  90915. */
  90916. pause(): AnimationGroup;
  90917. /**
  90918. * Play all animations to initial state
  90919. * This function will start() the animations if they were not started or will restart() them if they were paused
  90920. * @param loop defines if animations must loop
  90921. * @returns the animation group
  90922. */
  90923. play(loop?: boolean): AnimationGroup;
  90924. /**
  90925. * Reset all animations to initial state
  90926. * @returns the animation group
  90927. */
  90928. reset(): AnimationGroup;
  90929. /**
  90930. * Restart animations from key 0
  90931. * @returns the animation group
  90932. */
  90933. restart(): AnimationGroup;
  90934. /**
  90935. * Stop all animations
  90936. * @returns the animation group
  90937. */
  90938. stop(): AnimationGroup;
  90939. /**
  90940. * Set animation weight for all animatables
  90941. * @param weight defines the weight to use
  90942. * @return the animationGroup
  90943. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  90944. */
  90945. setWeightForAllAnimatables(weight: number): AnimationGroup;
  90946. /**
  90947. * Synchronize and normalize all animatables with a source animatable
  90948. * @param root defines the root animatable to synchronize with
  90949. * @return the animationGroup
  90950. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  90951. */
  90952. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  90953. /**
  90954. * Goes to a specific frame in this animation group
  90955. * @param frame the frame number to go to
  90956. * @return the animationGroup
  90957. */
  90958. goToFrame(frame: number): AnimationGroup;
  90959. /**
  90960. * Dispose all associated resources
  90961. */
  90962. dispose(): void;
  90963. private _checkAnimationGroupEnded;
  90964. /**
  90965. * Clone the current animation group and returns a copy
  90966. * @param newName defines the name of the new group
  90967. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  90968. * @returns the new aniamtion group
  90969. */
  90970. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  90971. /**
  90972. * Returns a new AnimationGroup object parsed from the source provided.
  90973. * @param parsedAnimationGroup defines the source
  90974. * @param scene defines the scene that will receive the animationGroup
  90975. * @returns a new AnimationGroup
  90976. */
  90977. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  90978. /**
  90979. * Returns the string "AnimationGroup"
  90980. * @returns "AnimationGroup"
  90981. */
  90982. getClassName(): string;
  90983. /**
  90984. * Creates a detailled string about the object
  90985. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  90986. * @returns a string representing the object
  90987. */
  90988. toString(fullDetails?: boolean): string;
  90989. }
  90990. }
  90991. declare module BABYLON {
  90992. /**
  90993. * Define an interface for all classes that will hold resources
  90994. */
  90995. export interface IDisposable {
  90996. /**
  90997. * Releases all held resources
  90998. */
  90999. dispose(): void;
  91000. }
  91001. /** Interface defining initialization parameters for Scene class */
  91002. export interface SceneOptions {
  91003. /**
  91004. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  91005. * It will improve performance when the number of geometries becomes important.
  91006. */
  91007. useGeometryUniqueIdsMap?: boolean;
  91008. /**
  91009. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  91010. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91011. */
  91012. useMaterialMeshMap?: boolean;
  91013. /**
  91014. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  91015. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91016. */
  91017. useClonedMeshhMap?: boolean;
  91018. }
  91019. /**
  91020. * Represents a scene to be rendered by the engine.
  91021. * @see http://doc.babylonjs.com/features/scene
  91022. */
  91023. export class Scene extends AbstractScene implements IAnimatable {
  91024. private static _uniqueIdCounter;
  91025. /** The fog is deactivated */
  91026. static readonly FOGMODE_NONE: number;
  91027. /** The fog density is following an exponential function */
  91028. static readonly FOGMODE_EXP: number;
  91029. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  91030. static readonly FOGMODE_EXP2: number;
  91031. /** The fog density is following a linear function. */
  91032. static readonly FOGMODE_LINEAR: number;
  91033. /**
  91034. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  91035. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91036. */
  91037. static MinDeltaTime: number;
  91038. /**
  91039. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  91040. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91041. */
  91042. static MaxDeltaTime: number;
  91043. /**
  91044. * Factory used to create the default material.
  91045. * @param name The name of the material to create
  91046. * @param scene The scene to create the material for
  91047. * @returns The default material
  91048. */
  91049. static DefaultMaterialFactory(scene: Scene): Material;
  91050. /**
  91051. * Factory used to create the a collision coordinator.
  91052. * @returns The collision coordinator
  91053. */
  91054. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  91055. /** @hidden */
  91056. readonly _isScene: boolean;
  91057. /**
  91058. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  91059. */
  91060. autoClear: boolean;
  91061. /**
  91062. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  91063. */
  91064. autoClearDepthAndStencil: boolean;
  91065. /**
  91066. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  91067. */
  91068. clearColor: Color4;
  91069. /**
  91070. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  91071. */
  91072. ambientColor: Color3;
  91073. /**
  91074. * This is use to store the default BRDF lookup for PBR materials in your scene.
  91075. * It should only be one of the following (if not the default embedded one):
  91076. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  91077. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  91078. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  91079. * The material properties need to be setup according to the type of texture in use.
  91080. */
  91081. environmentBRDFTexture: BaseTexture;
  91082. /** @hidden */
  91083. protected _environmentTexture: Nullable<BaseTexture>;
  91084. /**
  91085. * Texture used in all pbr material as the reflection texture.
  91086. * As in the majority of the scene they are the same (exception for multi room and so on),
  91087. * this is easier to reference from here than from all the materials.
  91088. */
  91089. /**
  91090. * Texture used in all pbr material as the reflection texture.
  91091. * As in the majority of the scene they are the same (exception for multi room and so on),
  91092. * this is easier to set here than in all the materials.
  91093. */
  91094. environmentTexture: Nullable<BaseTexture>;
  91095. /** @hidden */
  91096. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  91097. /**
  91098. * Default image processing configuration used either in the rendering
  91099. * Forward main pass or through the imageProcessingPostProcess if present.
  91100. * As in the majority of the scene they are the same (exception for multi camera),
  91101. * this is easier to reference from here than from all the materials and post process.
  91102. *
  91103. * No setter as we it is a shared configuration, you can set the values instead.
  91104. */
  91105. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  91106. private _forceWireframe;
  91107. /**
  91108. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  91109. */
  91110. forceWireframe: boolean;
  91111. private _forcePointsCloud;
  91112. /**
  91113. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  91114. */
  91115. forcePointsCloud: boolean;
  91116. /**
  91117. * Gets or sets the active clipplane 1
  91118. */
  91119. clipPlane: Nullable<Plane>;
  91120. /**
  91121. * Gets or sets the active clipplane 2
  91122. */
  91123. clipPlane2: Nullable<Plane>;
  91124. /**
  91125. * Gets or sets the active clipplane 3
  91126. */
  91127. clipPlane3: Nullable<Plane>;
  91128. /**
  91129. * Gets or sets the active clipplane 4
  91130. */
  91131. clipPlane4: Nullable<Plane>;
  91132. /**
  91133. * Gets or sets a boolean indicating if animations are enabled
  91134. */
  91135. animationsEnabled: boolean;
  91136. private _animationPropertiesOverride;
  91137. /**
  91138. * Gets or sets the animation properties override
  91139. */
  91140. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91141. /**
  91142. * Gets or sets a boolean indicating if a constant deltatime has to be used
  91143. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  91144. */
  91145. useConstantAnimationDeltaTime: boolean;
  91146. /**
  91147. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  91148. * Please note that it requires to run a ray cast through the scene on every frame
  91149. */
  91150. constantlyUpdateMeshUnderPointer: boolean;
  91151. /**
  91152. * Defines the HTML cursor to use when hovering over interactive elements
  91153. */
  91154. hoverCursor: string;
  91155. /**
  91156. * Defines the HTML default cursor to use (empty by default)
  91157. */
  91158. defaultCursor: string;
  91159. /**
  91160. * This is used to call preventDefault() on pointer down
  91161. * in order to block unwanted artifacts like system double clicks
  91162. */
  91163. preventDefaultOnPointerDown: boolean;
  91164. /**
  91165. * This is used to call preventDefault() on pointer up
  91166. * in order to block unwanted artifacts like system double clicks
  91167. */
  91168. preventDefaultOnPointerUp: boolean;
  91169. /**
  91170. * Gets or sets user defined metadata
  91171. */
  91172. metadata: any;
  91173. /**
  91174. * For internal use only. Please do not use.
  91175. */
  91176. reservedDataStore: any;
  91177. /**
  91178. * Gets the name of the plugin used to load this scene (null by default)
  91179. */
  91180. loadingPluginName: string;
  91181. /**
  91182. * Use this array to add regular expressions used to disable offline support for specific urls
  91183. */
  91184. disableOfflineSupportExceptionRules: RegExp[];
  91185. /**
  91186. * An event triggered when the scene is disposed.
  91187. */
  91188. onDisposeObservable: Observable<Scene>;
  91189. private _onDisposeObserver;
  91190. /** Sets a function to be executed when this scene is disposed. */
  91191. onDispose: () => void;
  91192. /**
  91193. * An event triggered before rendering the scene (right after animations and physics)
  91194. */
  91195. onBeforeRenderObservable: Observable<Scene>;
  91196. private _onBeforeRenderObserver;
  91197. /** Sets a function to be executed before rendering this scene */
  91198. beforeRender: Nullable<() => void>;
  91199. /**
  91200. * An event triggered after rendering the scene
  91201. */
  91202. onAfterRenderObservable: Observable<Scene>;
  91203. private _onAfterRenderObserver;
  91204. /** Sets a function to be executed after rendering this scene */
  91205. afterRender: Nullable<() => void>;
  91206. /**
  91207. * An event triggered before animating the scene
  91208. */
  91209. onBeforeAnimationsObservable: Observable<Scene>;
  91210. /**
  91211. * An event triggered after animations processing
  91212. */
  91213. onAfterAnimationsObservable: Observable<Scene>;
  91214. /**
  91215. * An event triggered before draw calls are ready to be sent
  91216. */
  91217. onBeforeDrawPhaseObservable: Observable<Scene>;
  91218. /**
  91219. * An event triggered after draw calls have been sent
  91220. */
  91221. onAfterDrawPhaseObservable: Observable<Scene>;
  91222. /**
  91223. * An event triggered when the scene is ready
  91224. */
  91225. onReadyObservable: Observable<Scene>;
  91226. /**
  91227. * An event triggered before rendering a camera
  91228. */
  91229. onBeforeCameraRenderObservable: Observable<Camera>;
  91230. private _onBeforeCameraRenderObserver;
  91231. /** Sets a function to be executed before rendering a camera*/
  91232. beforeCameraRender: () => void;
  91233. /**
  91234. * An event triggered after rendering a camera
  91235. */
  91236. onAfterCameraRenderObservable: Observable<Camera>;
  91237. private _onAfterCameraRenderObserver;
  91238. /** Sets a function to be executed after rendering a camera*/
  91239. afterCameraRender: () => void;
  91240. /**
  91241. * An event triggered when active meshes evaluation is about to start
  91242. */
  91243. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  91244. /**
  91245. * An event triggered when active meshes evaluation is done
  91246. */
  91247. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  91248. /**
  91249. * An event triggered when particles rendering is about to start
  91250. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  91251. */
  91252. onBeforeParticlesRenderingObservable: Observable<Scene>;
  91253. /**
  91254. * An event triggered when particles rendering is done
  91255. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  91256. */
  91257. onAfterParticlesRenderingObservable: Observable<Scene>;
  91258. /**
  91259. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  91260. */
  91261. onDataLoadedObservable: Observable<Scene>;
  91262. /**
  91263. * An event triggered when a camera is created
  91264. */
  91265. onNewCameraAddedObservable: Observable<Camera>;
  91266. /**
  91267. * An event triggered when a camera is removed
  91268. */
  91269. onCameraRemovedObservable: Observable<Camera>;
  91270. /**
  91271. * An event triggered when a light is created
  91272. */
  91273. onNewLightAddedObservable: Observable<Light>;
  91274. /**
  91275. * An event triggered when a light is removed
  91276. */
  91277. onLightRemovedObservable: Observable<Light>;
  91278. /**
  91279. * An event triggered when a geometry is created
  91280. */
  91281. onNewGeometryAddedObservable: Observable<Geometry>;
  91282. /**
  91283. * An event triggered when a geometry is removed
  91284. */
  91285. onGeometryRemovedObservable: Observable<Geometry>;
  91286. /**
  91287. * An event triggered when a transform node is created
  91288. */
  91289. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  91290. /**
  91291. * An event triggered when a transform node is removed
  91292. */
  91293. onTransformNodeRemovedObservable: Observable<TransformNode>;
  91294. /**
  91295. * An event triggered when a mesh is created
  91296. */
  91297. onNewMeshAddedObservable: Observable<AbstractMesh>;
  91298. /**
  91299. * An event triggered when a mesh is removed
  91300. */
  91301. onMeshRemovedObservable: Observable<AbstractMesh>;
  91302. /**
  91303. * An event triggered when a skeleton is created
  91304. */
  91305. onNewSkeletonAddedObservable: Observable<Skeleton>;
  91306. /**
  91307. * An event triggered when a skeleton is removed
  91308. */
  91309. onSkeletonRemovedObservable: Observable<Skeleton>;
  91310. /**
  91311. * An event triggered when a material is created
  91312. */
  91313. onNewMaterialAddedObservable: Observable<Material>;
  91314. /**
  91315. * An event triggered when a material is removed
  91316. */
  91317. onMaterialRemovedObservable: Observable<Material>;
  91318. /**
  91319. * An event triggered when a texture is created
  91320. */
  91321. onNewTextureAddedObservable: Observable<BaseTexture>;
  91322. /**
  91323. * An event triggered when a texture is removed
  91324. */
  91325. onTextureRemovedObservable: Observable<BaseTexture>;
  91326. /**
  91327. * An event triggered when render targets are about to be rendered
  91328. * Can happen multiple times per frame.
  91329. */
  91330. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  91331. /**
  91332. * An event triggered when render targets were rendered.
  91333. * Can happen multiple times per frame.
  91334. */
  91335. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  91336. /**
  91337. * An event triggered before calculating deterministic simulation step
  91338. */
  91339. onBeforeStepObservable: Observable<Scene>;
  91340. /**
  91341. * An event triggered after calculating deterministic simulation step
  91342. */
  91343. onAfterStepObservable: Observable<Scene>;
  91344. /**
  91345. * An event triggered when the activeCamera property is updated
  91346. */
  91347. onActiveCameraChanged: Observable<Scene>;
  91348. /**
  91349. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  91350. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  91351. * 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)
  91352. */
  91353. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  91354. /**
  91355. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  91356. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  91357. * 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)
  91358. */
  91359. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  91360. /**
  91361. * This Observable will when a mesh has been imported into the scene.
  91362. */
  91363. onMeshImportedObservable: Observable<AbstractMesh>;
  91364. /**
  91365. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  91366. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  91367. */
  91368. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  91369. /** @hidden */
  91370. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  91371. /**
  91372. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  91373. */
  91374. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  91375. /**
  91376. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  91377. */
  91378. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  91379. /**
  91380. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  91381. */
  91382. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  91383. private _onPointerMove;
  91384. private _onPointerDown;
  91385. private _onPointerUp;
  91386. /** Callback called when a pointer move is detected */
  91387. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  91388. /** Callback called when a pointer down is detected */
  91389. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  91390. /** Callback called when a pointer up is detected */
  91391. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  91392. /** Callback called when a pointer pick is detected */
  91393. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  91394. /**
  91395. * 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).
  91396. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  91397. */
  91398. onPrePointerObservable: Observable<PointerInfoPre>;
  91399. /**
  91400. * Observable event triggered each time an input event is received from the rendering canvas
  91401. */
  91402. onPointerObservable: Observable<PointerInfo>;
  91403. /**
  91404. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  91405. */
  91406. readonly unTranslatedPointer: Vector2;
  91407. /** The distance in pixel that you have to move to prevent some events */
  91408. static DragMovementThreshold: number;
  91409. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  91410. static LongPressDelay: number;
  91411. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  91412. static DoubleClickDelay: number;
  91413. /** If you need to check double click without raising a single click at first click, enable this flag */
  91414. static ExclusiveDoubleClickMode: boolean;
  91415. private _initClickEvent;
  91416. private _initActionManager;
  91417. private _delayedSimpleClick;
  91418. private _delayedSimpleClickTimeout;
  91419. private _previousDelayedSimpleClickTimeout;
  91420. private _meshPickProceed;
  91421. private _previousButtonPressed;
  91422. private _currentPickResult;
  91423. private _previousPickResult;
  91424. private _totalPointersPressed;
  91425. private _doubleClickOccured;
  91426. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  91427. cameraToUseForPointers: Nullable<Camera>;
  91428. private _pointerX;
  91429. private _pointerY;
  91430. private _unTranslatedPointerX;
  91431. private _unTranslatedPointerY;
  91432. private _startingPointerPosition;
  91433. private _previousStartingPointerPosition;
  91434. private _startingPointerTime;
  91435. private _previousStartingPointerTime;
  91436. private _pointerCaptures;
  91437. private _timeAccumulator;
  91438. private _currentStepId;
  91439. private _currentInternalStep;
  91440. /** @hidden */
  91441. _mirroredCameraPosition: Nullable<Vector3>;
  91442. /**
  91443. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  91444. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  91445. */
  91446. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  91447. /**
  91448. * Observable event triggered each time an keyboard event is received from the hosting window
  91449. */
  91450. onKeyboardObservable: Observable<KeyboardInfo>;
  91451. private _onKeyDown;
  91452. private _onKeyUp;
  91453. private _onCanvasFocusObserver;
  91454. private _onCanvasBlurObserver;
  91455. private _useRightHandedSystem;
  91456. /**
  91457. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  91458. */
  91459. useRightHandedSystem: boolean;
  91460. /**
  91461. * Sets the step Id used by deterministic lock step
  91462. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91463. * @param newStepId defines the step Id
  91464. */
  91465. setStepId(newStepId: number): void;
  91466. /**
  91467. * Gets the step Id used by deterministic lock step
  91468. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91469. * @returns the step Id
  91470. */
  91471. getStepId(): number;
  91472. /**
  91473. * Gets the internal step used by deterministic lock step
  91474. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91475. * @returns the internal step
  91476. */
  91477. getInternalStep(): number;
  91478. private _fogEnabled;
  91479. /**
  91480. * Gets or sets a boolean indicating if fog is enabled on this scene
  91481. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91482. * (Default is true)
  91483. */
  91484. fogEnabled: boolean;
  91485. private _fogMode;
  91486. /**
  91487. * Gets or sets the fog mode to use
  91488. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91489. * | mode | value |
  91490. * | --- | --- |
  91491. * | FOGMODE_NONE | 0 |
  91492. * | FOGMODE_EXP | 1 |
  91493. * | FOGMODE_EXP2 | 2 |
  91494. * | FOGMODE_LINEAR | 3 |
  91495. */
  91496. fogMode: number;
  91497. /**
  91498. * Gets or sets the fog color to use
  91499. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91500. * (Default is Color3(0.2, 0.2, 0.3))
  91501. */
  91502. fogColor: Color3;
  91503. /**
  91504. * Gets or sets the fog density to use
  91505. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91506. * (Default is 0.1)
  91507. */
  91508. fogDensity: number;
  91509. /**
  91510. * Gets or sets the fog start distance to use
  91511. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91512. * (Default is 0)
  91513. */
  91514. fogStart: number;
  91515. /**
  91516. * Gets or sets the fog end distance to use
  91517. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91518. * (Default is 1000)
  91519. */
  91520. fogEnd: number;
  91521. private _shadowsEnabled;
  91522. /**
  91523. * Gets or sets a boolean indicating if shadows are enabled on this scene
  91524. */
  91525. shadowsEnabled: boolean;
  91526. private _lightsEnabled;
  91527. /**
  91528. * Gets or sets a boolean indicating if lights are enabled on this scene
  91529. */
  91530. lightsEnabled: boolean;
  91531. /** All of the active cameras added to this scene. */
  91532. activeCameras: Camera[];
  91533. /** @hidden */
  91534. _activeCamera: Nullable<Camera>;
  91535. /** Gets or sets the current active camera */
  91536. activeCamera: Nullable<Camera>;
  91537. private _defaultMaterial;
  91538. /** The default material used on meshes when no material is affected */
  91539. /** The default material used on meshes when no material is affected */
  91540. defaultMaterial: Material;
  91541. private _texturesEnabled;
  91542. /**
  91543. * Gets or sets a boolean indicating if textures are enabled on this scene
  91544. */
  91545. texturesEnabled: boolean;
  91546. /**
  91547. * Gets or sets a boolean indicating if particles are enabled on this scene
  91548. */
  91549. particlesEnabled: boolean;
  91550. /**
  91551. * Gets or sets a boolean indicating if sprites are enabled on this scene
  91552. */
  91553. spritesEnabled: boolean;
  91554. private _skeletonsEnabled;
  91555. /**
  91556. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  91557. */
  91558. skeletonsEnabled: boolean;
  91559. /**
  91560. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  91561. */
  91562. lensFlaresEnabled: boolean;
  91563. /**
  91564. * Gets or sets a boolean indicating if collisions are enabled on this scene
  91565. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91566. */
  91567. collisionsEnabled: boolean;
  91568. private _collisionCoordinator;
  91569. /** @hidden */
  91570. readonly collisionCoordinator: ICollisionCoordinator;
  91571. /**
  91572. * Defines the gravity applied to this scene (used only for collisions)
  91573. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91574. */
  91575. gravity: Vector3;
  91576. /**
  91577. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  91578. */
  91579. postProcessesEnabled: boolean;
  91580. /**
  91581. * The list of postprocesses added to the scene
  91582. */
  91583. postProcesses: PostProcess[];
  91584. /**
  91585. * Gets the current postprocess manager
  91586. */
  91587. postProcessManager: PostProcessManager;
  91588. /**
  91589. * Gets or sets a boolean indicating if render targets are enabled on this scene
  91590. */
  91591. renderTargetsEnabled: boolean;
  91592. /**
  91593. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  91594. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  91595. */
  91596. dumpNextRenderTargets: boolean;
  91597. /**
  91598. * The list of user defined render targets added to the scene
  91599. */
  91600. customRenderTargets: RenderTargetTexture[];
  91601. /**
  91602. * Defines if texture loading must be delayed
  91603. * If true, textures will only be loaded when they need to be rendered
  91604. */
  91605. useDelayedTextureLoading: boolean;
  91606. /**
  91607. * Gets the list of meshes imported to the scene through SceneLoader
  91608. */
  91609. importedMeshesFiles: String[];
  91610. /**
  91611. * Gets or sets a boolean indicating if probes are enabled on this scene
  91612. */
  91613. probesEnabled: boolean;
  91614. /**
  91615. * Gets or sets the current offline provider to use to store scene data
  91616. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  91617. */
  91618. offlineProvider: IOfflineProvider;
  91619. /**
  91620. * Gets or sets the action manager associated with the scene
  91621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91622. */
  91623. actionManager: AbstractActionManager;
  91624. private _meshesForIntersections;
  91625. /**
  91626. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  91627. */
  91628. proceduralTexturesEnabled: boolean;
  91629. private _engine;
  91630. private _totalVertices;
  91631. /** @hidden */
  91632. _activeIndices: PerfCounter;
  91633. /** @hidden */
  91634. _activeParticles: PerfCounter;
  91635. /** @hidden */
  91636. _activeBones: PerfCounter;
  91637. private _animationRatio;
  91638. /** @hidden */
  91639. _animationTimeLast: number;
  91640. /** @hidden */
  91641. _animationTime: number;
  91642. /**
  91643. * Gets or sets a general scale for animation speed
  91644. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  91645. */
  91646. animationTimeScale: number;
  91647. /** @hidden */
  91648. _cachedMaterial: Nullable<Material>;
  91649. /** @hidden */
  91650. _cachedEffect: Nullable<Effect>;
  91651. /** @hidden */
  91652. _cachedVisibility: Nullable<number>;
  91653. private _renderId;
  91654. private _frameId;
  91655. private _executeWhenReadyTimeoutId;
  91656. private _intermediateRendering;
  91657. private _viewUpdateFlag;
  91658. private _projectionUpdateFlag;
  91659. /** @hidden */
  91660. _toBeDisposed: Nullable<IDisposable>[];
  91661. private _activeRequests;
  91662. /** @hidden */
  91663. _pendingData: any[];
  91664. private _isDisposed;
  91665. /**
  91666. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  91667. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  91668. */
  91669. dispatchAllSubMeshesOfActiveMeshes: boolean;
  91670. private _activeMeshes;
  91671. private _processedMaterials;
  91672. private _renderTargets;
  91673. /** @hidden */
  91674. _activeParticleSystems: SmartArray<IParticleSystem>;
  91675. private _activeSkeletons;
  91676. private _softwareSkinnedMeshes;
  91677. private _renderingManager;
  91678. /** @hidden */
  91679. _activeAnimatables: Animatable[];
  91680. private _transformMatrix;
  91681. private _sceneUbo;
  91682. /** @hidden */
  91683. _viewMatrix: Matrix;
  91684. private _projectionMatrix;
  91685. private _wheelEventName;
  91686. /** @hidden */
  91687. _forcedViewPosition: Nullable<Vector3>;
  91688. /** @hidden */
  91689. _frustumPlanes: Plane[];
  91690. /**
  91691. * Gets the list of frustum planes (built from the active camera)
  91692. */
  91693. readonly frustumPlanes: Plane[];
  91694. /**
  91695. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  91696. * This is useful if there are more lights that the maximum simulteanous authorized
  91697. */
  91698. requireLightSorting: boolean;
  91699. /** @hidden */
  91700. readonly useMaterialMeshMap: boolean;
  91701. /** @hidden */
  91702. readonly useClonedMeshhMap: boolean;
  91703. private _pointerOverMesh;
  91704. private _pickedDownMesh;
  91705. private _pickedUpMesh;
  91706. private _externalData;
  91707. private _uid;
  91708. /**
  91709. * @hidden
  91710. * Backing store of defined scene components.
  91711. */
  91712. _components: ISceneComponent[];
  91713. /**
  91714. * @hidden
  91715. * Backing store of defined scene components.
  91716. */
  91717. _serializableComponents: ISceneSerializableComponent[];
  91718. /**
  91719. * List of components to register on the next registration step.
  91720. */
  91721. private _transientComponents;
  91722. /**
  91723. * Registers the transient components if needed.
  91724. */
  91725. private _registerTransientComponents;
  91726. /**
  91727. * @hidden
  91728. * Add a component to the scene.
  91729. * Note that the ccomponent could be registered on th next frame if this is called after
  91730. * the register component stage.
  91731. * @param component Defines the component to add to the scene
  91732. */
  91733. _addComponent(component: ISceneComponent): void;
  91734. /**
  91735. * @hidden
  91736. * Gets a component from the scene.
  91737. * @param name defines the name of the component to retrieve
  91738. * @returns the component or null if not present
  91739. */
  91740. _getComponent(name: string): Nullable<ISceneComponent>;
  91741. /**
  91742. * @hidden
  91743. * Defines the actions happening before camera updates.
  91744. */
  91745. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  91746. /**
  91747. * @hidden
  91748. * Defines the actions happening before clear the canvas.
  91749. */
  91750. _beforeClearStage: Stage<SimpleStageAction>;
  91751. /**
  91752. * @hidden
  91753. * Defines the actions when collecting render targets for the frame.
  91754. */
  91755. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  91756. /**
  91757. * @hidden
  91758. * Defines the actions happening for one camera in the frame.
  91759. */
  91760. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  91761. /**
  91762. * @hidden
  91763. * Defines the actions happening during the per mesh ready checks.
  91764. */
  91765. _isReadyForMeshStage: Stage<MeshStageAction>;
  91766. /**
  91767. * @hidden
  91768. * Defines the actions happening before evaluate active mesh checks.
  91769. */
  91770. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  91771. /**
  91772. * @hidden
  91773. * Defines the actions happening during the evaluate sub mesh checks.
  91774. */
  91775. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  91776. /**
  91777. * @hidden
  91778. * Defines the actions happening during the active mesh stage.
  91779. */
  91780. _activeMeshStage: Stage<ActiveMeshStageAction>;
  91781. /**
  91782. * @hidden
  91783. * Defines the actions happening during the per camera render target step.
  91784. */
  91785. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  91786. /**
  91787. * @hidden
  91788. * Defines the actions happening just before the active camera is drawing.
  91789. */
  91790. _beforeCameraDrawStage: Stage<CameraStageAction>;
  91791. /**
  91792. * @hidden
  91793. * Defines the actions happening just before a render target is drawing.
  91794. */
  91795. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  91796. /**
  91797. * @hidden
  91798. * Defines the actions happening just before a rendering group is drawing.
  91799. */
  91800. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  91801. /**
  91802. * @hidden
  91803. * Defines the actions happening just before a mesh is drawing.
  91804. */
  91805. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  91806. /**
  91807. * @hidden
  91808. * Defines the actions happening just after a mesh has been drawn.
  91809. */
  91810. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  91811. /**
  91812. * @hidden
  91813. * Defines the actions happening just after a rendering group has been drawn.
  91814. */
  91815. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  91816. /**
  91817. * @hidden
  91818. * Defines the actions happening just after the active camera has been drawn.
  91819. */
  91820. _afterCameraDrawStage: Stage<CameraStageAction>;
  91821. /**
  91822. * @hidden
  91823. * Defines the actions happening just after a render target has been drawn.
  91824. */
  91825. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  91826. /**
  91827. * @hidden
  91828. * Defines the actions happening just after rendering all cameras and computing intersections.
  91829. */
  91830. _afterRenderStage: Stage<SimpleStageAction>;
  91831. /**
  91832. * @hidden
  91833. * Defines the actions happening when a pointer move event happens.
  91834. */
  91835. _pointerMoveStage: Stage<PointerMoveStageAction>;
  91836. /**
  91837. * @hidden
  91838. * Defines the actions happening when a pointer down event happens.
  91839. */
  91840. _pointerDownStage: Stage<PointerUpDownStageAction>;
  91841. /**
  91842. * @hidden
  91843. * Defines the actions happening when a pointer up event happens.
  91844. */
  91845. _pointerUpStage: Stage<PointerUpDownStageAction>;
  91846. /**
  91847. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  91848. */
  91849. private geometriesByUniqueId;
  91850. /**
  91851. * Creates a new Scene
  91852. * @param engine defines the engine to use to render this scene
  91853. * @param options defines the scene options
  91854. */
  91855. constructor(engine: Engine, options?: SceneOptions);
  91856. /**
  91857. * Gets a string idenfifying the name of the class
  91858. * @returns "Scene" string
  91859. */
  91860. getClassName(): string;
  91861. private _defaultMeshCandidates;
  91862. /**
  91863. * @hidden
  91864. */
  91865. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  91866. private _defaultSubMeshCandidates;
  91867. /**
  91868. * @hidden
  91869. */
  91870. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  91871. /**
  91872. * Sets the default candidate providers for the scene.
  91873. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  91874. * and getCollidingSubMeshCandidates to their default function
  91875. */
  91876. setDefaultCandidateProviders(): void;
  91877. /**
  91878. * Gets the mesh that is currently under the pointer
  91879. */
  91880. readonly meshUnderPointer: Nullable<AbstractMesh>;
  91881. /**
  91882. * Gets or sets the current on-screen X position of the pointer
  91883. */
  91884. pointerX: number;
  91885. /**
  91886. * Gets or sets the current on-screen Y position of the pointer
  91887. */
  91888. pointerY: number;
  91889. /**
  91890. * Gets the cached material (ie. the latest rendered one)
  91891. * @returns the cached material
  91892. */
  91893. getCachedMaterial(): Nullable<Material>;
  91894. /**
  91895. * Gets the cached effect (ie. the latest rendered one)
  91896. * @returns the cached effect
  91897. */
  91898. getCachedEffect(): Nullable<Effect>;
  91899. /**
  91900. * Gets the cached visibility state (ie. the latest rendered one)
  91901. * @returns the cached visibility state
  91902. */
  91903. getCachedVisibility(): Nullable<number>;
  91904. /**
  91905. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  91906. * @param material defines the current material
  91907. * @param effect defines the current effect
  91908. * @param visibility defines the current visibility state
  91909. * @returns true if one parameter is not cached
  91910. */
  91911. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  91912. /**
  91913. * Gets the engine associated with the scene
  91914. * @returns an Engine
  91915. */
  91916. getEngine(): Engine;
  91917. /**
  91918. * Gets the total number of vertices rendered per frame
  91919. * @returns the total number of vertices rendered per frame
  91920. */
  91921. getTotalVertices(): number;
  91922. /**
  91923. * Gets the performance counter for total vertices
  91924. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91925. */
  91926. readonly totalVerticesPerfCounter: PerfCounter;
  91927. /**
  91928. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  91929. * @returns the total number of active indices rendered per frame
  91930. */
  91931. getActiveIndices(): number;
  91932. /**
  91933. * Gets the performance counter for active indices
  91934. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91935. */
  91936. readonly totalActiveIndicesPerfCounter: PerfCounter;
  91937. /**
  91938. * Gets the total number of active particles rendered per frame
  91939. * @returns the total number of active particles rendered per frame
  91940. */
  91941. getActiveParticles(): number;
  91942. /**
  91943. * Gets the performance counter for active particles
  91944. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91945. */
  91946. readonly activeParticlesPerfCounter: PerfCounter;
  91947. /**
  91948. * Gets the total number of active bones rendered per frame
  91949. * @returns the total number of active bones rendered per frame
  91950. */
  91951. getActiveBones(): number;
  91952. /**
  91953. * Gets the performance counter for active bones
  91954. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91955. */
  91956. readonly activeBonesPerfCounter: PerfCounter;
  91957. /**
  91958. * Gets the array of active meshes
  91959. * @returns an array of AbstractMesh
  91960. */
  91961. getActiveMeshes(): SmartArray<AbstractMesh>;
  91962. /**
  91963. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  91964. * @returns a number
  91965. */
  91966. getAnimationRatio(): number;
  91967. /**
  91968. * Gets an unique Id for the current render phase
  91969. * @returns a number
  91970. */
  91971. getRenderId(): number;
  91972. /**
  91973. * Gets an unique Id for the current frame
  91974. * @returns a number
  91975. */
  91976. getFrameId(): number;
  91977. /** Call this function if you want to manually increment the render Id*/
  91978. incrementRenderId(): void;
  91979. private _updatePointerPosition;
  91980. private _createUbo;
  91981. private _setRayOnPointerInfo;
  91982. /**
  91983. * Use this method to simulate a pointer move on a mesh
  91984. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91985. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91986. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91987. * @returns the current scene
  91988. */
  91989. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  91990. private _processPointerMove;
  91991. private _checkPrePointerObservable;
  91992. /**
  91993. * Use this method to simulate a pointer down on a mesh
  91994. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91995. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91996. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91997. * @returns the current scene
  91998. */
  91999. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92000. private _processPointerDown;
  92001. /**
  92002. * Use this method to simulate a pointer up on a mesh
  92003. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92004. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92005. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92006. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  92007. * @returns the current scene
  92008. */
  92009. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  92010. private _processPointerUp;
  92011. /**
  92012. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  92013. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  92014. * @returns true if the pointer was captured
  92015. */
  92016. isPointerCaptured(pointerId?: number): boolean;
  92017. /** @hidden */
  92018. _isPointerSwiping(): boolean;
  92019. /**
  92020. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  92021. * @param attachUp defines if you want to attach events to pointerup
  92022. * @param attachDown defines if you want to attach events to pointerdown
  92023. * @param attachMove defines if you want to attach events to pointermove
  92024. */
  92025. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  92026. /** Detaches all event handlers*/
  92027. detachControl(): void;
  92028. /**
  92029. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  92030. * Delay loaded resources are not taking in account
  92031. * @return true if all required resources are ready
  92032. */
  92033. isReady(): boolean;
  92034. /** Resets all cached information relative to material (including effect and visibility) */
  92035. resetCachedMaterial(): void;
  92036. /**
  92037. * Registers a function to be called before every frame render
  92038. * @param func defines the function to register
  92039. */
  92040. registerBeforeRender(func: () => void): void;
  92041. /**
  92042. * Unregisters a function called before every frame render
  92043. * @param func defines the function to unregister
  92044. */
  92045. unregisterBeforeRender(func: () => void): void;
  92046. /**
  92047. * Registers a function to be called after every frame render
  92048. * @param func defines the function to register
  92049. */
  92050. registerAfterRender(func: () => void): void;
  92051. /**
  92052. * Unregisters a function called after every frame render
  92053. * @param func defines the function to unregister
  92054. */
  92055. unregisterAfterRender(func: () => void): void;
  92056. private _executeOnceBeforeRender;
  92057. /**
  92058. * The provided function will run before render once and will be disposed afterwards.
  92059. * A timeout delay can be provided so that the function will be executed in N ms.
  92060. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  92061. * @param func The function to be executed.
  92062. * @param timeout optional delay in ms
  92063. */
  92064. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  92065. /** @hidden */
  92066. _addPendingData(data: any): void;
  92067. /** @hidden */
  92068. _removePendingData(data: any): void;
  92069. /**
  92070. * Returns the number of items waiting to be loaded
  92071. * @returns the number of items waiting to be loaded
  92072. */
  92073. getWaitingItemsCount(): number;
  92074. /**
  92075. * Returns a boolean indicating if the scene is still loading data
  92076. */
  92077. readonly isLoading: boolean;
  92078. /**
  92079. * Registers a function to be executed when the scene is ready
  92080. * @param {Function} func - the function to be executed
  92081. */
  92082. executeWhenReady(func: () => void): void;
  92083. /**
  92084. * Returns a promise that resolves when the scene is ready
  92085. * @returns A promise that resolves when the scene is ready
  92086. */
  92087. whenReadyAsync(): Promise<void>;
  92088. /** @hidden */
  92089. _checkIsReady(): void;
  92090. /**
  92091. * Gets all animatable attached to the scene
  92092. */
  92093. readonly animatables: Animatable[];
  92094. /**
  92095. * Resets the last animation time frame.
  92096. * Useful to override when animations start running when loading a scene for the first time.
  92097. */
  92098. resetLastAnimationTimeFrame(): void;
  92099. /**
  92100. * Gets the current view matrix
  92101. * @returns a Matrix
  92102. */
  92103. getViewMatrix(): Matrix;
  92104. /**
  92105. * Gets the current projection matrix
  92106. * @returns a Matrix
  92107. */
  92108. getProjectionMatrix(): Matrix;
  92109. /**
  92110. * Gets the current transform matrix
  92111. * @returns a Matrix made of View * Projection
  92112. */
  92113. getTransformMatrix(): Matrix;
  92114. /**
  92115. * Sets the current transform matrix
  92116. * @param viewL defines the View matrix to use
  92117. * @param projectionL defines the Projection matrix to use
  92118. * @param viewR defines the right View matrix to use (if provided)
  92119. * @param projectionR defines the right Projection matrix to use (if provided)
  92120. */
  92121. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  92122. /**
  92123. * Gets the uniform buffer used to store scene data
  92124. * @returns a UniformBuffer
  92125. */
  92126. getSceneUniformBuffer(): UniformBuffer;
  92127. /**
  92128. * Gets an unique (relatively to the current scene) Id
  92129. * @returns an unique number for the scene
  92130. */
  92131. getUniqueId(): number;
  92132. /**
  92133. * Add a mesh to the list of scene's meshes
  92134. * @param newMesh defines the mesh to add
  92135. * @param recursive if all child meshes should also be added to the scene
  92136. */
  92137. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  92138. /**
  92139. * Remove a mesh for the list of scene's meshes
  92140. * @param toRemove defines the mesh to remove
  92141. * @param recursive if all child meshes should also be removed from the scene
  92142. * @returns the index where the mesh was in the mesh list
  92143. */
  92144. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  92145. /**
  92146. * Add a transform node to the list of scene's transform nodes
  92147. * @param newTransformNode defines the transform node to add
  92148. */
  92149. addTransformNode(newTransformNode: TransformNode): void;
  92150. /**
  92151. * Remove a transform node for the list of scene's transform nodes
  92152. * @param toRemove defines the transform node to remove
  92153. * @returns the index where the transform node was in the transform node list
  92154. */
  92155. removeTransformNode(toRemove: TransformNode): number;
  92156. /**
  92157. * Remove a skeleton for the list of scene's skeletons
  92158. * @param toRemove defines the skeleton to remove
  92159. * @returns the index where the skeleton was in the skeleton list
  92160. */
  92161. removeSkeleton(toRemove: Skeleton): number;
  92162. /**
  92163. * Remove a morph target for the list of scene's morph targets
  92164. * @param toRemove defines the morph target to remove
  92165. * @returns the index where the morph target was in the morph target list
  92166. */
  92167. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  92168. /**
  92169. * Remove a light for the list of scene's lights
  92170. * @param toRemove defines the light to remove
  92171. * @returns the index where the light was in the light list
  92172. */
  92173. removeLight(toRemove: Light): number;
  92174. /**
  92175. * Remove a camera for the list of scene's cameras
  92176. * @param toRemove defines the camera to remove
  92177. * @returns the index where the camera was in the camera list
  92178. */
  92179. removeCamera(toRemove: Camera): number;
  92180. /**
  92181. * Remove a particle system for the list of scene's particle systems
  92182. * @param toRemove defines the particle system to remove
  92183. * @returns the index where the particle system was in the particle system list
  92184. */
  92185. removeParticleSystem(toRemove: IParticleSystem): number;
  92186. /**
  92187. * Remove a animation for the list of scene's animations
  92188. * @param toRemove defines the animation to remove
  92189. * @returns the index where the animation was in the animation list
  92190. */
  92191. removeAnimation(toRemove: Animation): number;
  92192. /**
  92193. * Removes the given animation group from this scene.
  92194. * @param toRemove The animation group to remove
  92195. * @returns The index of the removed animation group
  92196. */
  92197. removeAnimationGroup(toRemove: AnimationGroup): number;
  92198. /**
  92199. * Removes the given multi-material from this scene.
  92200. * @param toRemove The multi-material to remove
  92201. * @returns The index of the removed multi-material
  92202. */
  92203. removeMultiMaterial(toRemove: MultiMaterial): number;
  92204. /**
  92205. * Removes the given material from this scene.
  92206. * @param toRemove The material to remove
  92207. * @returns The index of the removed material
  92208. */
  92209. removeMaterial(toRemove: Material): number;
  92210. /**
  92211. * Removes the given action manager from this scene.
  92212. * @param toRemove The action manager to remove
  92213. * @returns The index of the removed action manager
  92214. */
  92215. removeActionManager(toRemove: AbstractActionManager): number;
  92216. /**
  92217. * Removes the given texture from this scene.
  92218. * @param toRemove The texture to remove
  92219. * @returns The index of the removed texture
  92220. */
  92221. removeTexture(toRemove: BaseTexture): number;
  92222. /**
  92223. * Adds the given light to this scene
  92224. * @param newLight The light to add
  92225. */
  92226. addLight(newLight: Light): void;
  92227. /**
  92228. * Sorts the list list based on light priorities
  92229. */
  92230. sortLightsByPriority(): void;
  92231. /**
  92232. * Adds the given camera to this scene
  92233. * @param newCamera The camera to add
  92234. */
  92235. addCamera(newCamera: Camera): void;
  92236. /**
  92237. * Adds the given skeleton to this scene
  92238. * @param newSkeleton The skeleton to add
  92239. */
  92240. addSkeleton(newSkeleton: Skeleton): void;
  92241. /**
  92242. * Adds the given particle system to this scene
  92243. * @param newParticleSystem The particle system to add
  92244. */
  92245. addParticleSystem(newParticleSystem: IParticleSystem): void;
  92246. /**
  92247. * Adds the given animation to this scene
  92248. * @param newAnimation The animation to add
  92249. */
  92250. addAnimation(newAnimation: Animation): void;
  92251. /**
  92252. * Adds the given animation group to this scene.
  92253. * @param newAnimationGroup The animation group to add
  92254. */
  92255. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  92256. /**
  92257. * Adds the given multi-material to this scene
  92258. * @param newMultiMaterial The multi-material to add
  92259. */
  92260. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  92261. /**
  92262. * Adds the given material to this scene
  92263. * @param newMaterial The material to add
  92264. */
  92265. addMaterial(newMaterial: Material): void;
  92266. /**
  92267. * Adds the given morph target to this scene
  92268. * @param newMorphTargetManager The morph target to add
  92269. */
  92270. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  92271. /**
  92272. * Adds the given geometry to this scene
  92273. * @param newGeometry The geometry to add
  92274. */
  92275. addGeometry(newGeometry: Geometry): void;
  92276. /**
  92277. * Adds the given action manager to this scene
  92278. * @param newActionManager The action manager to add
  92279. */
  92280. addActionManager(newActionManager: AbstractActionManager): void;
  92281. /**
  92282. * Adds the given texture to this scene.
  92283. * @param newTexture The texture to add
  92284. */
  92285. addTexture(newTexture: BaseTexture): void;
  92286. /**
  92287. * Switch active camera
  92288. * @param newCamera defines the new active camera
  92289. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  92290. */
  92291. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  92292. /**
  92293. * sets the active camera of the scene using its ID
  92294. * @param id defines the camera's ID
  92295. * @return the new active camera or null if none found.
  92296. */
  92297. setActiveCameraByID(id: string): Nullable<Camera>;
  92298. /**
  92299. * sets the active camera of the scene using its name
  92300. * @param name defines the camera's name
  92301. * @returns the new active camera or null if none found.
  92302. */
  92303. setActiveCameraByName(name: string): Nullable<Camera>;
  92304. /**
  92305. * get an animation group using its name
  92306. * @param name defines the material's name
  92307. * @return the animation group or null if none found.
  92308. */
  92309. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  92310. /**
  92311. * Get a material using its unique id
  92312. * @param uniqueId defines the material's unique id
  92313. * @return the material or null if none found.
  92314. */
  92315. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  92316. /**
  92317. * get a material using its id
  92318. * @param id defines the material's ID
  92319. * @return the material or null if none found.
  92320. */
  92321. getMaterialByID(id: string): Nullable<Material>;
  92322. /**
  92323. * Gets a material using its name
  92324. * @param name defines the material's name
  92325. * @return the material or null if none found.
  92326. */
  92327. getMaterialByName(name: string): Nullable<Material>;
  92328. /**
  92329. * Gets a camera using its id
  92330. * @param id defines the id to look for
  92331. * @returns the camera or null if not found
  92332. */
  92333. getCameraByID(id: string): Nullable<Camera>;
  92334. /**
  92335. * Gets a camera using its unique id
  92336. * @param uniqueId defines the unique id to look for
  92337. * @returns the camera or null if not found
  92338. */
  92339. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  92340. /**
  92341. * Gets a camera using its name
  92342. * @param name defines the camera's name
  92343. * @return the camera or null if none found.
  92344. */
  92345. getCameraByName(name: string): Nullable<Camera>;
  92346. /**
  92347. * Gets a bone using its id
  92348. * @param id defines the bone's id
  92349. * @return the bone or null if not found
  92350. */
  92351. getBoneByID(id: string): Nullable<Bone>;
  92352. /**
  92353. * Gets a bone using its id
  92354. * @param name defines the bone's name
  92355. * @return the bone or null if not found
  92356. */
  92357. getBoneByName(name: string): Nullable<Bone>;
  92358. /**
  92359. * Gets a light node using its name
  92360. * @param name defines the the light's name
  92361. * @return the light or null if none found.
  92362. */
  92363. getLightByName(name: string): Nullable<Light>;
  92364. /**
  92365. * Gets a light node using its id
  92366. * @param id defines the light's id
  92367. * @return the light or null if none found.
  92368. */
  92369. getLightByID(id: string): Nullable<Light>;
  92370. /**
  92371. * Gets a light node using its scene-generated unique ID
  92372. * @param uniqueId defines the light's unique id
  92373. * @return the light or null if none found.
  92374. */
  92375. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  92376. /**
  92377. * Gets a particle system by id
  92378. * @param id defines the particle system id
  92379. * @return the corresponding system or null if none found
  92380. */
  92381. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  92382. /**
  92383. * Gets a geometry using its ID
  92384. * @param id defines the geometry's id
  92385. * @return the geometry or null if none found.
  92386. */
  92387. getGeometryByID(id: string): Nullable<Geometry>;
  92388. private _getGeometryByUniqueID;
  92389. /**
  92390. * Add a new geometry to this scene
  92391. * @param geometry defines the geometry to be added to the scene.
  92392. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  92393. * @return a boolean defining if the geometry was added or not
  92394. */
  92395. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  92396. /**
  92397. * Removes an existing geometry
  92398. * @param geometry defines the geometry to be removed from the scene
  92399. * @return a boolean defining if the geometry was removed or not
  92400. */
  92401. removeGeometry(geometry: Geometry): boolean;
  92402. /**
  92403. * Gets the list of geometries attached to the scene
  92404. * @returns an array of Geometry
  92405. */
  92406. getGeometries(): Geometry[];
  92407. /**
  92408. * Gets the first added mesh found of a given ID
  92409. * @param id defines the id to search for
  92410. * @return the mesh found or null if not found at all
  92411. */
  92412. getMeshByID(id: string): Nullable<AbstractMesh>;
  92413. /**
  92414. * Gets a list of meshes using their id
  92415. * @param id defines the id to search for
  92416. * @returns a list of meshes
  92417. */
  92418. getMeshesByID(id: string): Array<AbstractMesh>;
  92419. /**
  92420. * Gets the first added transform node found of a given ID
  92421. * @param id defines the id to search for
  92422. * @return the found transform node or null if not found at all.
  92423. */
  92424. getTransformNodeByID(id: string): Nullable<TransformNode>;
  92425. /**
  92426. * Gets a transform node with its auto-generated unique id
  92427. * @param uniqueId efines the unique id to search for
  92428. * @return the found transform node or null if not found at all.
  92429. */
  92430. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  92431. /**
  92432. * Gets a list of transform nodes using their id
  92433. * @param id defines the id to search for
  92434. * @returns a list of transform nodes
  92435. */
  92436. getTransformNodesByID(id: string): Array<TransformNode>;
  92437. /**
  92438. * Gets a mesh with its auto-generated unique id
  92439. * @param uniqueId defines the unique id to search for
  92440. * @return the found mesh or null if not found at all.
  92441. */
  92442. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  92443. /**
  92444. * Gets a the last added mesh using a given id
  92445. * @param id defines the id to search for
  92446. * @return the found mesh or null if not found at all.
  92447. */
  92448. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  92449. /**
  92450. * Gets a the last added node (Mesh, Camera, Light) using a given id
  92451. * @param id defines the id to search for
  92452. * @return the found node or null if not found at all
  92453. */
  92454. getLastEntryByID(id: string): Nullable<Node>;
  92455. /**
  92456. * Gets a node (Mesh, Camera, Light) using a given id
  92457. * @param id defines the id to search for
  92458. * @return the found node or null if not found at all
  92459. */
  92460. getNodeByID(id: string): Nullable<Node>;
  92461. /**
  92462. * Gets a node (Mesh, Camera, Light) using a given name
  92463. * @param name defines the name to search for
  92464. * @return the found node or null if not found at all.
  92465. */
  92466. getNodeByName(name: string): Nullable<Node>;
  92467. /**
  92468. * Gets a mesh using a given name
  92469. * @param name defines the name to search for
  92470. * @return the found mesh or null if not found at all.
  92471. */
  92472. getMeshByName(name: string): Nullable<AbstractMesh>;
  92473. /**
  92474. * Gets a transform node using a given name
  92475. * @param name defines the name to search for
  92476. * @return the found transform node or null if not found at all.
  92477. */
  92478. getTransformNodeByName(name: string): Nullable<TransformNode>;
  92479. /**
  92480. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  92481. * @param id defines the id to search for
  92482. * @return the found skeleton or null if not found at all.
  92483. */
  92484. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  92485. /**
  92486. * Gets a skeleton using a given auto generated unique id
  92487. * @param uniqueId defines the unique id to search for
  92488. * @return the found skeleton or null if not found at all.
  92489. */
  92490. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  92491. /**
  92492. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  92493. * @param id defines the id to search for
  92494. * @return the found skeleton or null if not found at all.
  92495. */
  92496. getSkeletonById(id: string): Nullable<Skeleton>;
  92497. /**
  92498. * Gets a skeleton using a given name
  92499. * @param name defines the name to search for
  92500. * @return the found skeleton or null if not found at all.
  92501. */
  92502. getSkeletonByName(name: string): Nullable<Skeleton>;
  92503. /**
  92504. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  92505. * @param id defines the id to search for
  92506. * @return the found morph target manager or null if not found at all.
  92507. */
  92508. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  92509. /**
  92510. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  92511. * @param id defines the id to search for
  92512. * @return the found morph target or null if not found at all.
  92513. */
  92514. getMorphTargetById(id: string): Nullable<MorphTarget>;
  92515. /**
  92516. * Gets a boolean indicating if the given mesh is active
  92517. * @param mesh defines the mesh to look for
  92518. * @returns true if the mesh is in the active list
  92519. */
  92520. isActiveMesh(mesh: AbstractMesh): boolean;
  92521. /**
  92522. * Return a unique id as a string which can serve as an identifier for the scene
  92523. */
  92524. readonly uid: string;
  92525. /**
  92526. * Add an externaly attached data from its key.
  92527. * This method call will fail and return false, if such key already exists.
  92528. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  92529. * @param key the unique key that identifies the data
  92530. * @param data the data object to associate to the key for this Engine instance
  92531. * @return true if no such key were already present and the data was added successfully, false otherwise
  92532. */
  92533. addExternalData<T>(key: string, data: T): boolean;
  92534. /**
  92535. * Get an externaly attached data from its key
  92536. * @param key the unique key that identifies the data
  92537. * @return the associated data, if present (can be null), or undefined if not present
  92538. */
  92539. getExternalData<T>(key: string): Nullable<T>;
  92540. /**
  92541. * Get an externaly attached data from its key, create it using a factory if it's not already present
  92542. * @param key the unique key that identifies the data
  92543. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  92544. * @return the associated data, can be null if the factory returned null.
  92545. */
  92546. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  92547. /**
  92548. * Remove an externaly attached data from the Engine instance
  92549. * @param key the unique key that identifies the data
  92550. * @return true if the data was successfully removed, false if it doesn't exist
  92551. */
  92552. removeExternalData(key: string): boolean;
  92553. private _evaluateSubMesh;
  92554. /**
  92555. * Clear the processed materials smart array preventing retention point in material dispose.
  92556. */
  92557. freeProcessedMaterials(): void;
  92558. private _preventFreeActiveMeshesAndRenderingGroups;
  92559. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  92560. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  92561. * when disposing several meshes in a row or a hierarchy of meshes.
  92562. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  92563. */
  92564. blockfreeActiveMeshesAndRenderingGroups: boolean;
  92565. /**
  92566. * Clear the active meshes smart array preventing retention point in mesh dispose.
  92567. */
  92568. freeActiveMeshes(): void;
  92569. /**
  92570. * Clear the info related to rendering groups preventing retention points during dispose.
  92571. */
  92572. freeRenderingGroups(): void;
  92573. /** @hidden */
  92574. _isInIntermediateRendering(): boolean;
  92575. /**
  92576. * Lambda returning the list of potentially active meshes.
  92577. */
  92578. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  92579. /**
  92580. * Lambda returning the list of potentially active sub meshes.
  92581. */
  92582. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  92583. /**
  92584. * Lambda returning the list of potentially intersecting sub meshes.
  92585. */
  92586. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  92587. /**
  92588. * Lambda returning the list of potentially colliding sub meshes.
  92589. */
  92590. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  92591. private _activeMeshesFrozen;
  92592. /**
  92593. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  92594. * @returns the current scene
  92595. */
  92596. freezeActiveMeshes(): Scene;
  92597. /**
  92598. * Use this function to restart evaluating active meshes on every frame
  92599. * @returns the current scene
  92600. */
  92601. unfreezeActiveMeshes(): Scene;
  92602. private _evaluateActiveMeshes;
  92603. private _activeMesh;
  92604. /**
  92605. * Update the transform matrix to update from the current active camera
  92606. * @param force defines a boolean used to force the update even if cache is up to date
  92607. */
  92608. updateTransformMatrix(force?: boolean): void;
  92609. private _bindFrameBuffer;
  92610. /** @hidden */
  92611. _allowPostProcessClearColor: boolean;
  92612. /** @hidden */
  92613. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  92614. private _processSubCameras;
  92615. private _checkIntersections;
  92616. /** @hidden */
  92617. _advancePhysicsEngineStep(step: number): void;
  92618. /**
  92619. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  92620. */
  92621. getDeterministicFrameTime: () => number;
  92622. /** @hidden */
  92623. _animate(): void;
  92624. /**
  92625. * Render the scene
  92626. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  92627. */
  92628. render(updateCameras?: boolean): void;
  92629. /**
  92630. * Freeze all materials
  92631. * A frozen material will not be updatable but should be faster to render
  92632. */
  92633. freezeMaterials(): void;
  92634. /**
  92635. * Unfreeze all materials
  92636. * A frozen material will not be updatable but should be faster to render
  92637. */
  92638. unfreezeMaterials(): void;
  92639. /**
  92640. * Releases all held ressources
  92641. */
  92642. dispose(): void;
  92643. /**
  92644. * Gets if the scene is already disposed
  92645. */
  92646. readonly isDisposed: boolean;
  92647. /**
  92648. * Call this function to reduce memory footprint of the scene.
  92649. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  92650. */
  92651. clearCachedVertexData(): void;
  92652. /**
  92653. * This function will remove the local cached buffer data from texture.
  92654. * It will save memory but will prevent the texture from being rebuilt
  92655. */
  92656. cleanCachedTextureBuffer(): void;
  92657. /**
  92658. * Get the world extend vectors with an optional filter
  92659. *
  92660. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  92661. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  92662. */
  92663. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  92664. min: Vector3;
  92665. max: Vector3;
  92666. };
  92667. /**
  92668. * Creates a ray that can be used to pick in the scene
  92669. * @param x defines the x coordinate of the origin (on-screen)
  92670. * @param y defines the y coordinate of the origin (on-screen)
  92671. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  92672. * @param camera defines the camera to use for the picking
  92673. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  92674. * @returns a Ray
  92675. */
  92676. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  92677. /**
  92678. * Creates a ray that can be used to pick in the scene
  92679. * @param x defines the x coordinate of the origin (on-screen)
  92680. * @param y defines the y coordinate of the origin (on-screen)
  92681. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  92682. * @param result defines the ray where to store the picking ray
  92683. * @param camera defines the camera to use for the picking
  92684. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  92685. * @returns the current scene
  92686. */
  92687. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  92688. /**
  92689. * Creates a ray that can be used to pick in the scene
  92690. * @param x defines the x coordinate of the origin (on-screen)
  92691. * @param y defines the y coordinate of the origin (on-screen)
  92692. * @param camera defines the camera to use for the picking
  92693. * @returns a Ray
  92694. */
  92695. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  92696. /**
  92697. * Creates a ray that can be used to pick in the scene
  92698. * @param x defines the x coordinate of the origin (on-screen)
  92699. * @param y defines the y coordinate of the origin (on-screen)
  92700. * @param result defines the ray where to store the picking ray
  92701. * @param camera defines the camera to use for the picking
  92702. * @returns the current scene
  92703. */
  92704. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  92705. /** Launch a ray to try to pick a mesh in the scene
  92706. * @param x position on screen
  92707. * @param y position on screen
  92708. * @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
  92709. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  92710. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92711. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92712. * @returns a PickingInfo
  92713. */
  92714. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  92715. /** Use the given ray to pick a mesh in the scene
  92716. * @param ray The ray to use to pick meshes
  92717. * @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
  92718. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  92719. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92720. * @returns a PickingInfo
  92721. */
  92722. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  92723. /**
  92724. * Launch a ray to try to pick a mesh in the scene
  92725. * @param x X position on screen
  92726. * @param y Y position on screen
  92727. * @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
  92728. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92729. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92730. * @returns an array of PickingInfo
  92731. */
  92732. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92733. /**
  92734. * Launch a ray to try to pick a mesh in the scene
  92735. * @param ray Ray to use
  92736. * @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
  92737. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92738. * @returns an array of PickingInfo
  92739. */
  92740. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92741. /**
  92742. * Force the value of meshUnderPointer
  92743. * @param mesh defines the mesh to use
  92744. */
  92745. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  92746. /**
  92747. * Gets the mesh under the pointer
  92748. * @returns a Mesh or null if no mesh is under the pointer
  92749. */
  92750. getPointerOverMesh(): Nullable<AbstractMesh>;
  92751. /** @hidden */
  92752. _rebuildGeometries(): void;
  92753. /** @hidden */
  92754. _rebuildTextures(): void;
  92755. private _getByTags;
  92756. /**
  92757. * Get a list of meshes by tags
  92758. * @param tagsQuery defines the tags query to use
  92759. * @param forEach defines a predicate used to filter results
  92760. * @returns an array of Mesh
  92761. */
  92762. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  92763. /**
  92764. * Get a list of cameras by tags
  92765. * @param tagsQuery defines the tags query to use
  92766. * @param forEach defines a predicate used to filter results
  92767. * @returns an array of Camera
  92768. */
  92769. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  92770. /**
  92771. * Get a list of lights by tags
  92772. * @param tagsQuery defines the tags query to use
  92773. * @param forEach defines a predicate used to filter results
  92774. * @returns an array of Light
  92775. */
  92776. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  92777. /**
  92778. * Get a list of materials by tags
  92779. * @param tagsQuery defines the tags query to use
  92780. * @param forEach defines a predicate used to filter results
  92781. * @returns an array of Material
  92782. */
  92783. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  92784. /**
  92785. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  92786. * This allowed control for front to back rendering or reversly depending of the special needs.
  92787. *
  92788. * @param renderingGroupId The rendering group id corresponding to its index
  92789. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  92790. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  92791. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  92792. */
  92793. 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;
  92794. /**
  92795. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  92796. *
  92797. * @param renderingGroupId The rendering group id corresponding to its index
  92798. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  92799. * @param depth Automatically clears depth between groups if true and autoClear is true.
  92800. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  92801. */
  92802. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  92803. /**
  92804. * Gets the current auto clear configuration for one rendering group of the rendering
  92805. * manager.
  92806. * @param index the rendering group index to get the information for
  92807. * @returns The auto clear setup for the requested rendering group
  92808. */
  92809. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  92810. private _blockMaterialDirtyMechanism;
  92811. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  92812. blockMaterialDirtyMechanism: boolean;
  92813. /**
  92814. * Will flag all materials as dirty to trigger new shader compilation
  92815. * @param flag defines the flag used to specify which material part must be marked as dirty
  92816. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  92817. */
  92818. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  92819. /** @hidden */
  92820. _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;
  92821. /** @hidden */
  92822. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  92823. }
  92824. }
  92825. declare module BABYLON {
  92826. /**
  92827. * Set of assets to keep when moving a scene into an asset container.
  92828. */
  92829. export class KeepAssets extends AbstractScene {
  92830. }
  92831. /**
  92832. * Container with a set of assets that can be added or removed from a scene.
  92833. */
  92834. export class AssetContainer extends AbstractScene {
  92835. /**
  92836. * The scene the AssetContainer belongs to.
  92837. */
  92838. scene: Scene;
  92839. /**
  92840. * Instantiates an AssetContainer.
  92841. * @param scene The scene the AssetContainer belongs to.
  92842. */
  92843. constructor(scene: Scene);
  92844. /**
  92845. * Adds all the assets from the container to the scene.
  92846. */
  92847. addAllToScene(): void;
  92848. /**
  92849. * Removes all the assets in the container from the scene
  92850. */
  92851. removeAllFromScene(): void;
  92852. /**
  92853. * Disposes all the assets in the container
  92854. */
  92855. dispose(): void;
  92856. private _moveAssets;
  92857. /**
  92858. * Removes all the assets contained in the scene and adds them to the container.
  92859. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  92860. */
  92861. moveAllFromScene(keepAssets?: KeepAssets): void;
  92862. /**
  92863. * 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.
  92864. * @returns the root mesh
  92865. */
  92866. createRootMesh(): Mesh;
  92867. }
  92868. }
  92869. declare module BABYLON {
  92870. /**
  92871. * Defines how the parser contract is defined.
  92872. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  92873. */
  92874. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  92875. /**
  92876. * Defines how the individual parser contract is defined.
  92877. * These parser can parse an individual asset
  92878. */
  92879. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  92880. /**
  92881. * Base class of the scene acting as a container for the different elements composing a scene.
  92882. * This class is dynamically extended by the different components of the scene increasing
  92883. * flexibility and reducing coupling
  92884. */
  92885. export abstract class AbstractScene {
  92886. /**
  92887. * Stores the list of available parsers in the application.
  92888. */
  92889. private static _BabylonFileParsers;
  92890. /**
  92891. * Stores the list of available individual parsers in the application.
  92892. */
  92893. private static _IndividualBabylonFileParsers;
  92894. /**
  92895. * Adds a parser in the list of available ones
  92896. * @param name Defines the name of the parser
  92897. * @param parser Defines the parser to add
  92898. */
  92899. static AddParser(name: string, parser: BabylonFileParser): void;
  92900. /**
  92901. * Gets a general parser from the list of avaialble ones
  92902. * @param name Defines the name of the parser
  92903. * @returns the requested parser or null
  92904. */
  92905. static GetParser(name: string): Nullable<BabylonFileParser>;
  92906. /**
  92907. * Adds n individual parser in the list of available ones
  92908. * @param name Defines the name of the parser
  92909. * @param parser Defines the parser to add
  92910. */
  92911. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  92912. /**
  92913. * Gets an individual parser from the list of avaialble ones
  92914. * @param name Defines the name of the parser
  92915. * @returns the requested parser or null
  92916. */
  92917. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  92918. /**
  92919. * Parser json data and populate both a scene and its associated container object
  92920. * @param jsonData Defines the data to parse
  92921. * @param scene Defines the scene to parse the data for
  92922. * @param container Defines the container attached to the parsing sequence
  92923. * @param rootUrl Defines the root url of the data
  92924. */
  92925. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  92926. /**
  92927. * Gets the list of root nodes (ie. nodes with no parent)
  92928. */
  92929. rootNodes: Node[];
  92930. /** All of the cameras added to this scene
  92931. * @see http://doc.babylonjs.com/babylon101/cameras
  92932. */
  92933. cameras: Camera[];
  92934. /**
  92935. * All of the lights added to this scene
  92936. * @see http://doc.babylonjs.com/babylon101/lights
  92937. */
  92938. lights: Light[];
  92939. /**
  92940. * All of the (abstract) meshes added to this scene
  92941. */
  92942. meshes: AbstractMesh[];
  92943. /**
  92944. * The list of skeletons added to the scene
  92945. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92946. */
  92947. skeletons: Skeleton[];
  92948. /**
  92949. * All of the particle systems added to this scene
  92950. * @see http://doc.babylonjs.com/babylon101/particles
  92951. */
  92952. particleSystems: IParticleSystem[];
  92953. /**
  92954. * Gets a list of Animations associated with the scene
  92955. */
  92956. animations: Animation[];
  92957. /**
  92958. * All of the animation groups added to this scene
  92959. * @see http://doc.babylonjs.com/how_to/group
  92960. */
  92961. animationGroups: AnimationGroup[];
  92962. /**
  92963. * All of the multi-materials added to this scene
  92964. * @see http://doc.babylonjs.com/how_to/multi_materials
  92965. */
  92966. multiMaterials: MultiMaterial[];
  92967. /**
  92968. * All of the materials added to this scene
  92969. * In the context of a Scene, it is not supposed to be modified manually.
  92970. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  92971. * Note also that the order of the Material wihin the array is not significant and might change.
  92972. * @see http://doc.babylonjs.com/babylon101/materials
  92973. */
  92974. materials: Material[];
  92975. /**
  92976. * The list of morph target managers added to the scene
  92977. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  92978. */
  92979. morphTargetManagers: MorphTargetManager[];
  92980. /**
  92981. * The list of geometries used in the scene.
  92982. */
  92983. geometries: Geometry[];
  92984. /**
  92985. * All of the tranform nodes added to this scene
  92986. * In the context of a Scene, it is not supposed to be modified manually.
  92987. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  92988. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  92989. * @see http://doc.babylonjs.com/how_to/transformnode
  92990. */
  92991. transformNodes: TransformNode[];
  92992. /**
  92993. * ActionManagers available on the scene.
  92994. */
  92995. actionManagers: AbstractActionManager[];
  92996. /**
  92997. * Textures to keep.
  92998. */
  92999. textures: BaseTexture[];
  93000. /**
  93001. * Environment texture for the scene
  93002. */
  93003. environmentTexture: Nullable<BaseTexture>;
  93004. }
  93005. }
  93006. declare module BABYLON {
  93007. /**
  93008. * Defines a sound that can be played in the application.
  93009. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  93010. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93011. */
  93012. export class Sound {
  93013. /**
  93014. * The name of the sound in the scene.
  93015. */
  93016. name: string;
  93017. /**
  93018. * Does the sound autoplay once loaded.
  93019. */
  93020. autoplay: boolean;
  93021. /**
  93022. * Does the sound loop after it finishes playing once.
  93023. */
  93024. loop: boolean;
  93025. /**
  93026. * Does the sound use a custom attenuation curve to simulate the falloff
  93027. * happening when the source gets further away from the camera.
  93028. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93029. */
  93030. useCustomAttenuation: boolean;
  93031. /**
  93032. * The sound track id this sound belongs to.
  93033. */
  93034. soundTrackId: number;
  93035. /**
  93036. * Is this sound currently played.
  93037. */
  93038. isPlaying: boolean;
  93039. /**
  93040. * Is this sound currently paused.
  93041. */
  93042. isPaused: boolean;
  93043. /**
  93044. * Does this sound enables spatial sound.
  93045. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93046. */
  93047. spatialSound: boolean;
  93048. /**
  93049. * Define the reference distance the sound should be heard perfectly.
  93050. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93051. */
  93052. refDistance: number;
  93053. /**
  93054. * Define the roll off factor of spatial sounds.
  93055. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93056. */
  93057. rolloffFactor: number;
  93058. /**
  93059. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  93060. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93061. */
  93062. maxDistance: number;
  93063. /**
  93064. * Define the distance attenuation model the sound will follow.
  93065. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93066. */
  93067. distanceModel: string;
  93068. /**
  93069. * @hidden
  93070. * Back Compat
  93071. **/
  93072. onended: () => any;
  93073. /**
  93074. * Observable event when the current playing sound finishes.
  93075. */
  93076. onEndedObservable: Observable<Sound>;
  93077. private _panningModel;
  93078. private _playbackRate;
  93079. private _streaming;
  93080. private _startTime;
  93081. private _startOffset;
  93082. private _position;
  93083. /** @hidden */
  93084. _positionInEmitterSpace: boolean;
  93085. private _localDirection;
  93086. private _volume;
  93087. private _isReadyToPlay;
  93088. private _isDirectional;
  93089. private _readyToPlayCallback;
  93090. private _audioBuffer;
  93091. private _soundSource;
  93092. private _streamingSource;
  93093. private _soundPanner;
  93094. private _soundGain;
  93095. private _inputAudioNode;
  93096. private _outputAudioNode;
  93097. private _coneInnerAngle;
  93098. private _coneOuterAngle;
  93099. private _coneOuterGain;
  93100. private _scene;
  93101. private _connectedTransformNode;
  93102. private _customAttenuationFunction;
  93103. private _registerFunc;
  93104. private _isOutputConnected;
  93105. private _htmlAudioElement;
  93106. private _urlType;
  93107. /** @hidden */
  93108. static _SceneComponentInitialization: (scene: Scene) => void;
  93109. /**
  93110. * Create a sound and attach it to a scene
  93111. * @param name Name of your sound
  93112. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  93113. * @param scene defines the scene the sound belongs to
  93114. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  93115. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  93116. */
  93117. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  93118. /**
  93119. * Release the sound and its associated resources
  93120. */
  93121. dispose(): void;
  93122. /**
  93123. * Gets if the sounds is ready to be played or not.
  93124. * @returns true if ready, otherwise false
  93125. */
  93126. isReady(): boolean;
  93127. private _soundLoaded;
  93128. /**
  93129. * Sets the data of the sound from an audiobuffer
  93130. * @param audioBuffer The audioBuffer containing the data
  93131. */
  93132. setAudioBuffer(audioBuffer: AudioBuffer): void;
  93133. /**
  93134. * Updates the current sounds options such as maxdistance, loop...
  93135. * @param options A JSON object containing values named as the object properties
  93136. */
  93137. updateOptions(options: any): void;
  93138. private _createSpatialParameters;
  93139. private _updateSpatialParameters;
  93140. /**
  93141. * Switch the panning model to HRTF:
  93142. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93143. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93144. */
  93145. switchPanningModelToHRTF(): void;
  93146. /**
  93147. * Switch the panning model to Equal Power:
  93148. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93149. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93150. */
  93151. switchPanningModelToEqualPower(): void;
  93152. private _switchPanningModel;
  93153. /**
  93154. * Connect this sound to a sound track audio node like gain...
  93155. * @param soundTrackAudioNode the sound track audio node to connect to
  93156. */
  93157. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  93158. /**
  93159. * Transform this sound into a directional source
  93160. * @param coneInnerAngle Size of the inner cone in degree
  93161. * @param coneOuterAngle Size of the outer cone in degree
  93162. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  93163. */
  93164. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  93165. /**
  93166. * Gets or sets the inner angle for the directional cone.
  93167. */
  93168. /**
  93169. * Gets or sets the inner angle for the directional cone.
  93170. */
  93171. directionalConeInnerAngle: number;
  93172. /**
  93173. * Gets or sets the outer angle for the directional cone.
  93174. */
  93175. /**
  93176. * Gets or sets the outer angle for the directional cone.
  93177. */
  93178. directionalConeOuterAngle: number;
  93179. /**
  93180. * Sets the position of the emitter if spatial sound is enabled
  93181. * @param newPosition Defines the new posisiton
  93182. */
  93183. setPosition(newPosition: Vector3): void;
  93184. /**
  93185. * Sets the local direction of the emitter if spatial sound is enabled
  93186. * @param newLocalDirection Defines the new local direction
  93187. */
  93188. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  93189. private _updateDirection;
  93190. /** @hidden */
  93191. updateDistanceFromListener(): void;
  93192. /**
  93193. * Sets a new custom attenuation function for the sound.
  93194. * @param callback Defines the function used for the attenuation
  93195. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93196. */
  93197. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  93198. /**
  93199. * Play the sound
  93200. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  93201. * @param offset (optional) Start the sound setting it at a specific time
  93202. */
  93203. play(time?: number, offset?: number): void;
  93204. private _onended;
  93205. /**
  93206. * Stop the sound
  93207. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  93208. */
  93209. stop(time?: number): void;
  93210. /**
  93211. * Put the sound in pause
  93212. */
  93213. pause(): void;
  93214. /**
  93215. * Sets a dedicated volume for this sounds
  93216. * @param newVolume Define the new volume of the sound
  93217. * @param time Define in how long the sound should be at this value
  93218. */
  93219. setVolume(newVolume: number, time?: number): void;
  93220. /**
  93221. * Set the sound play back rate
  93222. * @param newPlaybackRate Define the playback rate the sound should be played at
  93223. */
  93224. setPlaybackRate(newPlaybackRate: number): void;
  93225. /**
  93226. * Gets the volume of the sound.
  93227. * @returns the volume of the sound
  93228. */
  93229. getVolume(): number;
  93230. /**
  93231. * Attach the sound to a dedicated mesh
  93232. * @param transformNode The transform node to connect the sound with
  93233. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  93234. */
  93235. attachToMesh(transformNode: TransformNode): void;
  93236. /**
  93237. * Detach the sound from the previously attached mesh
  93238. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  93239. */
  93240. detachFromMesh(): void;
  93241. private _onRegisterAfterWorldMatrixUpdate;
  93242. /**
  93243. * Clone the current sound in the scene.
  93244. * @returns the new sound clone
  93245. */
  93246. clone(): Nullable<Sound>;
  93247. /**
  93248. * Gets the current underlying audio buffer containing the data
  93249. * @returns the audio buffer
  93250. */
  93251. getAudioBuffer(): Nullable<AudioBuffer>;
  93252. /**
  93253. * Serializes the Sound in a JSON representation
  93254. * @returns the JSON representation of the sound
  93255. */
  93256. serialize(): any;
  93257. /**
  93258. * Parse a JSON representation of a sound to innstantiate in a given scene
  93259. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  93260. * @param scene Define the scene the new parsed sound should be created in
  93261. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  93262. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  93263. * @returns the newly parsed sound
  93264. */
  93265. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  93266. }
  93267. }
  93268. declare module BABYLON {
  93269. /**
  93270. * This defines an action helpful to play a defined sound on a triggered action.
  93271. */
  93272. export class PlaySoundAction extends Action {
  93273. private _sound;
  93274. /**
  93275. * Instantiate the action
  93276. * @param triggerOptions defines the trigger options
  93277. * @param sound defines the sound to play
  93278. * @param condition defines the trigger related conditions
  93279. */
  93280. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  93281. /** @hidden */
  93282. _prepare(): void;
  93283. /**
  93284. * Execute the action and play the sound.
  93285. */
  93286. execute(): void;
  93287. /**
  93288. * Serializes the actions and its related information.
  93289. * @param parent defines the object to serialize in
  93290. * @returns the serialized object
  93291. */
  93292. serialize(parent: any): any;
  93293. }
  93294. /**
  93295. * This defines an action helpful to stop a defined sound on a triggered action.
  93296. */
  93297. export class StopSoundAction extends Action {
  93298. private _sound;
  93299. /**
  93300. * Instantiate the action
  93301. * @param triggerOptions defines the trigger options
  93302. * @param sound defines the sound to stop
  93303. * @param condition defines the trigger related conditions
  93304. */
  93305. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  93306. /** @hidden */
  93307. _prepare(): void;
  93308. /**
  93309. * Execute the action and stop the sound.
  93310. */
  93311. execute(): void;
  93312. /**
  93313. * Serializes the actions and its related information.
  93314. * @param parent defines the object to serialize in
  93315. * @returns the serialized object
  93316. */
  93317. serialize(parent: any): any;
  93318. }
  93319. }
  93320. declare module BABYLON {
  93321. /**
  93322. * This defines an action responsible to change the value of a property
  93323. * by interpolating between its current value and the newly set one once triggered.
  93324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93325. */
  93326. export class InterpolateValueAction extends Action {
  93327. /**
  93328. * Defines the path of the property where the value should be interpolated
  93329. */
  93330. propertyPath: string;
  93331. /**
  93332. * Defines the target value at the end of the interpolation.
  93333. */
  93334. value: any;
  93335. /**
  93336. * Defines the time it will take for the property to interpolate to the value.
  93337. */
  93338. duration: number;
  93339. /**
  93340. * Defines if the other scene animations should be stopped when the action has been triggered
  93341. */
  93342. stopOtherAnimations?: boolean;
  93343. /**
  93344. * Defines a callback raised once the interpolation animation has been done.
  93345. */
  93346. onInterpolationDone?: () => void;
  93347. /**
  93348. * Observable triggered once the interpolation animation has been done.
  93349. */
  93350. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  93351. private _target;
  93352. private _effectiveTarget;
  93353. private _property;
  93354. /**
  93355. * Instantiate the action
  93356. * @param triggerOptions defines the trigger options
  93357. * @param target defines the object containing the value to interpolate
  93358. * @param propertyPath defines the path to the property in the target object
  93359. * @param value defines the target value at the end of the interpolation
  93360. * @param duration deines the time it will take for the property to interpolate to the value.
  93361. * @param condition defines the trigger related conditions
  93362. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  93363. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  93364. */
  93365. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  93366. /** @hidden */
  93367. _prepare(): void;
  93368. /**
  93369. * Execute the action starts the value interpolation.
  93370. */
  93371. execute(): void;
  93372. /**
  93373. * Serializes the actions and its related information.
  93374. * @param parent defines the object to serialize in
  93375. * @returns the serialized object
  93376. */
  93377. serialize(parent: any): any;
  93378. }
  93379. }
  93380. declare module BABYLON {
  93381. /**
  93382. * Options allowed during the creation of a sound track.
  93383. */
  93384. export interface ISoundTrackOptions {
  93385. /**
  93386. * The volume the sound track should take during creation
  93387. */
  93388. volume?: number;
  93389. /**
  93390. * Define if the sound track is the main sound track of the scene
  93391. */
  93392. mainTrack?: boolean;
  93393. }
  93394. /**
  93395. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  93396. * It will be also used in a future release to apply effects on a specific track.
  93397. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  93398. */
  93399. export class SoundTrack {
  93400. /**
  93401. * The unique identifier of the sound track in the scene.
  93402. */
  93403. id: number;
  93404. /**
  93405. * The list of sounds included in the sound track.
  93406. */
  93407. soundCollection: Array<Sound>;
  93408. private _outputAudioNode;
  93409. private _scene;
  93410. private _isMainTrack;
  93411. private _connectedAnalyser;
  93412. private _options;
  93413. private _isInitialized;
  93414. /**
  93415. * Creates a new sound track.
  93416. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  93417. * @param scene Define the scene the sound track belongs to
  93418. * @param options
  93419. */
  93420. constructor(scene: Scene, options?: ISoundTrackOptions);
  93421. private _initializeSoundTrackAudioGraph;
  93422. /**
  93423. * Release the sound track and its associated resources
  93424. */
  93425. dispose(): void;
  93426. /**
  93427. * Adds a sound to this sound track
  93428. * @param sound define the cound to add
  93429. * @ignoreNaming
  93430. */
  93431. AddSound(sound: Sound): void;
  93432. /**
  93433. * Removes a sound to this sound track
  93434. * @param sound define the cound to remove
  93435. * @ignoreNaming
  93436. */
  93437. RemoveSound(sound: Sound): void;
  93438. /**
  93439. * Set a global volume for the full sound track.
  93440. * @param newVolume Define the new volume of the sound track
  93441. */
  93442. setVolume(newVolume: number): void;
  93443. /**
  93444. * Switch the panning model to HRTF:
  93445. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93446. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93447. */
  93448. switchPanningModelToHRTF(): void;
  93449. /**
  93450. * Switch the panning model to Equal Power:
  93451. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93452. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93453. */
  93454. switchPanningModelToEqualPower(): void;
  93455. /**
  93456. * Connect the sound track to an audio analyser allowing some amazing
  93457. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  93458. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  93459. * @param analyser The analyser to connect to the engine
  93460. */
  93461. connectToAnalyser(analyser: Analyser): void;
  93462. }
  93463. }
  93464. declare module BABYLON {
  93465. interface AbstractScene {
  93466. /**
  93467. * The list of sounds used in the scene.
  93468. */
  93469. sounds: Nullable<Array<Sound>>;
  93470. }
  93471. interface Scene {
  93472. /**
  93473. * @hidden
  93474. * Backing field
  93475. */
  93476. _mainSoundTrack: SoundTrack;
  93477. /**
  93478. * The main sound track played by the scene.
  93479. * It cotains your primary collection of sounds.
  93480. */
  93481. mainSoundTrack: SoundTrack;
  93482. /**
  93483. * The list of sound tracks added to the scene
  93484. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93485. */
  93486. soundTracks: Nullable<Array<SoundTrack>>;
  93487. /**
  93488. * Gets a sound using a given name
  93489. * @param name defines the name to search for
  93490. * @return the found sound or null if not found at all.
  93491. */
  93492. getSoundByName(name: string): Nullable<Sound>;
  93493. /**
  93494. * Gets or sets if audio support is enabled
  93495. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93496. */
  93497. audioEnabled: boolean;
  93498. /**
  93499. * Gets or sets if audio will be output to headphones
  93500. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93501. */
  93502. headphone: boolean;
  93503. }
  93504. /**
  93505. * Defines the sound scene component responsible to manage any sounds
  93506. * in a given scene.
  93507. */
  93508. export class AudioSceneComponent implements ISceneSerializableComponent {
  93509. /**
  93510. * The component name helpfull to identify the component in the list of scene components.
  93511. */
  93512. readonly name: string;
  93513. /**
  93514. * The scene the component belongs to.
  93515. */
  93516. scene: Scene;
  93517. private _audioEnabled;
  93518. /**
  93519. * Gets whether audio is enabled or not.
  93520. * Please use related enable/disable method to switch state.
  93521. */
  93522. readonly audioEnabled: boolean;
  93523. private _headphone;
  93524. /**
  93525. * Gets whether audio is outputing to headphone or not.
  93526. * Please use the according Switch methods to change output.
  93527. */
  93528. readonly headphone: boolean;
  93529. /**
  93530. * Creates a new instance of the component for the given scene
  93531. * @param scene Defines the scene to register the component in
  93532. */
  93533. constructor(scene: Scene);
  93534. /**
  93535. * Registers the component in a given scene
  93536. */
  93537. register(): void;
  93538. /**
  93539. * Rebuilds the elements related to this component in case of
  93540. * context lost for instance.
  93541. */
  93542. rebuild(): void;
  93543. /**
  93544. * Serializes the component data to the specified json object
  93545. * @param serializationObject The object to serialize to
  93546. */
  93547. serialize(serializationObject: any): void;
  93548. /**
  93549. * Adds all the element from the container to the scene
  93550. * @param container the container holding the elements
  93551. */
  93552. addFromContainer(container: AbstractScene): void;
  93553. /**
  93554. * Removes all the elements in the container from the scene
  93555. * @param container contains the elements to remove
  93556. * @param dispose if the removed element should be disposed (default: false)
  93557. */
  93558. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  93559. /**
  93560. * Disposes the component and the associated ressources.
  93561. */
  93562. dispose(): void;
  93563. /**
  93564. * Disables audio in the associated scene.
  93565. */
  93566. disableAudio(): void;
  93567. /**
  93568. * Enables audio in the associated scene.
  93569. */
  93570. enableAudio(): void;
  93571. /**
  93572. * Switch audio to headphone output.
  93573. */
  93574. switchAudioModeForHeadphones(): void;
  93575. /**
  93576. * Switch audio to normal speakers.
  93577. */
  93578. switchAudioModeForNormalSpeakers(): void;
  93579. private _afterRender;
  93580. }
  93581. }
  93582. declare module BABYLON {
  93583. /**
  93584. * Wraps one or more Sound objects and selects one with random weight for playback.
  93585. */
  93586. export class WeightedSound {
  93587. /** When true a Sound will be selected and played when the current playing Sound completes. */
  93588. loop: boolean;
  93589. private _coneInnerAngle;
  93590. private _coneOuterAngle;
  93591. private _volume;
  93592. /** A Sound is currently playing. */
  93593. isPlaying: boolean;
  93594. /** A Sound is currently paused. */
  93595. isPaused: boolean;
  93596. private _sounds;
  93597. private _weights;
  93598. private _currentIndex?;
  93599. /**
  93600. * Creates a new WeightedSound from the list of sounds given.
  93601. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  93602. * @param sounds Array of Sounds that will be selected from.
  93603. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  93604. */
  93605. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  93606. /**
  93607. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  93608. */
  93609. /**
  93610. * The size of cone in degress for a directional sound in which there will be no attenuation.
  93611. */
  93612. directionalConeInnerAngle: number;
  93613. /**
  93614. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  93615. * Listener angles between innerAngle and outerAngle will falloff linearly.
  93616. */
  93617. /**
  93618. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  93619. * Listener angles between innerAngle and outerAngle will falloff linearly.
  93620. */
  93621. directionalConeOuterAngle: number;
  93622. /**
  93623. * Playback volume.
  93624. */
  93625. /**
  93626. * Playback volume.
  93627. */
  93628. volume: number;
  93629. private _onended;
  93630. /**
  93631. * Suspend playback
  93632. */
  93633. pause(): void;
  93634. /**
  93635. * Stop playback
  93636. */
  93637. stop(): void;
  93638. /**
  93639. * Start playback.
  93640. * @param startOffset Position the clip head at a specific time in seconds.
  93641. */
  93642. play(startOffset?: number): void;
  93643. }
  93644. }
  93645. declare module BABYLON {
  93646. /**
  93647. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  93648. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93649. */
  93650. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  93651. /**
  93652. * Gets the name of the behavior.
  93653. */
  93654. readonly name: string;
  93655. /**
  93656. * The easing function used by animations
  93657. */
  93658. static EasingFunction: BackEase;
  93659. /**
  93660. * The easing mode used by animations
  93661. */
  93662. static EasingMode: number;
  93663. /**
  93664. * The duration of the animation, in milliseconds
  93665. */
  93666. transitionDuration: number;
  93667. /**
  93668. * Length of the distance animated by the transition when lower radius is reached
  93669. */
  93670. lowerRadiusTransitionRange: number;
  93671. /**
  93672. * Length of the distance animated by the transition when upper radius is reached
  93673. */
  93674. upperRadiusTransitionRange: number;
  93675. private _autoTransitionRange;
  93676. /**
  93677. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  93678. */
  93679. /**
  93680. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  93681. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  93682. */
  93683. autoTransitionRange: boolean;
  93684. private _attachedCamera;
  93685. private _onAfterCheckInputsObserver;
  93686. private _onMeshTargetChangedObserver;
  93687. /**
  93688. * Initializes the behavior.
  93689. */
  93690. init(): void;
  93691. /**
  93692. * Attaches the behavior to its arc rotate camera.
  93693. * @param camera Defines the camera to attach the behavior to
  93694. */
  93695. attach(camera: ArcRotateCamera): void;
  93696. /**
  93697. * Detaches the behavior from its current arc rotate camera.
  93698. */
  93699. detach(): void;
  93700. private _radiusIsAnimating;
  93701. private _radiusBounceTransition;
  93702. private _animatables;
  93703. private _cachedWheelPrecision;
  93704. /**
  93705. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  93706. * @param radiusLimit The limit to check against.
  93707. * @return Bool to indicate if at limit.
  93708. */
  93709. private _isRadiusAtLimit;
  93710. /**
  93711. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  93712. * @param radiusDelta The delta by which to animate to. Can be negative.
  93713. */
  93714. private _applyBoundRadiusAnimation;
  93715. /**
  93716. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  93717. */
  93718. protected _clearAnimationLocks(): void;
  93719. /**
  93720. * Stops and removes all animations that have been applied to the camera
  93721. */
  93722. stopAllAnimations(): void;
  93723. }
  93724. }
  93725. declare module BABYLON {
  93726. /**
  93727. * 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.
  93728. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93729. */
  93730. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  93731. /**
  93732. * Gets the name of the behavior.
  93733. */
  93734. readonly name: string;
  93735. private _mode;
  93736. private _radiusScale;
  93737. private _positionScale;
  93738. private _defaultElevation;
  93739. private _elevationReturnTime;
  93740. private _elevationReturnWaitTime;
  93741. private _zoomStopsAnimation;
  93742. private _framingTime;
  93743. /**
  93744. * The easing function used by animations
  93745. */
  93746. static EasingFunction: ExponentialEase;
  93747. /**
  93748. * The easing mode used by animations
  93749. */
  93750. static EasingMode: number;
  93751. /**
  93752. * Sets the current mode used by the behavior
  93753. */
  93754. /**
  93755. * Gets current mode used by the behavior.
  93756. */
  93757. mode: number;
  93758. /**
  93759. * Sets the scale applied to the radius (1 by default)
  93760. */
  93761. /**
  93762. * Gets the scale applied to the radius
  93763. */
  93764. radiusScale: number;
  93765. /**
  93766. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  93767. */
  93768. /**
  93769. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  93770. */
  93771. positionScale: number;
  93772. /**
  93773. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  93774. * behaviour is triggered, in radians.
  93775. */
  93776. /**
  93777. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  93778. * behaviour is triggered, in radians.
  93779. */
  93780. defaultElevation: number;
  93781. /**
  93782. * Sets the time (in milliseconds) taken to return to the default beta position.
  93783. * Negative value indicates camera should not return to default.
  93784. */
  93785. /**
  93786. * Gets the time (in milliseconds) taken to return to the default beta position.
  93787. * Negative value indicates camera should not return to default.
  93788. */
  93789. elevationReturnTime: number;
  93790. /**
  93791. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  93792. */
  93793. /**
  93794. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  93795. */
  93796. elevationReturnWaitTime: number;
  93797. /**
  93798. * Sets the flag that indicates if user zooming should stop animation.
  93799. */
  93800. /**
  93801. * Gets the flag that indicates if user zooming should stop animation.
  93802. */
  93803. zoomStopsAnimation: boolean;
  93804. /**
  93805. * Sets the transition time when framing the mesh, in milliseconds
  93806. */
  93807. /**
  93808. * Gets the transition time when framing the mesh, in milliseconds
  93809. */
  93810. framingTime: number;
  93811. /**
  93812. * Define if the behavior should automatically change the configured
  93813. * camera limits and sensibilities.
  93814. */
  93815. autoCorrectCameraLimitsAndSensibility: boolean;
  93816. private _onPrePointerObservableObserver;
  93817. private _onAfterCheckInputsObserver;
  93818. private _onMeshTargetChangedObserver;
  93819. private _attachedCamera;
  93820. private _isPointerDown;
  93821. private _lastInteractionTime;
  93822. /**
  93823. * Initializes the behavior.
  93824. */
  93825. init(): void;
  93826. /**
  93827. * Attaches the behavior to its arc rotate camera.
  93828. * @param camera Defines the camera to attach the behavior to
  93829. */
  93830. attach(camera: ArcRotateCamera): void;
  93831. /**
  93832. * Detaches the behavior from its current arc rotate camera.
  93833. */
  93834. detach(): void;
  93835. private _animatables;
  93836. private _betaIsAnimating;
  93837. private _betaTransition;
  93838. private _radiusTransition;
  93839. private _vectorTransition;
  93840. /**
  93841. * Targets the given mesh and updates zoom level accordingly.
  93842. * @param mesh The mesh to target.
  93843. * @param radius Optional. If a cached radius position already exists, overrides default.
  93844. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93845. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93846. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93847. */
  93848. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93849. /**
  93850. * Targets the given mesh with its children and updates zoom level accordingly.
  93851. * @param mesh The mesh to target.
  93852. * @param radius Optional. If a cached radius position already exists, overrides default.
  93853. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93854. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93855. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93856. */
  93857. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93858. /**
  93859. * Targets the given meshes with their children and updates zoom level accordingly.
  93860. * @param meshes The mesh to target.
  93861. * @param radius Optional. If a cached radius position already exists, overrides default.
  93862. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93863. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93864. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93865. */
  93866. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93867. /**
  93868. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  93869. * @param minimumWorld Determines the smaller position of the bounding box extend
  93870. * @param maximumWorld Determines the bigger position of the bounding box extend
  93871. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93872. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93873. */
  93874. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93875. /**
  93876. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  93877. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  93878. * frustum width.
  93879. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  93880. * to fully enclose the mesh in the viewing frustum.
  93881. */
  93882. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  93883. /**
  93884. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  93885. * is automatically returned to its default position (expected to be above ground plane).
  93886. */
  93887. private _maintainCameraAboveGround;
  93888. /**
  93889. * Returns the frustum slope based on the canvas ratio and camera FOV
  93890. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  93891. */
  93892. private _getFrustumSlope;
  93893. /**
  93894. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  93895. */
  93896. private _clearAnimationLocks;
  93897. /**
  93898. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  93899. */
  93900. private _applyUserInteraction;
  93901. /**
  93902. * Stops and removes all animations that have been applied to the camera
  93903. */
  93904. stopAllAnimations(): void;
  93905. /**
  93906. * Gets a value indicating if the user is moving the camera
  93907. */
  93908. readonly isUserIsMoving: boolean;
  93909. /**
  93910. * The camera can move all the way towards the mesh.
  93911. */
  93912. static IgnoreBoundsSizeMode: number;
  93913. /**
  93914. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  93915. */
  93916. static FitFrustumSidesMode: number;
  93917. }
  93918. }
  93919. declare module BABYLON {
  93920. /**
  93921. * Base class for Camera Pointer Inputs.
  93922. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  93923. * for example usage.
  93924. */
  93925. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  93926. /**
  93927. * Defines the camera the input is attached to.
  93928. */
  93929. abstract camera: Camera;
  93930. /**
  93931. * Whether keyboard modifier keys are pressed at time of last mouse event.
  93932. */
  93933. protected _altKey: boolean;
  93934. protected _ctrlKey: boolean;
  93935. protected _metaKey: boolean;
  93936. protected _shiftKey: boolean;
  93937. /**
  93938. * Which mouse buttons were pressed at time of last mouse event.
  93939. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  93940. */
  93941. protected _buttonsPressed: number;
  93942. /**
  93943. * Defines the buttons associated with the input to handle camera move.
  93944. */
  93945. buttons: number[];
  93946. /**
  93947. * Attach the input controls to a specific dom element to get the input from.
  93948. * @param element Defines the element the controls should be listened from
  93949. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93950. */
  93951. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93952. /**
  93953. * Detach the current controls from the specified dom element.
  93954. * @param element Defines the element to stop listening the inputs from
  93955. */
  93956. detachControl(element: Nullable<HTMLElement>): void;
  93957. /**
  93958. * Gets the class name of the current input.
  93959. * @returns the class name
  93960. */
  93961. getClassName(): string;
  93962. /**
  93963. * Get the friendly name associated with the input class.
  93964. * @returns the input friendly name
  93965. */
  93966. getSimpleName(): string;
  93967. /**
  93968. * Called on pointer POINTERDOUBLETAP event.
  93969. * Override this method to provide functionality on POINTERDOUBLETAP event.
  93970. */
  93971. protected onDoubleTap(type: string): void;
  93972. /**
  93973. * Called on pointer POINTERMOVE event if only a single touch is active.
  93974. * Override this method to provide functionality.
  93975. */
  93976. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93977. /**
  93978. * Called on pointer POINTERMOVE event if multiple touches are active.
  93979. * Override this method to provide functionality.
  93980. */
  93981. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93982. /**
  93983. * Called on JS contextmenu event.
  93984. * Override this method to provide functionality.
  93985. */
  93986. protected onContextMenu(evt: PointerEvent): void;
  93987. /**
  93988. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  93989. * press.
  93990. * Override this method to provide functionality.
  93991. */
  93992. protected onButtonDown(evt: PointerEvent): void;
  93993. /**
  93994. * Called each time a new POINTERUP event occurs. Ie, for each button
  93995. * release.
  93996. * Override this method to provide functionality.
  93997. */
  93998. protected onButtonUp(evt: PointerEvent): void;
  93999. /**
  94000. * Called when window becomes inactive.
  94001. * Override this method to provide functionality.
  94002. */
  94003. protected onLostFocus(): void;
  94004. private _pointerInput;
  94005. private _observer;
  94006. private _onLostFocus;
  94007. private pointA;
  94008. private pointB;
  94009. }
  94010. }
  94011. declare module BABYLON {
  94012. /**
  94013. * Manage the pointers inputs to control an arc rotate camera.
  94014. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94015. */
  94016. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  94017. /**
  94018. * Defines the camera the input is attached to.
  94019. */
  94020. camera: ArcRotateCamera;
  94021. /**
  94022. * Gets the class name of the current input.
  94023. * @returns the class name
  94024. */
  94025. getClassName(): string;
  94026. /**
  94027. * Defines the buttons associated with the input to handle camera move.
  94028. */
  94029. buttons: number[];
  94030. /**
  94031. * Defines the pointer angular sensibility along the X axis or how fast is
  94032. * the camera rotating.
  94033. */
  94034. angularSensibilityX: number;
  94035. /**
  94036. * Defines the pointer angular sensibility along the Y axis or how fast is
  94037. * the camera rotating.
  94038. */
  94039. angularSensibilityY: number;
  94040. /**
  94041. * Defines the pointer pinch precision or how fast is the camera zooming.
  94042. */
  94043. pinchPrecision: number;
  94044. /**
  94045. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94046. * from 0.
  94047. * It defines the percentage of current camera.radius to use as delta when
  94048. * pinch zoom is used.
  94049. */
  94050. pinchDeltaPercentage: number;
  94051. /**
  94052. * Defines the pointer panning sensibility or how fast is the camera moving.
  94053. */
  94054. panningSensibility: number;
  94055. /**
  94056. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  94057. */
  94058. multiTouchPanning: boolean;
  94059. /**
  94060. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  94061. * zoom (pinch) through multitouch.
  94062. */
  94063. multiTouchPanAndZoom: boolean;
  94064. /**
  94065. * Revers pinch action direction.
  94066. */
  94067. pinchInwards: boolean;
  94068. private _isPanClick;
  94069. private _twoFingerActivityCount;
  94070. private _isPinching;
  94071. /**
  94072. * Called on pointer POINTERMOVE event if only a single touch is active.
  94073. */
  94074. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94075. /**
  94076. * Called on pointer POINTERDOUBLETAP event.
  94077. */
  94078. protected onDoubleTap(type: string): void;
  94079. /**
  94080. * Called on pointer POINTERMOVE event if multiple touches are active.
  94081. */
  94082. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94083. /**
  94084. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94085. * press.
  94086. */
  94087. protected onButtonDown(evt: PointerEvent): void;
  94088. /**
  94089. * Called each time a new POINTERUP event occurs. Ie, for each button
  94090. * release.
  94091. */
  94092. protected onButtonUp(evt: PointerEvent): void;
  94093. /**
  94094. * Called when window becomes inactive.
  94095. */
  94096. protected onLostFocus(): void;
  94097. }
  94098. }
  94099. declare module BABYLON {
  94100. /**
  94101. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  94102. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94103. */
  94104. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  94105. /**
  94106. * Defines the camera the input is attached to.
  94107. */
  94108. camera: ArcRotateCamera;
  94109. /**
  94110. * Defines the list of key codes associated with the up action (increase alpha)
  94111. */
  94112. keysUp: number[];
  94113. /**
  94114. * Defines the list of key codes associated with the down action (decrease alpha)
  94115. */
  94116. keysDown: number[];
  94117. /**
  94118. * Defines the list of key codes associated with the left action (increase beta)
  94119. */
  94120. keysLeft: number[];
  94121. /**
  94122. * Defines the list of key codes associated with the right action (decrease beta)
  94123. */
  94124. keysRight: number[];
  94125. /**
  94126. * Defines the list of key codes associated with the reset action.
  94127. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  94128. */
  94129. keysReset: number[];
  94130. /**
  94131. * Defines the panning sensibility of the inputs.
  94132. * (How fast is the camera paning)
  94133. */
  94134. panningSensibility: number;
  94135. /**
  94136. * Defines the zooming sensibility of the inputs.
  94137. * (How fast is the camera zooming)
  94138. */
  94139. zoomingSensibility: number;
  94140. /**
  94141. * Defines wether maintaining the alt key down switch the movement mode from
  94142. * orientation to zoom.
  94143. */
  94144. useAltToZoom: boolean;
  94145. /**
  94146. * Rotation speed of the camera
  94147. */
  94148. angularSpeed: number;
  94149. private _keys;
  94150. private _ctrlPressed;
  94151. private _altPressed;
  94152. private _onCanvasBlurObserver;
  94153. private _onKeyboardObserver;
  94154. private _engine;
  94155. private _scene;
  94156. /**
  94157. * Attach the input controls to a specific dom element to get the input from.
  94158. * @param element Defines the element the controls should be listened from
  94159. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94160. */
  94161. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94162. /**
  94163. * Detach the current controls from the specified dom element.
  94164. * @param element Defines the element to stop listening the inputs from
  94165. */
  94166. detachControl(element: Nullable<HTMLElement>): void;
  94167. /**
  94168. * Update the current camera state depending on the inputs that have been used this frame.
  94169. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94170. */
  94171. checkInputs(): void;
  94172. /**
  94173. * Gets the class name of the current intput.
  94174. * @returns the class name
  94175. */
  94176. getClassName(): string;
  94177. /**
  94178. * Get the friendly name associated with the input class.
  94179. * @returns the input friendly name
  94180. */
  94181. getSimpleName(): string;
  94182. }
  94183. }
  94184. declare module BABYLON {
  94185. /**
  94186. * Manage the mouse wheel inputs to control an arc rotate camera.
  94187. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94188. */
  94189. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  94190. /**
  94191. * Defines the camera the input is attached to.
  94192. */
  94193. camera: ArcRotateCamera;
  94194. /**
  94195. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94196. */
  94197. wheelPrecision: number;
  94198. /**
  94199. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  94200. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  94201. */
  94202. wheelDeltaPercentage: number;
  94203. private _wheel;
  94204. private _observer;
  94205. /**
  94206. * Attach the input controls to a specific dom element to get the input from.
  94207. * @param element Defines the element the controls should be listened from
  94208. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94209. */
  94210. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94211. /**
  94212. * Detach the current controls from the specified dom element.
  94213. * @param element Defines the element to stop listening the inputs from
  94214. */
  94215. detachControl(element: Nullable<HTMLElement>): void;
  94216. /**
  94217. * Gets the class name of the current intput.
  94218. * @returns the class name
  94219. */
  94220. getClassName(): string;
  94221. /**
  94222. * Get the friendly name associated with the input class.
  94223. * @returns the input friendly name
  94224. */
  94225. getSimpleName(): string;
  94226. }
  94227. }
  94228. declare module BABYLON {
  94229. /**
  94230. * Default Inputs manager for the ArcRotateCamera.
  94231. * It groups all the default supported inputs for ease of use.
  94232. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94233. */
  94234. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  94235. /**
  94236. * Instantiates a new ArcRotateCameraInputsManager.
  94237. * @param camera Defines the camera the inputs belong to
  94238. */
  94239. constructor(camera: ArcRotateCamera);
  94240. /**
  94241. * Add mouse wheel input support to the input manager.
  94242. * @returns the current input manager
  94243. */
  94244. addMouseWheel(): ArcRotateCameraInputsManager;
  94245. /**
  94246. * Add pointers input support to the input manager.
  94247. * @returns the current input manager
  94248. */
  94249. addPointers(): ArcRotateCameraInputsManager;
  94250. /**
  94251. * Add keyboard input support to the input manager.
  94252. * @returns the current input manager
  94253. */
  94254. addKeyboard(): ArcRotateCameraInputsManager;
  94255. }
  94256. }
  94257. declare module BABYLON {
  94258. /**
  94259. * This represents an orbital type of camera.
  94260. *
  94261. * 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.
  94262. * 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.
  94263. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  94264. */
  94265. export class ArcRotateCamera extends TargetCamera {
  94266. /**
  94267. * Defines the rotation angle of the camera along the longitudinal axis.
  94268. */
  94269. alpha: number;
  94270. /**
  94271. * Defines the rotation angle of the camera along the latitudinal axis.
  94272. */
  94273. beta: number;
  94274. /**
  94275. * Defines the radius of the camera from it s target point.
  94276. */
  94277. radius: number;
  94278. protected _target: Vector3;
  94279. protected _targetHost: Nullable<AbstractMesh>;
  94280. /**
  94281. * Defines the target point of the camera.
  94282. * The camera looks towards it form the radius distance.
  94283. */
  94284. target: Vector3;
  94285. /**
  94286. * Define the current local position of the camera in the scene
  94287. */
  94288. position: Vector3;
  94289. protected _upVector: Vector3;
  94290. protected _upToYMatrix: Matrix;
  94291. protected _YToUpMatrix: Matrix;
  94292. /**
  94293. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  94294. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  94295. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  94296. */
  94297. upVector: Vector3;
  94298. /**
  94299. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  94300. */
  94301. setMatUp(): void;
  94302. /**
  94303. * Current inertia value on the longitudinal axis.
  94304. * The bigger this number the longer it will take for the camera to stop.
  94305. */
  94306. inertialAlphaOffset: number;
  94307. /**
  94308. * Current inertia value on the latitudinal axis.
  94309. * The bigger this number the longer it will take for the camera to stop.
  94310. */
  94311. inertialBetaOffset: number;
  94312. /**
  94313. * Current inertia value on the radius axis.
  94314. * The bigger this number the longer it will take for the camera to stop.
  94315. */
  94316. inertialRadiusOffset: number;
  94317. /**
  94318. * Minimum allowed angle on the longitudinal axis.
  94319. * This can help limiting how the Camera is able to move in the scene.
  94320. */
  94321. lowerAlphaLimit: Nullable<number>;
  94322. /**
  94323. * Maximum allowed angle on the longitudinal axis.
  94324. * This can help limiting how the Camera is able to move in the scene.
  94325. */
  94326. upperAlphaLimit: Nullable<number>;
  94327. /**
  94328. * Minimum allowed angle on the latitudinal axis.
  94329. * This can help limiting how the Camera is able to move in the scene.
  94330. */
  94331. lowerBetaLimit: number;
  94332. /**
  94333. * Maximum allowed angle on the latitudinal axis.
  94334. * This can help limiting how the Camera is able to move in the scene.
  94335. */
  94336. upperBetaLimit: number;
  94337. /**
  94338. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  94339. * This can help limiting how the Camera is able to move in the scene.
  94340. */
  94341. lowerRadiusLimit: Nullable<number>;
  94342. /**
  94343. * Maximum allowed distance of the camera to the target (The camera can not get further).
  94344. * This can help limiting how the Camera is able to move in the scene.
  94345. */
  94346. upperRadiusLimit: Nullable<number>;
  94347. /**
  94348. * Defines the current inertia value used during panning of the camera along the X axis.
  94349. */
  94350. inertialPanningX: number;
  94351. /**
  94352. * Defines the current inertia value used during panning of the camera along the Y axis.
  94353. */
  94354. inertialPanningY: number;
  94355. /**
  94356. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  94357. * Basically if your fingers moves away from more than this distance you will be considered
  94358. * in pinch mode.
  94359. */
  94360. pinchToPanMaxDistance: number;
  94361. /**
  94362. * Defines the maximum distance the camera can pan.
  94363. * This could help keeping the cammera always in your scene.
  94364. */
  94365. panningDistanceLimit: Nullable<number>;
  94366. /**
  94367. * Defines the target of the camera before paning.
  94368. */
  94369. panningOriginTarget: Vector3;
  94370. /**
  94371. * Defines the value of the inertia used during panning.
  94372. * 0 would mean stop inertia and one would mean no decelleration at all.
  94373. */
  94374. panningInertia: number;
  94375. /**
  94376. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  94377. */
  94378. angularSensibilityX: number;
  94379. /**
  94380. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  94381. */
  94382. angularSensibilityY: number;
  94383. /**
  94384. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  94385. */
  94386. pinchPrecision: number;
  94387. /**
  94388. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  94389. * It will be used instead of pinchDeltaPrecision if different from 0.
  94390. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  94391. */
  94392. pinchDeltaPercentage: number;
  94393. /**
  94394. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  94395. */
  94396. panningSensibility: number;
  94397. /**
  94398. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  94399. */
  94400. keysUp: number[];
  94401. /**
  94402. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  94403. */
  94404. keysDown: number[];
  94405. /**
  94406. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  94407. */
  94408. keysLeft: number[];
  94409. /**
  94410. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  94411. */
  94412. keysRight: number[];
  94413. /**
  94414. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94415. */
  94416. wheelPrecision: number;
  94417. /**
  94418. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  94419. * It will be used instead of pinchDeltaPrecision if different from 0.
  94420. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  94421. */
  94422. wheelDeltaPercentage: number;
  94423. /**
  94424. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  94425. */
  94426. zoomOnFactor: number;
  94427. /**
  94428. * Defines a screen offset for the camera position.
  94429. */
  94430. targetScreenOffset: Vector2;
  94431. /**
  94432. * Allows the camera to be completely reversed.
  94433. * If false the camera can not arrive upside down.
  94434. */
  94435. allowUpsideDown: boolean;
  94436. /**
  94437. * Define if double tap/click is used to restore the previously saved state of the camera.
  94438. */
  94439. useInputToRestoreState: boolean;
  94440. /** @hidden */
  94441. _viewMatrix: Matrix;
  94442. /** @hidden */
  94443. _useCtrlForPanning: boolean;
  94444. /** @hidden */
  94445. _panningMouseButton: number;
  94446. /**
  94447. * Defines the input associated to the camera.
  94448. */
  94449. inputs: ArcRotateCameraInputsManager;
  94450. /** @hidden */
  94451. _reset: () => void;
  94452. /**
  94453. * Defines the allowed panning axis.
  94454. */
  94455. panningAxis: Vector3;
  94456. protected _localDirection: Vector3;
  94457. protected _transformedDirection: Vector3;
  94458. private _bouncingBehavior;
  94459. /**
  94460. * Gets the bouncing behavior of the camera if it has been enabled.
  94461. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94462. */
  94463. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  94464. /**
  94465. * Defines if the bouncing behavior of the camera is enabled on the camera.
  94466. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94467. */
  94468. useBouncingBehavior: boolean;
  94469. private _framingBehavior;
  94470. /**
  94471. * Gets the framing behavior of the camera if it has been enabled.
  94472. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94473. */
  94474. readonly framingBehavior: Nullable<FramingBehavior>;
  94475. /**
  94476. * Defines if the framing behavior of the camera is enabled on the camera.
  94477. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94478. */
  94479. useFramingBehavior: boolean;
  94480. private _autoRotationBehavior;
  94481. /**
  94482. * Gets the auto rotation behavior of the camera if it has been enabled.
  94483. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94484. */
  94485. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  94486. /**
  94487. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  94488. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94489. */
  94490. useAutoRotationBehavior: boolean;
  94491. /**
  94492. * Observable triggered when the mesh target has been changed on the camera.
  94493. */
  94494. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  94495. /**
  94496. * Event raised when the camera is colliding with a mesh.
  94497. */
  94498. onCollide: (collidedMesh: AbstractMesh) => void;
  94499. /**
  94500. * Defines whether the camera should check collision with the objects oh the scene.
  94501. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  94502. */
  94503. checkCollisions: boolean;
  94504. /**
  94505. * Defines the collision radius of the camera.
  94506. * This simulates a sphere around the camera.
  94507. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94508. */
  94509. collisionRadius: Vector3;
  94510. protected _collider: Collider;
  94511. protected _previousPosition: Vector3;
  94512. protected _collisionVelocity: Vector3;
  94513. protected _newPosition: Vector3;
  94514. protected _previousAlpha: number;
  94515. protected _previousBeta: number;
  94516. protected _previousRadius: number;
  94517. protected _collisionTriggered: boolean;
  94518. protected _targetBoundingCenter: Nullable<Vector3>;
  94519. private _computationVector;
  94520. /**
  94521. * Instantiates a new ArcRotateCamera in a given scene
  94522. * @param name Defines the name of the camera
  94523. * @param alpha Defines the camera rotation along the logitudinal axis
  94524. * @param beta Defines the camera rotation along the latitudinal axis
  94525. * @param radius Defines the camera distance from its target
  94526. * @param target Defines the camera target
  94527. * @param scene Defines the scene the camera belongs to
  94528. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  94529. */
  94530. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94531. /** @hidden */
  94532. _initCache(): void;
  94533. /** @hidden */
  94534. _updateCache(ignoreParentClass?: boolean): void;
  94535. protected _getTargetPosition(): Vector3;
  94536. private _storedAlpha;
  94537. private _storedBeta;
  94538. private _storedRadius;
  94539. private _storedTarget;
  94540. /**
  94541. * Stores the current state of the camera (alpha, beta, radius and target)
  94542. * @returns the camera itself
  94543. */
  94544. storeState(): Camera;
  94545. /**
  94546. * @hidden
  94547. * Restored camera state. You must call storeState() first
  94548. */
  94549. _restoreStateValues(): boolean;
  94550. /** @hidden */
  94551. _isSynchronizedViewMatrix(): boolean;
  94552. /**
  94553. * Attached controls to the current camera.
  94554. * @param element Defines the element the controls should be listened from
  94555. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94556. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  94557. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  94558. */
  94559. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  94560. /**
  94561. * Detach the current controls from the camera.
  94562. * The camera will stop reacting to inputs.
  94563. * @param element Defines the element to stop listening the inputs from
  94564. */
  94565. detachControl(element: HTMLElement): void;
  94566. /** @hidden */
  94567. _checkInputs(): void;
  94568. protected _checkLimits(): void;
  94569. /**
  94570. * Rebuilds angles (alpha, beta) and radius from the give position and target
  94571. */
  94572. rebuildAnglesAndRadius(): void;
  94573. /**
  94574. * Use a position to define the current camera related information like aplha, beta and radius
  94575. * @param position Defines the position to set the camera at
  94576. */
  94577. setPosition(position: Vector3): void;
  94578. /**
  94579. * Defines the target the camera should look at.
  94580. * This will automatically adapt alpha beta and radius to fit within the new target.
  94581. * @param target Defines the new target as a Vector or a mesh
  94582. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  94583. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  94584. */
  94585. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  94586. /** @hidden */
  94587. _getViewMatrix(): Matrix;
  94588. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  94589. /**
  94590. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  94591. * @param meshes Defines the mesh to zoom on
  94592. * @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)
  94593. */
  94594. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  94595. /**
  94596. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  94597. * The target will be changed but the radius
  94598. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  94599. * @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)
  94600. */
  94601. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  94602. min: Vector3;
  94603. max: Vector3;
  94604. distance: number;
  94605. }, doNotUpdateMaxZ?: boolean): void;
  94606. /**
  94607. * @override
  94608. * Override Camera.createRigCamera
  94609. */
  94610. createRigCamera(name: string, cameraIndex: number): Camera;
  94611. /**
  94612. * @hidden
  94613. * @override
  94614. * Override Camera._updateRigCameras
  94615. */
  94616. _updateRigCameras(): void;
  94617. /**
  94618. * Destroy the camera and release the current resources hold by it.
  94619. */
  94620. dispose(): void;
  94621. /**
  94622. * Gets the current object class name.
  94623. * @return the class name
  94624. */
  94625. getClassName(): string;
  94626. }
  94627. }
  94628. declare module BABYLON {
  94629. /**
  94630. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  94631. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94632. */
  94633. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  94634. /**
  94635. * Gets the name of the behavior.
  94636. */
  94637. readonly name: string;
  94638. private _zoomStopsAnimation;
  94639. private _idleRotationSpeed;
  94640. private _idleRotationWaitTime;
  94641. private _idleRotationSpinupTime;
  94642. /**
  94643. * Sets the flag that indicates if user zooming should stop animation.
  94644. */
  94645. /**
  94646. * Gets the flag that indicates if user zooming should stop animation.
  94647. */
  94648. zoomStopsAnimation: boolean;
  94649. /**
  94650. * Sets the default speed at which the camera rotates around the model.
  94651. */
  94652. /**
  94653. * Gets the default speed at which the camera rotates around the model.
  94654. */
  94655. idleRotationSpeed: number;
  94656. /**
  94657. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  94658. */
  94659. /**
  94660. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  94661. */
  94662. idleRotationWaitTime: number;
  94663. /**
  94664. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  94665. */
  94666. /**
  94667. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  94668. */
  94669. idleRotationSpinupTime: number;
  94670. /**
  94671. * Gets a value indicating if the camera is currently rotating because of this behavior
  94672. */
  94673. readonly rotationInProgress: boolean;
  94674. private _onPrePointerObservableObserver;
  94675. private _onAfterCheckInputsObserver;
  94676. private _attachedCamera;
  94677. private _isPointerDown;
  94678. private _lastFrameTime;
  94679. private _lastInteractionTime;
  94680. private _cameraRotationSpeed;
  94681. /**
  94682. * Initializes the behavior.
  94683. */
  94684. init(): void;
  94685. /**
  94686. * Attaches the behavior to its arc rotate camera.
  94687. * @param camera Defines the camera to attach the behavior to
  94688. */
  94689. attach(camera: ArcRotateCamera): void;
  94690. /**
  94691. * Detaches the behavior from its current arc rotate camera.
  94692. */
  94693. detach(): void;
  94694. /**
  94695. * Returns true if user is scrolling.
  94696. * @return true if user is scrolling.
  94697. */
  94698. private _userIsZooming;
  94699. private _lastFrameRadius;
  94700. private _shouldAnimationStopForInteraction;
  94701. /**
  94702. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94703. */
  94704. private _applyUserInteraction;
  94705. private _userIsMoving;
  94706. }
  94707. }
  94708. declare module BABYLON {
  94709. /**
  94710. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  94711. */
  94712. export class AttachToBoxBehavior implements Behavior<Mesh> {
  94713. private ui;
  94714. /**
  94715. * The name of the behavior
  94716. */
  94717. name: string;
  94718. /**
  94719. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  94720. */
  94721. distanceAwayFromFace: number;
  94722. /**
  94723. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  94724. */
  94725. distanceAwayFromBottomOfFace: number;
  94726. private _faceVectors;
  94727. private _target;
  94728. private _scene;
  94729. private _onRenderObserver;
  94730. private _tmpMatrix;
  94731. private _tmpVector;
  94732. /**
  94733. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  94734. * @param ui The transform node that should be attched to the mesh
  94735. */
  94736. constructor(ui: TransformNode);
  94737. /**
  94738. * Initializes the behavior
  94739. */
  94740. init(): void;
  94741. private _closestFace;
  94742. private _zeroVector;
  94743. private _lookAtTmpMatrix;
  94744. private _lookAtToRef;
  94745. /**
  94746. * Attaches the AttachToBoxBehavior to the passed in mesh
  94747. * @param target The mesh that the specified node will be attached to
  94748. */
  94749. attach(target: Mesh): void;
  94750. /**
  94751. * Detaches the behavior from the mesh
  94752. */
  94753. detach(): void;
  94754. }
  94755. }
  94756. declare module BABYLON {
  94757. /**
  94758. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  94759. */
  94760. export class FadeInOutBehavior implements Behavior<Mesh> {
  94761. /**
  94762. * Time in milliseconds to delay before fading in (Default: 0)
  94763. */
  94764. delay: number;
  94765. /**
  94766. * Time in milliseconds for the mesh to fade in (Default: 300)
  94767. */
  94768. fadeInTime: number;
  94769. private _millisecondsPerFrame;
  94770. private _hovered;
  94771. private _hoverValue;
  94772. private _ownerNode;
  94773. /**
  94774. * Instatiates the FadeInOutBehavior
  94775. */
  94776. constructor();
  94777. /**
  94778. * The name of the behavior
  94779. */
  94780. readonly name: string;
  94781. /**
  94782. * Initializes the behavior
  94783. */
  94784. init(): void;
  94785. /**
  94786. * Attaches the fade behavior on the passed in mesh
  94787. * @param ownerNode The mesh that will be faded in/out once attached
  94788. */
  94789. attach(ownerNode: Mesh): void;
  94790. /**
  94791. * Detaches the behavior from the mesh
  94792. */
  94793. detach(): void;
  94794. /**
  94795. * Triggers the mesh to begin fading in or out
  94796. * @param value if the object should fade in or out (true to fade in)
  94797. */
  94798. fadeIn(value: boolean): void;
  94799. private _update;
  94800. private _setAllVisibility;
  94801. }
  94802. }
  94803. declare module BABYLON {
  94804. /**
  94805. * Class containing a set of static utilities functions for managing Pivots
  94806. * @hidden
  94807. */
  94808. export class PivotTools {
  94809. private static _PivotCached;
  94810. private static _OldPivotPoint;
  94811. private static _PivotTranslation;
  94812. private static _PivotTmpVector;
  94813. /** @hidden */
  94814. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  94815. /** @hidden */
  94816. static _RestorePivotPoint(mesh: AbstractMesh): void;
  94817. }
  94818. }
  94819. declare module BABYLON {
  94820. /**
  94821. * Class containing static functions to help procedurally build meshes
  94822. */
  94823. export class PlaneBuilder {
  94824. /**
  94825. * Creates a plane mesh
  94826. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  94827. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  94828. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  94829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94830. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94832. * @param name defines the name of the mesh
  94833. * @param options defines the options used to create the mesh
  94834. * @param scene defines the hosting scene
  94835. * @returns the plane mesh
  94836. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  94837. */
  94838. static CreatePlane(name: string, options: {
  94839. size?: number;
  94840. width?: number;
  94841. height?: number;
  94842. sideOrientation?: number;
  94843. frontUVs?: Vector4;
  94844. backUVs?: Vector4;
  94845. updatable?: boolean;
  94846. sourcePlane?: Plane;
  94847. }, scene?: Nullable<Scene>): Mesh;
  94848. }
  94849. }
  94850. declare module BABYLON {
  94851. /**
  94852. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  94853. */
  94854. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  94855. private static _AnyMouseID;
  94856. private _attachedNode;
  94857. private _dragPlane;
  94858. private _scene;
  94859. private _pointerObserver;
  94860. private _beforeRenderObserver;
  94861. private static _planeScene;
  94862. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  94863. /**
  94864. * 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)
  94865. */
  94866. maxDragAngle: number;
  94867. /**
  94868. * @hidden
  94869. */
  94870. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  94871. /**
  94872. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  94873. */
  94874. currentDraggingPointerID: number;
  94875. /**
  94876. * The last position where the pointer hit the drag plane in world space
  94877. */
  94878. lastDragPosition: Vector3;
  94879. /**
  94880. * If the behavior is currently in a dragging state
  94881. */
  94882. dragging: boolean;
  94883. /**
  94884. * 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)
  94885. */
  94886. dragDeltaRatio: number;
  94887. /**
  94888. * If the drag plane orientation should be updated during the dragging (Default: true)
  94889. */
  94890. updateDragPlane: boolean;
  94891. private _debugMode;
  94892. private _moving;
  94893. /**
  94894. * Fires each time the attached mesh is dragged with the pointer
  94895. * * delta between last drag position and current drag position in world space
  94896. * * dragDistance along the drag axis
  94897. * * dragPlaneNormal normal of the current drag plane used during the drag
  94898. * * dragPlanePoint in world space where the drag intersects the drag plane
  94899. */
  94900. onDragObservable: Observable<{
  94901. delta: Vector3;
  94902. dragPlanePoint: Vector3;
  94903. dragPlaneNormal: Vector3;
  94904. dragDistance: number;
  94905. pointerId: number;
  94906. }>;
  94907. /**
  94908. * Fires each time a drag begins (eg. mouse down on mesh)
  94909. */
  94910. onDragStartObservable: Observable<{
  94911. dragPlanePoint: Vector3;
  94912. pointerId: number;
  94913. }>;
  94914. /**
  94915. * Fires each time a drag ends (eg. mouse release after drag)
  94916. */
  94917. onDragEndObservable: Observable<{
  94918. dragPlanePoint: Vector3;
  94919. pointerId: number;
  94920. }>;
  94921. /**
  94922. * If the attached mesh should be moved when dragged
  94923. */
  94924. moveAttached: boolean;
  94925. /**
  94926. * If the drag behavior will react to drag events (Default: true)
  94927. */
  94928. enabled: boolean;
  94929. /**
  94930. * If camera controls should be detached during the drag
  94931. */
  94932. detachCameraControls: boolean;
  94933. /**
  94934. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  94935. */
  94936. useObjectOrienationForDragging: boolean;
  94937. private _options;
  94938. /**
  94939. * Creates a pointer drag behavior that can be attached to a mesh
  94940. * @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)
  94941. */
  94942. constructor(options?: {
  94943. dragAxis?: Vector3;
  94944. dragPlaneNormal?: Vector3;
  94945. });
  94946. /**
  94947. * Predicate to determine if it is valid to move the object to a new position when it is moved
  94948. */
  94949. validateDrag: (targetPosition: Vector3) => boolean;
  94950. /**
  94951. * The name of the behavior
  94952. */
  94953. readonly name: string;
  94954. /**
  94955. * Initializes the behavior
  94956. */
  94957. init(): void;
  94958. private _tmpVector;
  94959. private _alternatePickedPoint;
  94960. private _worldDragAxis;
  94961. private _targetPosition;
  94962. private _attachedElement;
  94963. /**
  94964. * Attaches the drag behavior the passed in mesh
  94965. * @param ownerNode The mesh that will be dragged around once attached
  94966. */
  94967. attach(ownerNode: AbstractMesh): void;
  94968. /**
  94969. * Force relase the drag action by code.
  94970. */
  94971. releaseDrag(): void;
  94972. private _startDragRay;
  94973. private _lastPointerRay;
  94974. /**
  94975. * Simulates the start of a pointer drag event on the behavior
  94976. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  94977. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  94978. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  94979. */
  94980. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  94981. private _startDrag;
  94982. private _dragDelta;
  94983. private _moveDrag;
  94984. private _pickWithRayOnDragPlane;
  94985. private _pointA;
  94986. private _pointB;
  94987. private _pointC;
  94988. private _lineA;
  94989. private _lineB;
  94990. private _localAxis;
  94991. private _lookAt;
  94992. private _updateDragPlanePosition;
  94993. /**
  94994. * Detaches the behavior from the mesh
  94995. */
  94996. detach(): void;
  94997. }
  94998. }
  94999. declare module BABYLON {
  95000. /**
  95001. * A behavior that when attached to a mesh will allow the mesh to be scaled
  95002. */
  95003. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  95004. private _dragBehaviorA;
  95005. private _dragBehaviorB;
  95006. private _startDistance;
  95007. private _initialScale;
  95008. private _targetScale;
  95009. private _ownerNode;
  95010. private _sceneRenderObserver;
  95011. /**
  95012. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  95013. */
  95014. constructor();
  95015. /**
  95016. * The name of the behavior
  95017. */
  95018. readonly name: string;
  95019. /**
  95020. * Initializes the behavior
  95021. */
  95022. init(): void;
  95023. private _getCurrentDistance;
  95024. /**
  95025. * Attaches the scale behavior the passed in mesh
  95026. * @param ownerNode The mesh that will be scaled around once attached
  95027. */
  95028. attach(ownerNode: Mesh): void;
  95029. /**
  95030. * Detaches the behavior from the mesh
  95031. */
  95032. detach(): void;
  95033. }
  95034. }
  95035. declare module BABYLON {
  95036. /**
  95037. * 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
  95038. */
  95039. export class SixDofDragBehavior implements Behavior<Mesh> {
  95040. private static _virtualScene;
  95041. private _ownerNode;
  95042. private _sceneRenderObserver;
  95043. private _scene;
  95044. private _targetPosition;
  95045. private _virtualOriginMesh;
  95046. private _virtualDragMesh;
  95047. private _pointerObserver;
  95048. private _moving;
  95049. private _startingOrientation;
  95050. /**
  95051. * 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)
  95052. */
  95053. private zDragFactor;
  95054. /**
  95055. * If the object should rotate to face the drag origin
  95056. */
  95057. rotateDraggedObject: boolean;
  95058. /**
  95059. * If the behavior is currently in a dragging state
  95060. */
  95061. dragging: boolean;
  95062. /**
  95063. * 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)
  95064. */
  95065. dragDeltaRatio: number;
  95066. /**
  95067. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95068. */
  95069. currentDraggingPointerID: number;
  95070. /**
  95071. * If camera controls should be detached during the drag
  95072. */
  95073. detachCameraControls: boolean;
  95074. /**
  95075. * Fires each time a drag starts
  95076. */
  95077. onDragStartObservable: Observable<{}>;
  95078. /**
  95079. * Fires each time a drag ends (eg. mouse release after drag)
  95080. */
  95081. onDragEndObservable: Observable<{}>;
  95082. /**
  95083. * 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
  95084. */
  95085. constructor();
  95086. /**
  95087. * The name of the behavior
  95088. */
  95089. readonly name: string;
  95090. /**
  95091. * Initializes the behavior
  95092. */
  95093. init(): void;
  95094. /**
  95095. * Attaches the scale behavior the passed in mesh
  95096. * @param ownerNode The mesh that will be scaled around once attached
  95097. */
  95098. attach(ownerNode: Mesh): void;
  95099. /**
  95100. * Detaches the behavior from the mesh
  95101. */
  95102. detach(): void;
  95103. }
  95104. }
  95105. declare module BABYLON {
  95106. /**
  95107. * Class used to apply inverse kinematics to bones
  95108. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  95109. */
  95110. export class BoneIKController {
  95111. private static _tmpVecs;
  95112. private static _tmpQuat;
  95113. private static _tmpMats;
  95114. /**
  95115. * Gets or sets the target mesh
  95116. */
  95117. targetMesh: AbstractMesh;
  95118. /** Gets or sets the mesh used as pole */
  95119. poleTargetMesh: AbstractMesh;
  95120. /**
  95121. * Gets or sets the bone used as pole
  95122. */
  95123. poleTargetBone: Nullable<Bone>;
  95124. /**
  95125. * Gets or sets the target position
  95126. */
  95127. targetPosition: Vector3;
  95128. /**
  95129. * Gets or sets the pole target position
  95130. */
  95131. poleTargetPosition: Vector3;
  95132. /**
  95133. * Gets or sets the pole target local offset
  95134. */
  95135. poleTargetLocalOffset: Vector3;
  95136. /**
  95137. * Gets or sets the pole angle
  95138. */
  95139. poleAngle: number;
  95140. /**
  95141. * Gets or sets the mesh associated with the controller
  95142. */
  95143. mesh: AbstractMesh;
  95144. /**
  95145. * 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)
  95146. */
  95147. slerpAmount: number;
  95148. private _bone1Quat;
  95149. private _bone1Mat;
  95150. private _bone2Ang;
  95151. private _bone1;
  95152. private _bone2;
  95153. private _bone1Length;
  95154. private _bone2Length;
  95155. private _maxAngle;
  95156. private _maxReach;
  95157. private _rightHandedSystem;
  95158. private _bendAxis;
  95159. private _slerping;
  95160. private _adjustRoll;
  95161. /**
  95162. * Gets or sets maximum allowed angle
  95163. */
  95164. maxAngle: number;
  95165. /**
  95166. * Creates a new BoneIKController
  95167. * @param mesh defines the mesh to control
  95168. * @param bone defines the bone to control
  95169. * @param options defines options to set up the controller
  95170. */
  95171. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  95172. targetMesh?: AbstractMesh;
  95173. poleTargetMesh?: AbstractMesh;
  95174. poleTargetBone?: Bone;
  95175. poleTargetLocalOffset?: Vector3;
  95176. poleAngle?: number;
  95177. bendAxis?: Vector3;
  95178. maxAngle?: number;
  95179. slerpAmount?: number;
  95180. });
  95181. private _setMaxAngle;
  95182. /**
  95183. * Force the controller to update the bones
  95184. */
  95185. update(): void;
  95186. }
  95187. }
  95188. declare module BABYLON {
  95189. /**
  95190. * Class used to make a bone look toward a point in space
  95191. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  95192. */
  95193. export class BoneLookController {
  95194. private static _tmpVecs;
  95195. private static _tmpQuat;
  95196. private static _tmpMats;
  95197. /**
  95198. * The target Vector3 that the bone will look at
  95199. */
  95200. target: Vector3;
  95201. /**
  95202. * The mesh that the bone is attached to
  95203. */
  95204. mesh: AbstractMesh;
  95205. /**
  95206. * The bone that will be looking to the target
  95207. */
  95208. bone: Bone;
  95209. /**
  95210. * The up axis of the coordinate system that is used when the bone is rotated
  95211. */
  95212. upAxis: Vector3;
  95213. /**
  95214. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  95215. */
  95216. upAxisSpace: Space;
  95217. /**
  95218. * Used to make an adjustment to the yaw of the bone
  95219. */
  95220. adjustYaw: number;
  95221. /**
  95222. * Used to make an adjustment to the pitch of the bone
  95223. */
  95224. adjustPitch: number;
  95225. /**
  95226. * Used to make an adjustment to the roll of the bone
  95227. */
  95228. adjustRoll: number;
  95229. /**
  95230. * 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)
  95231. */
  95232. slerpAmount: number;
  95233. private _minYaw;
  95234. private _maxYaw;
  95235. private _minPitch;
  95236. private _maxPitch;
  95237. private _minYawSin;
  95238. private _minYawCos;
  95239. private _maxYawSin;
  95240. private _maxYawCos;
  95241. private _midYawConstraint;
  95242. private _minPitchTan;
  95243. private _maxPitchTan;
  95244. private _boneQuat;
  95245. private _slerping;
  95246. private _transformYawPitch;
  95247. private _transformYawPitchInv;
  95248. private _firstFrameSkipped;
  95249. private _yawRange;
  95250. private _fowardAxis;
  95251. /**
  95252. * Gets or sets the minimum yaw angle that the bone can look to
  95253. */
  95254. minYaw: number;
  95255. /**
  95256. * Gets or sets the maximum yaw angle that the bone can look to
  95257. */
  95258. maxYaw: number;
  95259. /**
  95260. * Gets or sets the minimum pitch angle that the bone can look to
  95261. */
  95262. minPitch: number;
  95263. /**
  95264. * Gets or sets the maximum pitch angle that the bone can look to
  95265. */
  95266. maxPitch: number;
  95267. /**
  95268. * Create a BoneLookController
  95269. * @param mesh the mesh that the bone belongs to
  95270. * @param bone the bone that will be looking to the target
  95271. * @param target the target Vector3 to look at
  95272. * @param options optional settings:
  95273. * * maxYaw: the maximum angle the bone will yaw to
  95274. * * minYaw: the minimum angle the bone will yaw to
  95275. * * maxPitch: the maximum angle the bone will pitch to
  95276. * * minPitch: the minimum angle the bone will yaw to
  95277. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  95278. * * upAxis: the up axis of the coordinate system
  95279. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  95280. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  95281. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  95282. * * adjustYaw: used to make an adjustment to the yaw of the bone
  95283. * * adjustPitch: used to make an adjustment to the pitch of the bone
  95284. * * adjustRoll: used to make an adjustment to the roll of the bone
  95285. **/
  95286. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  95287. maxYaw?: number;
  95288. minYaw?: number;
  95289. maxPitch?: number;
  95290. minPitch?: number;
  95291. slerpAmount?: number;
  95292. upAxis?: Vector3;
  95293. upAxisSpace?: Space;
  95294. yawAxis?: Vector3;
  95295. pitchAxis?: Vector3;
  95296. adjustYaw?: number;
  95297. adjustPitch?: number;
  95298. adjustRoll?: number;
  95299. });
  95300. /**
  95301. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  95302. */
  95303. update(): void;
  95304. private _getAngleDiff;
  95305. private _getAngleBetween;
  95306. private _isAngleBetween;
  95307. }
  95308. }
  95309. declare module BABYLON {
  95310. /**
  95311. * Manage the gamepad inputs to control an arc rotate camera.
  95312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95313. */
  95314. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  95315. /**
  95316. * Defines the camera the input is attached to.
  95317. */
  95318. camera: ArcRotateCamera;
  95319. /**
  95320. * Defines the gamepad the input is gathering event from.
  95321. */
  95322. gamepad: Nullable<Gamepad>;
  95323. /**
  95324. * Defines the gamepad rotation sensiblity.
  95325. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95326. */
  95327. gamepadRotationSensibility: number;
  95328. /**
  95329. * Defines the gamepad move sensiblity.
  95330. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95331. */
  95332. gamepadMoveSensibility: number;
  95333. private _onGamepadConnectedObserver;
  95334. private _onGamepadDisconnectedObserver;
  95335. /**
  95336. * Attach the input controls to a specific dom element to get the input from.
  95337. * @param element Defines the element the controls should be listened from
  95338. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95339. */
  95340. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95341. /**
  95342. * Detach the current controls from the specified dom element.
  95343. * @param element Defines the element to stop listening the inputs from
  95344. */
  95345. detachControl(element: Nullable<HTMLElement>): void;
  95346. /**
  95347. * Update the current camera state depending on the inputs that have been used this frame.
  95348. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95349. */
  95350. checkInputs(): void;
  95351. /**
  95352. * Gets the class name of the current intput.
  95353. * @returns the class name
  95354. */
  95355. getClassName(): string;
  95356. /**
  95357. * Get the friendly name associated with the input class.
  95358. * @returns the input friendly name
  95359. */
  95360. getSimpleName(): string;
  95361. }
  95362. }
  95363. declare module BABYLON {
  95364. interface ArcRotateCameraInputsManager {
  95365. /**
  95366. * Add orientation input support to the input manager.
  95367. * @returns the current input manager
  95368. */
  95369. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  95370. }
  95371. /**
  95372. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  95373. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95374. */
  95375. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  95376. /**
  95377. * Defines the camera the input is attached to.
  95378. */
  95379. camera: ArcRotateCamera;
  95380. /**
  95381. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  95382. */
  95383. alphaCorrection: number;
  95384. /**
  95385. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  95386. */
  95387. gammaCorrection: number;
  95388. private _alpha;
  95389. private _gamma;
  95390. private _dirty;
  95391. private _deviceOrientationHandler;
  95392. /**
  95393. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  95394. */
  95395. constructor();
  95396. /**
  95397. * Attach the input controls to a specific dom element to get the input from.
  95398. * @param element Defines the element the controls should be listened from
  95399. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95400. */
  95401. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95402. /** @hidden */
  95403. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  95404. /**
  95405. * Update the current camera state depending on the inputs that have been used this frame.
  95406. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95407. */
  95408. checkInputs(): void;
  95409. /**
  95410. * Detach the current controls from the specified dom element.
  95411. * @param element Defines the element to stop listening the inputs from
  95412. */
  95413. detachControl(element: Nullable<HTMLElement>): void;
  95414. /**
  95415. * Gets the class name of the current intput.
  95416. * @returns the class name
  95417. */
  95418. getClassName(): string;
  95419. /**
  95420. * Get the friendly name associated with the input class.
  95421. * @returns the input friendly name
  95422. */
  95423. getSimpleName(): string;
  95424. }
  95425. }
  95426. declare module BABYLON {
  95427. /**
  95428. * Listen to mouse events to control the camera.
  95429. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95430. */
  95431. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  95432. /**
  95433. * Defines the camera the input is attached to.
  95434. */
  95435. camera: FlyCamera;
  95436. /**
  95437. * Defines if touch is enabled. (Default is true.)
  95438. */
  95439. touchEnabled: boolean;
  95440. /**
  95441. * Defines the buttons associated with the input to handle camera rotation.
  95442. */
  95443. buttons: number[];
  95444. /**
  95445. * Assign buttons for Yaw control.
  95446. */
  95447. buttonsYaw: number[];
  95448. /**
  95449. * Assign buttons for Pitch control.
  95450. */
  95451. buttonsPitch: number[];
  95452. /**
  95453. * Assign buttons for Roll control.
  95454. */
  95455. buttonsRoll: number[];
  95456. /**
  95457. * Detect if any button is being pressed while mouse is moved.
  95458. * -1 = Mouse locked.
  95459. * 0 = Left button.
  95460. * 1 = Middle Button.
  95461. * 2 = Right Button.
  95462. */
  95463. activeButton: number;
  95464. /**
  95465. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  95466. * Higher values reduce its sensitivity.
  95467. */
  95468. angularSensibility: number;
  95469. private _mousemoveCallback;
  95470. private _observer;
  95471. private _rollObserver;
  95472. private previousPosition;
  95473. private noPreventDefault;
  95474. private element;
  95475. /**
  95476. * Listen to mouse events to control the camera.
  95477. * @param touchEnabled Define if touch is enabled. (Default is true.)
  95478. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95479. */
  95480. constructor(touchEnabled?: boolean);
  95481. /**
  95482. * Attach the mouse control to the HTML DOM element.
  95483. * @param element Defines the element that listens to the input events.
  95484. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  95485. */
  95486. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95487. /**
  95488. * Detach the current controls from the specified dom element.
  95489. * @param element Defines the element to stop listening the inputs from
  95490. */
  95491. detachControl(element: Nullable<HTMLElement>): void;
  95492. /**
  95493. * Gets the class name of the current input.
  95494. * @returns the class name.
  95495. */
  95496. getClassName(): string;
  95497. /**
  95498. * Get the friendly name associated with the input class.
  95499. * @returns the input's friendly name.
  95500. */
  95501. getSimpleName(): string;
  95502. private _pointerInput;
  95503. private _onMouseMove;
  95504. /**
  95505. * Rotate camera by mouse offset.
  95506. */
  95507. private rotateCamera;
  95508. }
  95509. }
  95510. declare module BABYLON {
  95511. /**
  95512. * Default Inputs manager for the FlyCamera.
  95513. * It groups all the default supported inputs for ease of use.
  95514. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95515. */
  95516. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  95517. /**
  95518. * Instantiates a new FlyCameraInputsManager.
  95519. * @param camera Defines the camera the inputs belong to.
  95520. */
  95521. constructor(camera: FlyCamera);
  95522. /**
  95523. * Add keyboard input support to the input manager.
  95524. * @returns the new FlyCameraKeyboardMoveInput().
  95525. */
  95526. addKeyboard(): FlyCameraInputsManager;
  95527. /**
  95528. * Add mouse input support to the input manager.
  95529. * @param touchEnabled Enable touch screen support.
  95530. * @returns the new FlyCameraMouseInput().
  95531. */
  95532. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  95533. }
  95534. }
  95535. declare module BABYLON {
  95536. /**
  95537. * This is a flying camera, designed for 3D movement and rotation in all directions,
  95538. * such as in a 3D Space Shooter or a Flight Simulator.
  95539. */
  95540. export class FlyCamera extends TargetCamera {
  95541. /**
  95542. * Define the collision ellipsoid of the camera.
  95543. * This is helpful for simulating a camera body, like a player's body.
  95544. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95545. */
  95546. ellipsoid: Vector3;
  95547. /**
  95548. * Define an offset for the position of the ellipsoid around the camera.
  95549. * This can be helpful if the camera is attached away from the player's body center,
  95550. * such as at its head.
  95551. */
  95552. ellipsoidOffset: Vector3;
  95553. /**
  95554. * Enable or disable collisions of the camera with the rest of the scene objects.
  95555. */
  95556. checkCollisions: boolean;
  95557. /**
  95558. * Enable or disable gravity on the camera.
  95559. */
  95560. applyGravity: boolean;
  95561. /**
  95562. * Define the current direction the camera is moving to.
  95563. */
  95564. cameraDirection: Vector3;
  95565. /**
  95566. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  95567. * This overrides and empties cameraRotation.
  95568. */
  95569. rotationQuaternion: Quaternion;
  95570. /**
  95571. * Track Roll to maintain the wanted Rolling when looking around.
  95572. */
  95573. _trackRoll: number;
  95574. /**
  95575. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  95576. */
  95577. rollCorrect: number;
  95578. /**
  95579. * Mimic a banked turn, Rolling the camera when Yawing.
  95580. * It's recommended to use rollCorrect = 10 for faster banking correction.
  95581. */
  95582. bankedTurn: boolean;
  95583. /**
  95584. * Limit in radians for how much Roll banking will add. (Default: 90°)
  95585. */
  95586. bankedTurnLimit: number;
  95587. /**
  95588. * Value of 0 disables the banked Roll.
  95589. * Value of 1 is equal to the Yaw angle in radians.
  95590. */
  95591. bankedTurnMultiplier: number;
  95592. /**
  95593. * The inputs manager loads all the input sources, such as keyboard and mouse.
  95594. */
  95595. inputs: FlyCameraInputsManager;
  95596. /**
  95597. * Gets the input sensibility for mouse input.
  95598. * Higher values reduce sensitivity.
  95599. */
  95600. /**
  95601. * Sets the input sensibility for a mouse input.
  95602. * Higher values reduce sensitivity.
  95603. */
  95604. angularSensibility: number;
  95605. /**
  95606. * Get the keys for camera movement forward.
  95607. */
  95608. /**
  95609. * Set the keys for camera movement forward.
  95610. */
  95611. keysForward: number[];
  95612. /**
  95613. * Get the keys for camera movement backward.
  95614. */
  95615. keysBackward: number[];
  95616. /**
  95617. * Get the keys for camera movement up.
  95618. */
  95619. /**
  95620. * Set the keys for camera movement up.
  95621. */
  95622. keysUp: number[];
  95623. /**
  95624. * Get the keys for camera movement down.
  95625. */
  95626. /**
  95627. * Set the keys for camera movement down.
  95628. */
  95629. keysDown: number[];
  95630. /**
  95631. * Get the keys for camera movement left.
  95632. */
  95633. /**
  95634. * Set the keys for camera movement left.
  95635. */
  95636. keysLeft: number[];
  95637. /**
  95638. * Set the keys for camera movement right.
  95639. */
  95640. /**
  95641. * Set the keys for camera movement right.
  95642. */
  95643. keysRight: number[];
  95644. /**
  95645. * Event raised when the camera collides with a mesh in the scene.
  95646. */
  95647. onCollide: (collidedMesh: AbstractMesh) => void;
  95648. private _collider;
  95649. private _needMoveForGravity;
  95650. private _oldPosition;
  95651. private _diffPosition;
  95652. private _newPosition;
  95653. /** @hidden */
  95654. _localDirection: Vector3;
  95655. /** @hidden */
  95656. _transformedDirection: Vector3;
  95657. /**
  95658. * Instantiates a FlyCamera.
  95659. * This is a flying camera, designed for 3D movement and rotation in all directions,
  95660. * such as in a 3D Space Shooter or a Flight Simulator.
  95661. * @param name Define the name of the camera in the scene.
  95662. * @param position Define the starting position of the camera in the scene.
  95663. * @param scene Define the scene the camera belongs to.
  95664. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  95665. */
  95666. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95667. /**
  95668. * Attach a control to the HTML DOM element.
  95669. * @param element Defines the element that listens to the input events.
  95670. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  95671. */
  95672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95673. /**
  95674. * Detach a control from the HTML DOM element.
  95675. * The camera will stop reacting to that input.
  95676. * @param element Defines the element that listens to the input events.
  95677. */
  95678. detachControl(element: HTMLElement): void;
  95679. private _collisionMask;
  95680. /**
  95681. * Get the mask that the camera ignores in collision events.
  95682. */
  95683. /**
  95684. * Set the mask that the camera ignores in collision events.
  95685. */
  95686. collisionMask: number;
  95687. /** @hidden */
  95688. _collideWithWorld(displacement: Vector3): void;
  95689. /** @hidden */
  95690. private _onCollisionPositionChange;
  95691. /** @hidden */
  95692. _checkInputs(): void;
  95693. /** @hidden */
  95694. _decideIfNeedsToMove(): boolean;
  95695. /** @hidden */
  95696. _updatePosition(): void;
  95697. /**
  95698. * Restore the Roll to its target value at the rate specified.
  95699. * @param rate - Higher means slower restoring.
  95700. * @hidden
  95701. */
  95702. restoreRoll(rate: number): void;
  95703. /**
  95704. * Destroy the camera and release the current resources held by it.
  95705. */
  95706. dispose(): void;
  95707. /**
  95708. * Get the current object class name.
  95709. * @returns the class name.
  95710. */
  95711. getClassName(): string;
  95712. }
  95713. }
  95714. declare module BABYLON {
  95715. /**
  95716. * Listen to keyboard events to control the camera.
  95717. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95718. */
  95719. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  95720. /**
  95721. * Defines the camera the input is attached to.
  95722. */
  95723. camera: FlyCamera;
  95724. /**
  95725. * The list of keyboard keys used to control the forward move of the camera.
  95726. */
  95727. keysForward: number[];
  95728. /**
  95729. * The list of keyboard keys used to control the backward move of the camera.
  95730. */
  95731. keysBackward: number[];
  95732. /**
  95733. * The list of keyboard keys used to control the forward move of the camera.
  95734. */
  95735. keysUp: number[];
  95736. /**
  95737. * The list of keyboard keys used to control the backward move of the camera.
  95738. */
  95739. keysDown: number[];
  95740. /**
  95741. * The list of keyboard keys used to control the right strafe move of the camera.
  95742. */
  95743. keysRight: number[];
  95744. /**
  95745. * The list of keyboard keys used to control the left strafe move of the camera.
  95746. */
  95747. keysLeft: number[];
  95748. private _keys;
  95749. private _onCanvasBlurObserver;
  95750. private _onKeyboardObserver;
  95751. private _engine;
  95752. private _scene;
  95753. /**
  95754. * Attach the input controls to a specific dom element to get the input from.
  95755. * @param element Defines the element the controls should be listened from
  95756. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95757. */
  95758. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95759. /**
  95760. * Detach the current controls from the specified dom element.
  95761. * @param element Defines the element to stop listening the inputs from
  95762. */
  95763. detachControl(element: Nullable<HTMLElement>): void;
  95764. /**
  95765. * Gets the class name of the current intput.
  95766. * @returns the class name
  95767. */
  95768. getClassName(): string;
  95769. /** @hidden */
  95770. _onLostFocus(e: FocusEvent): void;
  95771. /**
  95772. * Get the friendly name associated with the input class.
  95773. * @returns the input friendly name
  95774. */
  95775. getSimpleName(): string;
  95776. /**
  95777. * Update the current camera state depending on the inputs that have been used this frame.
  95778. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95779. */
  95780. checkInputs(): void;
  95781. }
  95782. }
  95783. declare module BABYLON {
  95784. /**
  95785. * Manage the mouse wheel inputs to control a follow camera.
  95786. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95787. */
  95788. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  95789. /**
  95790. * Defines the camera the input is attached to.
  95791. */
  95792. camera: FollowCamera;
  95793. /**
  95794. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  95795. */
  95796. axisControlRadius: boolean;
  95797. /**
  95798. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  95799. */
  95800. axisControlHeight: boolean;
  95801. /**
  95802. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  95803. */
  95804. axisControlRotation: boolean;
  95805. /**
  95806. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  95807. * relation to mouseWheel events.
  95808. */
  95809. wheelPrecision: number;
  95810. /**
  95811. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  95812. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  95813. */
  95814. wheelDeltaPercentage: number;
  95815. private _wheel;
  95816. private _observer;
  95817. /**
  95818. * Attach the input controls to a specific dom element to get the input from.
  95819. * @param element Defines the element the controls should be listened from
  95820. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95821. */
  95822. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95823. /**
  95824. * Detach the current controls from the specified dom element.
  95825. * @param element Defines the element to stop listening the inputs from
  95826. */
  95827. detachControl(element: Nullable<HTMLElement>): void;
  95828. /**
  95829. * Gets the class name of the current intput.
  95830. * @returns the class name
  95831. */
  95832. getClassName(): string;
  95833. /**
  95834. * Get the friendly name associated with the input class.
  95835. * @returns the input friendly name
  95836. */
  95837. getSimpleName(): string;
  95838. }
  95839. }
  95840. declare module BABYLON {
  95841. /**
  95842. * Manage the pointers inputs to control an follow camera.
  95843. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95844. */
  95845. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  95846. /**
  95847. * Defines the camera the input is attached to.
  95848. */
  95849. camera: FollowCamera;
  95850. /**
  95851. * Gets the class name of the current input.
  95852. * @returns the class name
  95853. */
  95854. getClassName(): string;
  95855. /**
  95856. * Defines the pointer angular sensibility along the X axis or how fast is
  95857. * the camera rotating.
  95858. * A negative number will reverse the axis direction.
  95859. */
  95860. angularSensibilityX: number;
  95861. /**
  95862. * Defines the pointer angular sensibility along the Y axis or how fast is
  95863. * the camera rotating.
  95864. * A negative number will reverse the axis direction.
  95865. */
  95866. angularSensibilityY: number;
  95867. /**
  95868. * Defines the pointer pinch precision or how fast is the camera zooming.
  95869. * A negative number will reverse the axis direction.
  95870. */
  95871. pinchPrecision: number;
  95872. /**
  95873. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  95874. * from 0.
  95875. * It defines the percentage of current camera.radius to use as delta when
  95876. * pinch zoom is used.
  95877. */
  95878. pinchDeltaPercentage: number;
  95879. /**
  95880. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  95881. */
  95882. axisXControlRadius: boolean;
  95883. /**
  95884. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  95885. */
  95886. axisXControlHeight: boolean;
  95887. /**
  95888. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  95889. */
  95890. axisXControlRotation: boolean;
  95891. /**
  95892. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  95893. */
  95894. axisYControlRadius: boolean;
  95895. /**
  95896. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  95897. */
  95898. axisYControlHeight: boolean;
  95899. /**
  95900. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  95901. */
  95902. axisYControlRotation: boolean;
  95903. /**
  95904. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  95905. */
  95906. axisPinchControlRadius: boolean;
  95907. /**
  95908. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  95909. */
  95910. axisPinchControlHeight: boolean;
  95911. /**
  95912. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  95913. */
  95914. axisPinchControlRotation: boolean;
  95915. /**
  95916. * Log error messages if basic misconfiguration has occurred.
  95917. */
  95918. warningEnable: boolean;
  95919. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  95920. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  95921. private _warningCounter;
  95922. private _warning;
  95923. }
  95924. }
  95925. declare module BABYLON {
  95926. /**
  95927. * Default Inputs manager for the FollowCamera.
  95928. * It groups all the default supported inputs for ease of use.
  95929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95930. */
  95931. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  95932. /**
  95933. * Instantiates a new FollowCameraInputsManager.
  95934. * @param camera Defines the camera the inputs belong to
  95935. */
  95936. constructor(camera: FollowCamera);
  95937. /**
  95938. * Add keyboard input support to the input manager.
  95939. * @returns the current input manager
  95940. */
  95941. addKeyboard(): FollowCameraInputsManager;
  95942. /**
  95943. * Add mouse wheel input support to the input manager.
  95944. * @returns the current input manager
  95945. */
  95946. addMouseWheel(): FollowCameraInputsManager;
  95947. /**
  95948. * Add pointers input support to the input manager.
  95949. * @returns the current input manager
  95950. */
  95951. addPointers(): FollowCameraInputsManager;
  95952. /**
  95953. * Add orientation input support to the input manager.
  95954. * @returns the current input manager
  95955. */
  95956. addVRDeviceOrientation(): FollowCameraInputsManager;
  95957. }
  95958. }
  95959. declare module BABYLON {
  95960. /**
  95961. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  95962. * an arc rotate version arcFollowCamera are available.
  95963. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  95964. */
  95965. export class FollowCamera extends TargetCamera {
  95966. /**
  95967. * Distance the follow camera should follow an object at
  95968. */
  95969. radius: number;
  95970. /**
  95971. * Minimum allowed distance of the camera to the axis of rotation
  95972. * (The camera can not get closer).
  95973. * This can help limiting how the Camera is able to move in the scene.
  95974. */
  95975. lowerRadiusLimit: Nullable<number>;
  95976. /**
  95977. * Maximum allowed distance of the camera to the axis of rotation
  95978. * (The camera can not get further).
  95979. * This can help limiting how the Camera is able to move in the scene.
  95980. */
  95981. upperRadiusLimit: Nullable<number>;
  95982. /**
  95983. * Define a rotation offset between the camera and the object it follows
  95984. */
  95985. rotationOffset: number;
  95986. /**
  95987. * Minimum allowed angle to camera position relative to target object.
  95988. * This can help limiting how the Camera is able to move in the scene.
  95989. */
  95990. lowerRotationOffsetLimit: Nullable<number>;
  95991. /**
  95992. * Maximum allowed angle to camera position relative to target object.
  95993. * This can help limiting how the Camera is able to move in the scene.
  95994. */
  95995. upperRotationOffsetLimit: Nullable<number>;
  95996. /**
  95997. * Define a height offset between the camera and the object it follows.
  95998. * It can help following an object from the top (like a car chaing a plane)
  95999. */
  96000. heightOffset: number;
  96001. /**
  96002. * Minimum allowed height of camera position relative to target object.
  96003. * This can help limiting how the Camera is able to move in the scene.
  96004. */
  96005. lowerHeightOffsetLimit: Nullable<number>;
  96006. /**
  96007. * Maximum allowed height of camera position relative to target object.
  96008. * This can help limiting how the Camera is able to move in the scene.
  96009. */
  96010. upperHeightOffsetLimit: Nullable<number>;
  96011. /**
  96012. * Define how fast the camera can accelerate to follow it s target.
  96013. */
  96014. cameraAcceleration: number;
  96015. /**
  96016. * Define the speed limit of the camera following an object.
  96017. */
  96018. maxCameraSpeed: number;
  96019. /**
  96020. * Define the target of the camera.
  96021. */
  96022. lockedTarget: Nullable<AbstractMesh>;
  96023. /**
  96024. * Defines the input associated with the camera.
  96025. */
  96026. inputs: FollowCameraInputsManager;
  96027. /**
  96028. * Instantiates the follow camera.
  96029. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96030. * @param name Define the name of the camera in the scene
  96031. * @param position Define the position of the camera
  96032. * @param scene Define the scene the camera belong to
  96033. * @param lockedTarget Define the target of the camera
  96034. */
  96035. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  96036. private _follow;
  96037. /**
  96038. * Attached controls to the current camera.
  96039. * @param element Defines the element the controls should be listened from
  96040. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96041. */
  96042. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96043. /**
  96044. * Detach the current controls from the camera.
  96045. * The camera will stop reacting to inputs.
  96046. * @param element Defines the element to stop listening the inputs from
  96047. */
  96048. detachControl(element: HTMLElement): void;
  96049. /** @hidden */
  96050. _checkInputs(): void;
  96051. private _checkLimits;
  96052. /**
  96053. * Gets the camera class name.
  96054. * @returns the class name
  96055. */
  96056. getClassName(): string;
  96057. }
  96058. /**
  96059. * Arc Rotate version of the follow camera.
  96060. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  96061. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96062. */
  96063. export class ArcFollowCamera extends TargetCamera {
  96064. /** The longitudinal angle of the camera */
  96065. alpha: number;
  96066. /** The latitudinal angle of the camera */
  96067. beta: number;
  96068. /** The radius of the camera from its target */
  96069. radius: number;
  96070. /** Define the camera target (the messh it should follow) */
  96071. target: Nullable<AbstractMesh>;
  96072. private _cartesianCoordinates;
  96073. /**
  96074. * Instantiates a new ArcFollowCamera
  96075. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96076. * @param name Define the name of the camera
  96077. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  96078. * @param beta Define the rotation angle of the camera around the elevation axis
  96079. * @param radius Define the radius of the camera from its target point
  96080. * @param target Define the target of the camera
  96081. * @param scene Define the scene the camera belongs to
  96082. */
  96083. constructor(name: string,
  96084. /** The longitudinal angle of the camera */
  96085. alpha: number,
  96086. /** The latitudinal angle of the camera */
  96087. beta: number,
  96088. /** The radius of the camera from its target */
  96089. radius: number,
  96090. /** Define the camera target (the messh it should follow) */
  96091. target: Nullable<AbstractMesh>, scene: Scene);
  96092. private _follow;
  96093. /** @hidden */
  96094. _checkInputs(): void;
  96095. /**
  96096. * Returns the class name of the object.
  96097. * It is mostly used internally for serialization purposes.
  96098. */
  96099. getClassName(): string;
  96100. }
  96101. }
  96102. declare module BABYLON {
  96103. /**
  96104. * Manage the keyboard inputs to control the movement of a follow camera.
  96105. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96106. */
  96107. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  96108. /**
  96109. * Defines the camera the input is attached to.
  96110. */
  96111. camera: FollowCamera;
  96112. /**
  96113. * Defines the list of key codes associated with the up action (increase heightOffset)
  96114. */
  96115. keysHeightOffsetIncr: number[];
  96116. /**
  96117. * Defines the list of key codes associated with the down action (decrease heightOffset)
  96118. */
  96119. keysHeightOffsetDecr: number[];
  96120. /**
  96121. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  96122. */
  96123. keysHeightOffsetModifierAlt: boolean;
  96124. /**
  96125. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  96126. */
  96127. keysHeightOffsetModifierCtrl: boolean;
  96128. /**
  96129. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  96130. */
  96131. keysHeightOffsetModifierShift: boolean;
  96132. /**
  96133. * Defines the list of key codes associated with the left action (increase rotationOffset)
  96134. */
  96135. keysRotationOffsetIncr: number[];
  96136. /**
  96137. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  96138. */
  96139. keysRotationOffsetDecr: number[];
  96140. /**
  96141. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  96142. */
  96143. keysRotationOffsetModifierAlt: boolean;
  96144. /**
  96145. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  96146. */
  96147. keysRotationOffsetModifierCtrl: boolean;
  96148. /**
  96149. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  96150. */
  96151. keysRotationOffsetModifierShift: boolean;
  96152. /**
  96153. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  96154. */
  96155. keysRadiusIncr: number[];
  96156. /**
  96157. * Defines the list of key codes associated with the zoom-out action (increase radius)
  96158. */
  96159. keysRadiusDecr: number[];
  96160. /**
  96161. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  96162. */
  96163. keysRadiusModifierAlt: boolean;
  96164. /**
  96165. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  96166. */
  96167. keysRadiusModifierCtrl: boolean;
  96168. /**
  96169. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  96170. */
  96171. keysRadiusModifierShift: boolean;
  96172. /**
  96173. * Defines the rate of change of heightOffset.
  96174. */
  96175. heightSensibility: number;
  96176. /**
  96177. * Defines the rate of change of rotationOffset.
  96178. */
  96179. rotationSensibility: number;
  96180. /**
  96181. * Defines the rate of change of radius.
  96182. */
  96183. radiusSensibility: number;
  96184. private _keys;
  96185. private _ctrlPressed;
  96186. private _altPressed;
  96187. private _shiftPressed;
  96188. private _onCanvasBlurObserver;
  96189. private _onKeyboardObserver;
  96190. private _engine;
  96191. private _scene;
  96192. /**
  96193. * Attach the input controls to a specific dom element to get the input from.
  96194. * @param element Defines the element the controls should be listened from
  96195. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96196. */
  96197. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96198. /**
  96199. * Detach the current controls from the specified dom element.
  96200. * @param element Defines the element to stop listening the inputs from
  96201. */
  96202. detachControl(element: Nullable<HTMLElement>): void;
  96203. /**
  96204. * Update the current camera state depending on the inputs that have been used this frame.
  96205. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96206. */
  96207. checkInputs(): void;
  96208. /**
  96209. * Gets the class name of the current input.
  96210. * @returns the class name
  96211. */
  96212. getClassName(): string;
  96213. /**
  96214. * Get the friendly name associated with the input class.
  96215. * @returns the input friendly name
  96216. */
  96217. getSimpleName(): string;
  96218. /**
  96219. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96220. * allow modification of the heightOffset value.
  96221. */
  96222. private _modifierHeightOffset;
  96223. /**
  96224. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96225. * allow modification of the rotationOffset value.
  96226. */
  96227. private _modifierRotationOffset;
  96228. /**
  96229. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96230. * allow modification of the radius value.
  96231. */
  96232. private _modifierRadius;
  96233. }
  96234. }
  96235. declare module BABYLON {
  96236. interface FreeCameraInputsManager {
  96237. /**
  96238. * @hidden
  96239. */
  96240. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  96241. /**
  96242. * Add orientation input support to the input manager.
  96243. * @returns the current input manager
  96244. */
  96245. addDeviceOrientation(): FreeCameraInputsManager;
  96246. }
  96247. /**
  96248. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  96249. * Screen rotation is taken into account.
  96250. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96251. */
  96252. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  96253. private _camera;
  96254. private _screenOrientationAngle;
  96255. private _constantTranform;
  96256. private _screenQuaternion;
  96257. private _alpha;
  96258. private _beta;
  96259. private _gamma;
  96260. /**
  96261. * @hidden
  96262. */
  96263. _onDeviceOrientationChangedObservable: Observable<void>;
  96264. /**
  96265. * Instantiates a new input
  96266. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96267. */
  96268. constructor();
  96269. /**
  96270. * Define the camera controlled by the input.
  96271. */
  96272. camera: FreeCamera;
  96273. /**
  96274. * Attach the input controls to a specific dom element to get the input from.
  96275. * @param element Defines the element the controls should be listened from
  96276. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96277. */
  96278. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96279. private _orientationChanged;
  96280. private _deviceOrientation;
  96281. /**
  96282. * Detach the current controls from the specified dom element.
  96283. * @param element Defines the element to stop listening the inputs from
  96284. */
  96285. detachControl(element: Nullable<HTMLElement>): void;
  96286. /**
  96287. * Update the current camera state depending on the inputs that have been used this frame.
  96288. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96289. */
  96290. checkInputs(): void;
  96291. /**
  96292. * Gets the class name of the current intput.
  96293. * @returns the class name
  96294. */
  96295. getClassName(): string;
  96296. /**
  96297. * Get the friendly name associated with the input class.
  96298. * @returns the input friendly name
  96299. */
  96300. getSimpleName(): string;
  96301. }
  96302. }
  96303. declare module BABYLON {
  96304. /**
  96305. * Manage the gamepad inputs to control a free camera.
  96306. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96307. */
  96308. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  96309. /**
  96310. * Define the camera the input is attached to.
  96311. */
  96312. camera: FreeCamera;
  96313. /**
  96314. * Define the Gamepad controlling the input
  96315. */
  96316. gamepad: Nullable<Gamepad>;
  96317. /**
  96318. * Defines the gamepad rotation sensiblity.
  96319. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96320. */
  96321. gamepadAngularSensibility: number;
  96322. /**
  96323. * Defines the gamepad move sensiblity.
  96324. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96325. */
  96326. gamepadMoveSensibility: number;
  96327. private _onGamepadConnectedObserver;
  96328. private _onGamepadDisconnectedObserver;
  96329. private _cameraTransform;
  96330. private _deltaTransform;
  96331. private _vector3;
  96332. private _vector2;
  96333. /**
  96334. * Attach the input controls to a specific dom element to get the input from.
  96335. * @param element Defines the element the controls should be listened from
  96336. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96337. */
  96338. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96339. /**
  96340. * Detach the current controls from the specified dom element.
  96341. * @param element Defines the element to stop listening the inputs from
  96342. */
  96343. detachControl(element: Nullable<HTMLElement>): void;
  96344. /**
  96345. * Update the current camera state depending on the inputs that have been used this frame.
  96346. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96347. */
  96348. checkInputs(): void;
  96349. /**
  96350. * Gets the class name of the current intput.
  96351. * @returns the class name
  96352. */
  96353. getClassName(): string;
  96354. /**
  96355. * Get the friendly name associated with the input class.
  96356. * @returns the input friendly name
  96357. */
  96358. getSimpleName(): string;
  96359. }
  96360. }
  96361. declare module BABYLON {
  96362. /**
  96363. * Defines the potential axis of a Joystick
  96364. */
  96365. export enum JoystickAxis {
  96366. /** X axis */
  96367. X = 0,
  96368. /** Y axis */
  96369. Y = 1,
  96370. /** Z axis */
  96371. Z = 2
  96372. }
  96373. /**
  96374. * Class used to define virtual joystick (used in touch mode)
  96375. */
  96376. export class VirtualJoystick {
  96377. /**
  96378. * Gets or sets a boolean indicating that left and right values must be inverted
  96379. */
  96380. reverseLeftRight: boolean;
  96381. /**
  96382. * Gets or sets a boolean indicating that up and down values must be inverted
  96383. */
  96384. reverseUpDown: boolean;
  96385. /**
  96386. * Gets the offset value for the position (ie. the change of the position value)
  96387. */
  96388. deltaPosition: Vector3;
  96389. /**
  96390. * Gets a boolean indicating if the virtual joystick was pressed
  96391. */
  96392. pressed: boolean;
  96393. /**
  96394. * Canvas the virtual joystick will render onto, default z-index of this is 5
  96395. */
  96396. static Canvas: Nullable<HTMLCanvasElement>;
  96397. private static _globalJoystickIndex;
  96398. private static vjCanvasContext;
  96399. private static vjCanvasWidth;
  96400. private static vjCanvasHeight;
  96401. private static halfWidth;
  96402. private _action;
  96403. private _axisTargetedByLeftAndRight;
  96404. private _axisTargetedByUpAndDown;
  96405. private _joystickSensibility;
  96406. private _inversedSensibility;
  96407. private _joystickPointerID;
  96408. private _joystickColor;
  96409. private _joystickPointerPos;
  96410. private _joystickPreviousPointerPos;
  96411. private _joystickPointerStartPos;
  96412. private _deltaJoystickVector;
  96413. private _leftJoystick;
  96414. private _touches;
  96415. private _onPointerDownHandlerRef;
  96416. private _onPointerMoveHandlerRef;
  96417. private _onPointerUpHandlerRef;
  96418. private _onResize;
  96419. /**
  96420. * Creates a new virtual joystick
  96421. * @param leftJoystick defines that the joystick is for left hand (false by default)
  96422. */
  96423. constructor(leftJoystick?: boolean);
  96424. /**
  96425. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  96426. * @param newJoystickSensibility defines the new sensibility
  96427. */
  96428. setJoystickSensibility(newJoystickSensibility: number): void;
  96429. private _onPointerDown;
  96430. private _onPointerMove;
  96431. private _onPointerUp;
  96432. /**
  96433. * Change the color of the virtual joystick
  96434. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  96435. */
  96436. setJoystickColor(newColor: string): void;
  96437. /**
  96438. * Defines a callback to call when the joystick is touched
  96439. * @param action defines the callback
  96440. */
  96441. setActionOnTouch(action: () => any): void;
  96442. /**
  96443. * Defines which axis you'd like to control for left & right
  96444. * @param axis defines the axis to use
  96445. */
  96446. setAxisForLeftRight(axis: JoystickAxis): void;
  96447. /**
  96448. * Defines which axis you'd like to control for up & down
  96449. * @param axis defines the axis to use
  96450. */
  96451. setAxisForUpDown(axis: JoystickAxis): void;
  96452. private _drawVirtualJoystick;
  96453. /**
  96454. * Release internal HTML canvas
  96455. */
  96456. releaseCanvas(): void;
  96457. }
  96458. }
  96459. declare module BABYLON {
  96460. interface FreeCameraInputsManager {
  96461. /**
  96462. * Add virtual joystick input support to the input manager.
  96463. * @returns the current input manager
  96464. */
  96465. addVirtualJoystick(): FreeCameraInputsManager;
  96466. }
  96467. /**
  96468. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  96469. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96470. */
  96471. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  96472. /**
  96473. * Defines the camera the input is attached to.
  96474. */
  96475. camera: FreeCamera;
  96476. private _leftjoystick;
  96477. private _rightjoystick;
  96478. /**
  96479. * Gets the left stick of the virtual joystick.
  96480. * @returns The virtual Joystick
  96481. */
  96482. getLeftJoystick(): VirtualJoystick;
  96483. /**
  96484. * Gets the right stick of the virtual joystick.
  96485. * @returns The virtual Joystick
  96486. */
  96487. getRightJoystick(): VirtualJoystick;
  96488. /**
  96489. * Update the current camera state depending on the inputs that have been used this frame.
  96490. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96491. */
  96492. checkInputs(): void;
  96493. /**
  96494. * Attach the input controls to a specific dom element to get the input from.
  96495. * @param element Defines the element the controls should be listened from
  96496. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96497. */
  96498. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96499. /**
  96500. * Detach the current controls from the specified dom element.
  96501. * @param element Defines the element to stop listening the inputs from
  96502. */
  96503. detachControl(element: Nullable<HTMLElement>): void;
  96504. /**
  96505. * Gets the class name of the current intput.
  96506. * @returns the class name
  96507. */
  96508. getClassName(): string;
  96509. /**
  96510. * Get the friendly name associated with the input class.
  96511. * @returns the input friendly name
  96512. */
  96513. getSimpleName(): string;
  96514. }
  96515. }
  96516. declare module BABYLON {
  96517. /**
  96518. * This represents a FPS type of camera controlled by touch.
  96519. * This is like a universal camera minus the Gamepad controls.
  96520. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96521. */
  96522. export class TouchCamera extends FreeCamera {
  96523. /**
  96524. * Defines the touch sensibility for rotation.
  96525. * The higher the faster.
  96526. */
  96527. touchAngularSensibility: number;
  96528. /**
  96529. * Defines the touch sensibility for move.
  96530. * The higher the faster.
  96531. */
  96532. touchMoveSensibility: number;
  96533. /**
  96534. * Instantiates a new touch camera.
  96535. * This represents a FPS type of camera controlled by touch.
  96536. * This is like a universal camera minus the Gamepad controls.
  96537. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96538. * @param name Define the name of the camera in the scene
  96539. * @param position Define the start position of the camera in the scene
  96540. * @param scene Define the scene the camera belongs to
  96541. */
  96542. constructor(name: string, position: Vector3, scene: Scene);
  96543. /**
  96544. * Gets the current object class name.
  96545. * @return the class name
  96546. */
  96547. getClassName(): string;
  96548. /** @hidden */
  96549. _setupInputs(): void;
  96550. }
  96551. }
  96552. declare module BABYLON {
  96553. /**
  96554. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  96555. * being tilted forward or back and left or right.
  96556. */
  96557. export class DeviceOrientationCamera extends FreeCamera {
  96558. private _initialQuaternion;
  96559. private _quaternionCache;
  96560. private _tmpDragQuaternion;
  96561. /**
  96562. * Creates a new device orientation camera
  96563. * @param name The name of the camera
  96564. * @param position The start position camera
  96565. * @param scene The scene the camera belongs to
  96566. */
  96567. constructor(name: string, position: Vector3, scene: Scene);
  96568. /**
  96569. * Disabled pointer input on first orientation sensor update (Default: true)
  96570. */
  96571. disablePointerInputWhenUsingDeviceOrientation: boolean;
  96572. private _dragFactor;
  96573. /**
  96574. * Enabled turning on the y axis when the orientation sensor is active
  96575. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  96576. */
  96577. enableHorizontalDragging(dragFactor?: number): void;
  96578. /**
  96579. * Gets the current instance class name ("DeviceOrientationCamera").
  96580. * This helps avoiding instanceof at run time.
  96581. * @returns the class name
  96582. */
  96583. getClassName(): string;
  96584. /**
  96585. * @hidden
  96586. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  96587. */
  96588. _checkInputs(): void;
  96589. /**
  96590. * Reset the camera to its default orientation on the specified axis only.
  96591. * @param axis The axis to reset
  96592. */
  96593. resetToCurrentRotation(axis?: Axis): void;
  96594. }
  96595. }
  96596. declare module BABYLON {
  96597. /**
  96598. * 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,
  96599. * which still works and will still be found in many Playgrounds.
  96600. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96601. */
  96602. export class UniversalCamera extends TouchCamera {
  96603. /**
  96604. * Defines the gamepad rotation sensiblity.
  96605. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96606. */
  96607. gamepadAngularSensibility: number;
  96608. /**
  96609. * Defines the gamepad move sensiblity.
  96610. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96611. */
  96612. gamepadMoveSensibility: number;
  96613. /**
  96614. * 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,
  96615. * which still works and will still be found in many Playgrounds.
  96616. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96617. * @param name Define the name of the camera in the scene
  96618. * @param position Define the start position of the camera in the scene
  96619. * @param scene Define the scene the camera belongs to
  96620. */
  96621. constructor(name: string, position: Vector3, scene: Scene);
  96622. /**
  96623. * Gets the current object class name.
  96624. * @return the class name
  96625. */
  96626. getClassName(): string;
  96627. }
  96628. }
  96629. declare module BABYLON {
  96630. /**
  96631. * This represents a FPS type of camera. This is only here for back compat purpose.
  96632. * Please use the UniversalCamera instead as both are identical.
  96633. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96634. */
  96635. export class GamepadCamera extends UniversalCamera {
  96636. /**
  96637. * Instantiates a new Gamepad Camera
  96638. * This represents a FPS type of camera. This is only here for back compat purpose.
  96639. * Please use the UniversalCamera instead as both are identical.
  96640. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96641. * @param name Define the name of the camera in the scene
  96642. * @param position Define the start position of the camera in the scene
  96643. * @param scene Define the scene the camera belongs to
  96644. */
  96645. constructor(name: string, position: Vector3, scene: Scene);
  96646. /**
  96647. * Gets the current object class name.
  96648. * @return the class name
  96649. */
  96650. getClassName(): string;
  96651. }
  96652. }
  96653. declare module BABYLON {
  96654. /** @hidden */
  96655. export var passPixelShader: {
  96656. name: string;
  96657. shader: string;
  96658. };
  96659. }
  96660. declare module BABYLON {
  96661. /** @hidden */
  96662. export var passCubePixelShader: {
  96663. name: string;
  96664. shader: string;
  96665. };
  96666. }
  96667. declare module BABYLON {
  96668. /**
  96669. * PassPostProcess which produces an output the same as it's input
  96670. */
  96671. export class PassPostProcess extends PostProcess {
  96672. /**
  96673. * Creates the PassPostProcess
  96674. * @param name The name of the effect.
  96675. * @param options The required width/height ratio to downsize to before computing the render pass.
  96676. * @param camera The camera to apply the render pass to.
  96677. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96678. * @param engine The engine which the post process will be applied. (default: current engine)
  96679. * @param reusable If the post process can be reused on the same frame. (default: false)
  96680. * @param textureType The type of texture to be used when performing the post processing.
  96681. * @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)
  96682. */
  96683. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  96684. }
  96685. /**
  96686. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  96687. */
  96688. export class PassCubePostProcess extends PostProcess {
  96689. private _face;
  96690. /**
  96691. * Gets or sets the cube face to display.
  96692. * * 0 is +X
  96693. * * 1 is -X
  96694. * * 2 is +Y
  96695. * * 3 is -Y
  96696. * * 4 is +Z
  96697. * * 5 is -Z
  96698. */
  96699. face: number;
  96700. /**
  96701. * Creates the PassCubePostProcess
  96702. * @param name The name of the effect.
  96703. * @param options The required width/height ratio to downsize to before computing the render pass.
  96704. * @param camera The camera to apply the render pass to.
  96705. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96706. * @param engine The engine which the post process will be applied. (default: current engine)
  96707. * @param reusable If the post process can be reused on the same frame. (default: false)
  96708. * @param textureType The type of texture to be used when performing the post processing.
  96709. * @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)
  96710. */
  96711. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  96712. }
  96713. }
  96714. declare module BABYLON {
  96715. /** @hidden */
  96716. export var anaglyphPixelShader: {
  96717. name: string;
  96718. shader: string;
  96719. };
  96720. }
  96721. declare module BABYLON {
  96722. /**
  96723. * Postprocess used to generate anaglyphic rendering
  96724. */
  96725. export class AnaglyphPostProcess extends PostProcess {
  96726. private _passedProcess;
  96727. /**
  96728. * Creates a new AnaglyphPostProcess
  96729. * @param name defines postprocess name
  96730. * @param options defines creation options or target ratio scale
  96731. * @param rigCameras defines cameras using this postprocess
  96732. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  96733. * @param engine defines hosting engine
  96734. * @param reusable defines if the postprocess will be reused multiple times per frame
  96735. */
  96736. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  96737. }
  96738. }
  96739. declare module BABYLON {
  96740. /**
  96741. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  96742. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96743. */
  96744. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  96745. /**
  96746. * Creates a new AnaglyphArcRotateCamera
  96747. * @param name defines camera name
  96748. * @param alpha defines alpha angle (in radians)
  96749. * @param beta defines beta angle (in radians)
  96750. * @param radius defines radius
  96751. * @param target defines camera target
  96752. * @param interaxialDistance defines distance between each color axis
  96753. * @param scene defines the hosting scene
  96754. */
  96755. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  96756. /**
  96757. * Gets camera class name
  96758. * @returns AnaglyphArcRotateCamera
  96759. */
  96760. getClassName(): string;
  96761. }
  96762. }
  96763. declare module BABYLON {
  96764. /**
  96765. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  96766. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96767. */
  96768. export class AnaglyphFreeCamera extends FreeCamera {
  96769. /**
  96770. * Creates a new AnaglyphFreeCamera
  96771. * @param name defines camera name
  96772. * @param position defines initial position
  96773. * @param interaxialDistance defines distance between each color axis
  96774. * @param scene defines the hosting scene
  96775. */
  96776. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96777. /**
  96778. * Gets camera class name
  96779. * @returns AnaglyphFreeCamera
  96780. */
  96781. getClassName(): string;
  96782. }
  96783. }
  96784. declare module BABYLON {
  96785. /**
  96786. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  96787. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96788. */
  96789. export class AnaglyphGamepadCamera extends GamepadCamera {
  96790. /**
  96791. * Creates a new AnaglyphGamepadCamera
  96792. * @param name defines camera name
  96793. * @param position defines initial position
  96794. * @param interaxialDistance defines distance between each color axis
  96795. * @param scene defines the hosting scene
  96796. */
  96797. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96798. /**
  96799. * Gets camera class name
  96800. * @returns AnaglyphGamepadCamera
  96801. */
  96802. getClassName(): string;
  96803. }
  96804. }
  96805. declare module BABYLON {
  96806. /**
  96807. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  96808. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96809. */
  96810. export class AnaglyphUniversalCamera extends UniversalCamera {
  96811. /**
  96812. * Creates a new AnaglyphUniversalCamera
  96813. * @param name defines camera name
  96814. * @param position defines initial position
  96815. * @param interaxialDistance defines distance between each color axis
  96816. * @param scene defines the hosting scene
  96817. */
  96818. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96819. /**
  96820. * Gets camera class name
  96821. * @returns AnaglyphUniversalCamera
  96822. */
  96823. getClassName(): string;
  96824. }
  96825. }
  96826. declare module BABYLON {
  96827. /** @hidden */
  96828. export var stereoscopicInterlacePixelShader: {
  96829. name: string;
  96830. shader: string;
  96831. };
  96832. }
  96833. declare module BABYLON {
  96834. /**
  96835. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  96836. */
  96837. export class StereoscopicInterlacePostProcess extends PostProcess {
  96838. private _stepSize;
  96839. private _passedProcess;
  96840. /**
  96841. * Initializes a StereoscopicInterlacePostProcess
  96842. * @param name The name of the effect.
  96843. * @param rigCameras The rig cameras to be appled to the post process
  96844. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  96845. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96846. * @param engine The engine which the post process will be applied. (default: current engine)
  96847. * @param reusable If the post process can be reused on the same frame. (default: false)
  96848. */
  96849. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  96850. }
  96851. }
  96852. declare module BABYLON {
  96853. /**
  96854. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  96855. * @see http://doc.babylonjs.com/features/cameras
  96856. */
  96857. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  96858. /**
  96859. * Creates a new StereoscopicArcRotateCamera
  96860. * @param name defines camera name
  96861. * @param alpha defines alpha angle (in radians)
  96862. * @param beta defines beta angle (in radians)
  96863. * @param radius defines radius
  96864. * @param target defines camera target
  96865. * @param interaxialDistance defines distance between each color axis
  96866. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96867. * @param scene defines the hosting scene
  96868. */
  96869. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96870. /**
  96871. * Gets camera class name
  96872. * @returns StereoscopicArcRotateCamera
  96873. */
  96874. getClassName(): string;
  96875. }
  96876. }
  96877. declare module BABYLON {
  96878. /**
  96879. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  96880. * @see http://doc.babylonjs.com/features/cameras
  96881. */
  96882. export class StereoscopicFreeCamera extends FreeCamera {
  96883. /**
  96884. * Creates a new StereoscopicFreeCamera
  96885. * @param name defines camera name
  96886. * @param position defines initial position
  96887. * @param interaxialDistance defines distance between each color axis
  96888. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96889. * @param scene defines the hosting scene
  96890. */
  96891. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96892. /**
  96893. * Gets camera class name
  96894. * @returns StereoscopicFreeCamera
  96895. */
  96896. getClassName(): string;
  96897. }
  96898. }
  96899. declare module BABYLON {
  96900. /**
  96901. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  96902. * @see http://doc.babylonjs.com/features/cameras
  96903. */
  96904. export class StereoscopicGamepadCamera extends GamepadCamera {
  96905. /**
  96906. * Creates a new StereoscopicGamepadCamera
  96907. * @param name defines camera name
  96908. * @param position defines initial position
  96909. * @param interaxialDistance defines distance between each color axis
  96910. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96911. * @param scene defines the hosting scene
  96912. */
  96913. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96914. /**
  96915. * Gets camera class name
  96916. * @returns StereoscopicGamepadCamera
  96917. */
  96918. getClassName(): string;
  96919. }
  96920. }
  96921. declare module BABYLON {
  96922. /**
  96923. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  96924. * @see http://doc.babylonjs.com/features/cameras
  96925. */
  96926. export class StereoscopicUniversalCamera extends UniversalCamera {
  96927. /**
  96928. * Creates a new StereoscopicUniversalCamera
  96929. * @param name defines camera name
  96930. * @param position defines initial position
  96931. * @param interaxialDistance defines distance between each color axis
  96932. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96933. * @param scene defines the hosting scene
  96934. */
  96935. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96936. /**
  96937. * Gets camera class name
  96938. * @returns StereoscopicUniversalCamera
  96939. */
  96940. getClassName(): string;
  96941. }
  96942. }
  96943. declare module BABYLON {
  96944. /**
  96945. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96946. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  96947. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  96948. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  96949. */
  96950. export class VirtualJoysticksCamera extends FreeCamera {
  96951. /**
  96952. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  96953. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  96954. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  96955. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  96956. * @param name Define the name of the camera in the scene
  96957. * @param position Define the start position of the camera in the scene
  96958. * @param scene Define the scene the camera belongs to
  96959. */
  96960. constructor(name: string, position: Vector3, scene: Scene);
  96961. /**
  96962. * Gets the current object class name.
  96963. * @return the class name
  96964. */
  96965. getClassName(): string;
  96966. }
  96967. }
  96968. declare module BABYLON {
  96969. /**
  96970. * This represents all the required metrics to create a VR camera.
  96971. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  96972. */
  96973. export class VRCameraMetrics {
  96974. /**
  96975. * Define the horizontal resolution off the screen.
  96976. */
  96977. hResolution: number;
  96978. /**
  96979. * Define the vertical resolution off the screen.
  96980. */
  96981. vResolution: number;
  96982. /**
  96983. * Define the horizontal screen size.
  96984. */
  96985. hScreenSize: number;
  96986. /**
  96987. * Define the vertical screen size.
  96988. */
  96989. vScreenSize: number;
  96990. /**
  96991. * Define the vertical screen center position.
  96992. */
  96993. vScreenCenter: number;
  96994. /**
  96995. * Define the distance of the eyes to the screen.
  96996. */
  96997. eyeToScreenDistance: number;
  96998. /**
  96999. * Define the distance between both lenses
  97000. */
  97001. lensSeparationDistance: number;
  97002. /**
  97003. * Define the distance between both viewer's eyes.
  97004. */
  97005. interpupillaryDistance: number;
  97006. /**
  97007. * Define the distortion factor of the VR postprocess.
  97008. * Please, touch with care.
  97009. */
  97010. distortionK: number[];
  97011. /**
  97012. * Define the chromatic aberration correction factors for the VR post process.
  97013. */
  97014. chromaAbCorrection: number[];
  97015. /**
  97016. * Define the scale factor of the post process.
  97017. * The smaller the better but the slower.
  97018. */
  97019. postProcessScaleFactor: number;
  97020. /**
  97021. * Define an offset for the lens center.
  97022. */
  97023. lensCenterOffset: number;
  97024. /**
  97025. * Define if the current vr camera should compensate the distortion of the lense or not.
  97026. */
  97027. compensateDistortion: boolean;
  97028. /**
  97029. * Defines if multiview should be enabled when rendering (Default: false)
  97030. */
  97031. multiviewEnabled: boolean;
  97032. /**
  97033. * Gets the rendering aspect ratio based on the provided resolutions.
  97034. */
  97035. readonly aspectRatio: number;
  97036. /**
  97037. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  97038. */
  97039. readonly aspectRatioFov: number;
  97040. /**
  97041. * @hidden
  97042. */
  97043. readonly leftHMatrix: Matrix;
  97044. /**
  97045. * @hidden
  97046. */
  97047. readonly rightHMatrix: Matrix;
  97048. /**
  97049. * @hidden
  97050. */
  97051. readonly leftPreViewMatrix: Matrix;
  97052. /**
  97053. * @hidden
  97054. */
  97055. readonly rightPreViewMatrix: Matrix;
  97056. /**
  97057. * Get the default VRMetrics based on the most generic setup.
  97058. * @returns the default vr metrics
  97059. */
  97060. static GetDefault(): VRCameraMetrics;
  97061. }
  97062. }
  97063. declare module BABYLON {
  97064. /** @hidden */
  97065. export var vrDistortionCorrectionPixelShader: {
  97066. name: string;
  97067. shader: string;
  97068. };
  97069. }
  97070. declare module BABYLON {
  97071. /**
  97072. * VRDistortionCorrectionPostProcess used for mobile VR
  97073. */
  97074. export class VRDistortionCorrectionPostProcess extends PostProcess {
  97075. private _isRightEye;
  97076. private _distortionFactors;
  97077. private _postProcessScaleFactor;
  97078. private _lensCenterOffset;
  97079. private _scaleIn;
  97080. private _scaleFactor;
  97081. private _lensCenter;
  97082. /**
  97083. * Initializes the VRDistortionCorrectionPostProcess
  97084. * @param name The name of the effect.
  97085. * @param camera The camera to apply the render pass to.
  97086. * @param isRightEye If this is for the right eye distortion
  97087. * @param vrMetrics All the required metrics for the VR camera
  97088. */
  97089. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  97090. }
  97091. }
  97092. declare module BABYLON {
  97093. /**
  97094. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  97095. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97096. */
  97097. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  97098. /**
  97099. * Creates a new VRDeviceOrientationArcRotateCamera
  97100. * @param name defines camera name
  97101. * @param alpha defines the camera rotation along the logitudinal axis
  97102. * @param beta defines the camera rotation along the latitudinal axis
  97103. * @param radius defines the camera distance from its target
  97104. * @param target defines the camera target
  97105. * @param scene defines the scene the camera belongs to
  97106. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97107. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97108. */
  97109. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97110. /**
  97111. * Gets camera class name
  97112. * @returns VRDeviceOrientationArcRotateCamera
  97113. */
  97114. getClassName(): string;
  97115. }
  97116. }
  97117. declare module BABYLON {
  97118. /**
  97119. * Camera used to simulate VR rendering (based on FreeCamera)
  97120. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97121. */
  97122. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  97123. /**
  97124. * Creates a new VRDeviceOrientationFreeCamera
  97125. * @param name defines camera name
  97126. * @param position defines the start position of the camera
  97127. * @param scene defines the scene the camera belongs to
  97128. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97129. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97130. */
  97131. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97132. /**
  97133. * Gets camera class name
  97134. * @returns VRDeviceOrientationFreeCamera
  97135. */
  97136. getClassName(): string;
  97137. }
  97138. }
  97139. declare module BABYLON {
  97140. /**
  97141. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  97142. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97143. */
  97144. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  97145. /**
  97146. * Creates a new VRDeviceOrientationGamepadCamera
  97147. * @param name defines camera name
  97148. * @param position defines the start position of the camera
  97149. * @param scene defines the scene the camera belongs to
  97150. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97151. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97152. */
  97153. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97154. /**
  97155. * Gets camera class name
  97156. * @returns VRDeviceOrientationGamepadCamera
  97157. */
  97158. getClassName(): string;
  97159. }
  97160. }
  97161. declare module BABYLON {
  97162. /**
  97163. * Defines supported buttons for XBox360 compatible gamepads
  97164. */
  97165. export enum Xbox360Button {
  97166. /** A */
  97167. A = 0,
  97168. /** B */
  97169. B = 1,
  97170. /** X */
  97171. X = 2,
  97172. /** Y */
  97173. Y = 3,
  97174. /** Start */
  97175. Start = 4,
  97176. /** Back */
  97177. Back = 5,
  97178. /** Left button */
  97179. LB = 6,
  97180. /** Right button */
  97181. RB = 7,
  97182. /** Left stick */
  97183. LeftStick = 8,
  97184. /** Right stick */
  97185. RightStick = 9
  97186. }
  97187. /** Defines values for XBox360 DPad */
  97188. export enum Xbox360Dpad {
  97189. /** Up */
  97190. Up = 0,
  97191. /** Down */
  97192. Down = 1,
  97193. /** Left */
  97194. Left = 2,
  97195. /** Right */
  97196. Right = 3
  97197. }
  97198. /**
  97199. * Defines a XBox360 gamepad
  97200. */
  97201. export class Xbox360Pad extends Gamepad {
  97202. private _leftTrigger;
  97203. private _rightTrigger;
  97204. private _onlefttriggerchanged;
  97205. private _onrighttriggerchanged;
  97206. private _onbuttondown;
  97207. private _onbuttonup;
  97208. private _ondpaddown;
  97209. private _ondpadup;
  97210. /** Observable raised when a button is pressed */
  97211. onButtonDownObservable: Observable<Xbox360Button>;
  97212. /** Observable raised when a button is released */
  97213. onButtonUpObservable: Observable<Xbox360Button>;
  97214. /** Observable raised when a pad is pressed */
  97215. onPadDownObservable: Observable<Xbox360Dpad>;
  97216. /** Observable raised when a pad is released */
  97217. onPadUpObservable: Observable<Xbox360Dpad>;
  97218. private _buttonA;
  97219. private _buttonB;
  97220. private _buttonX;
  97221. private _buttonY;
  97222. private _buttonBack;
  97223. private _buttonStart;
  97224. private _buttonLB;
  97225. private _buttonRB;
  97226. private _buttonLeftStick;
  97227. private _buttonRightStick;
  97228. private _dPadUp;
  97229. private _dPadDown;
  97230. private _dPadLeft;
  97231. private _dPadRight;
  97232. private _isXboxOnePad;
  97233. /**
  97234. * Creates a new XBox360 gamepad object
  97235. * @param id defines the id of this gamepad
  97236. * @param index defines its index
  97237. * @param gamepad defines the internal HTML gamepad object
  97238. * @param xboxOne defines if it is a XBox One gamepad
  97239. */
  97240. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  97241. /**
  97242. * Defines the callback to call when left trigger is pressed
  97243. * @param callback defines the callback to use
  97244. */
  97245. onlefttriggerchanged(callback: (value: number) => void): void;
  97246. /**
  97247. * Defines the callback to call when right trigger is pressed
  97248. * @param callback defines the callback to use
  97249. */
  97250. onrighttriggerchanged(callback: (value: number) => void): void;
  97251. /**
  97252. * Gets the left trigger value
  97253. */
  97254. /**
  97255. * Sets the left trigger value
  97256. */
  97257. leftTrigger: number;
  97258. /**
  97259. * Gets the right trigger value
  97260. */
  97261. /**
  97262. * Sets the right trigger value
  97263. */
  97264. rightTrigger: number;
  97265. /**
  97266. * Defines the callback to call when a button is pressed
  97267. * @param callback defines the callback to use
  97268. */
  97269. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  97270. /**
  97271. * Defines the callback to call when a button is released
  97272. * @param callback defines the callback to use
  97273. */
  97274. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  97275. /**
  97276. * Defines the callback to call when a pad is pressed
  97277. * @param callback defines the callback to use
  97278. */
  97279. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  97280. /**
  97281. * Defines the callback to call when a pad is released
  97282. * @param callback defines the callback to use
  97283. */
  97284. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  97285. private _setButtonValue;
  97286. private _setDPadValue;
  97287. /**
  97288. * Gets the value of the `A` button
  97289. */
  97290. /**
  97291. * Sets the value of the `A` button
  97292. */
  97293. buttonA: number;
  97294. /**
  97295. * Gets the value of the `B` button
  97296. */
  97297. /**
  97298. * Sets the value of the `B` button
  97299. */
  97300. buttonB: number;
  97301. /**
  97302. * Gets the value of the `X` button
  97303. */
  97304. /**
  97305. * Sets the value of the `X` button
  97306. */
  97307. buttonX: number;
  97308. /**
  97309. * Gets the value of the `Y` button
  97310. */
  97311. /**
  97312. * Sets the value of the `Y` button
  97313. */
  97314. buttonY: number;
  97315. /**
  97316. * Gets the value of the `Start` button
  97317. */
  97318. /**
  97319. * Sets the value of the `Start` button
  97320. */
  97321. buttonStart: number;
  97322. /**
  97323. * Gets the value of the `Back` button
  97324. */
  97325. /**
  97326. * Sets the value of the `Back` button
  97327. */
  97328. buttonBack: number;
  97329. /**
  97330. * Gets the value of the `Left` button
  97331. */
  97332. /**
  97333. * Sets the value of the `Left` button
  97334. */
  97335. buttonLB: number;
  97336. /**
  97337. * Gets the value of the `Right` button
  97338. */
  97339. /**
  97340. * Sets the value of the `Right` button
  97341. */
  97342. buttonRB: number;
  97343. /**
  97344. * Gets the value of the Left joystick
  97345. */
  97346. /**
  97347. * Sets the value of the Left joystick
  97348. */
  97349. buttonLeftStick: number;
  97350. /**
  97351. * Gets the value of the Right joystick
  97352. */
  97353. /**
  97354. * Sets the value of the Right joystick
  97355. */
  97356. buttonRightStick: number;
  97357. /**
  97358. * Gets the value of D-pad up
  97359. */
  97360. /**
  97361. * Sets the value of D-pad up
  97362. */
  97363. dPadUp: number;
  97364. /**
  97365. * Gets the value of D-pad down
  97366. */
  97367. /**
  97368. * Sets the value of D-pad down
  97369. */
  97370. dPadDown: number;
  97371. /**
  97372. * Gets the value of D-pad left
  97373. */
  97374. /**
  97375. * Sets the value of D-pad left
  97376. */
  97377. dPadLeft: number;
  97378. /**
  97379. * Gets the value of D-pad right
  97380. */
  97381. /**
  97382. * Sets the value of D-pad right
  97383. */
  97384. dPadRight: number;
  97385. /**
  97386. * Force the gamepad to synchronize with device values
  97387. */
  97388. update(): void;
  97389. /**
  97390. * Disposes the gamepad
  97391. */
  97392. dispose(): void;
  97393. }
  97394. }
  97395. declare module BABYLON {
  97396. /**
  97397. * Base class of materials working in push mode in babylon JS
  97398. * @hidden
  97399. */
  97400. export class PushMaterial extends Material {
  97401. protected _activeEffect: Effect;
  97402. protected _normalMatrix: Matrix;
  97403. /**
  97404. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  97405. * This means that the material can keep using a previous shader while a new one is being compiled.
  97406. * This is mostly used when shader parallel compilation is supported (true by default)
  97407. */
  97408. allowShaderHotSwapping: boolean;
  97409. constructor(name: string, scene: Scene);
  97410. getEffect(): Effect;
  97411. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97412. /**
  97413. * Binds the given world matrix to the active effect
  97414. *
  97415. * @param world the matrix to bind
  97416. */
  97417. bindOnlyWorldMatrix(world: Matrix): void;
  97418. /**
  97419. * Binds the given normal matrix to the active effect
  97420. *
  97421. * @param normalMatrix the matrix to bind
  97422. */
  97423. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  97424. bind(world: Matrix, mesh?: Mesh): void;
  97425. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  97426. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  97427. }
  97428. }
  97429. declare module BABYLON {
  97430. /**
  97431. * This groups all the flags used to control the materials channel.
  97432. */
  97433. export class MaterialFlags {
  97434. private static _DiffuseTextureEnabled;
  97435. /**
  97436. * Are diffuse textures enabled in the application.
  97437. */
  97438. static DiffuseTextureEnabled: boolean;
  97439. private static _AmbientTextureEnabled;
  97440. /**
  97441. * Are ambient textures enabled in the application.
  97442. */
  97443. static AmbientTextureEnabled: boolean;
  97444. private static _OpacityTextureEnabled;
  97445. /**
  97446. * Are opacity textures enabled in the application.
  97447. */
  97448. static OpacityTextureEnabled: boolean;
  97449. private static _ReflectionTextureEnabled;
  97450. /**
  97451. * Are reflection textures enabled in the application.
  97452. */
  97453. static ReflectionTextureEnabled: boolean;
  97454. private static _EmissiveTextureEnabled;
  97455. /**
  97456. * Are emissive textures enabled in the application.
  97457. */
  97458. static EmissiveTextureEnabled: boolean;
  97459. private static _SpecularTextureEnabled;
  97460. /**
  97461. * Are specular textures enabled in the application.
  97462. */
  97463. static SpecularTextureEnabled: boolean;
  97464. private static _BumpTextureEnabled;
  97465. /**
  97466. * Are bump textures enabled in the application.
  97467. */
  97468. static BumpTextureEnabled: boolean;
  97469. private static _LightmapTextureEnabled;
  97470. /**
  97471. * Are lightmap textures enabled in the application.
  97472. */
  97473. static LightmapTextureEnabled: boolean;
  97474. private static _RefractionTextureEnabled;
  97475. /**
  97476. * Are refraction textures enabled in the application.
  97477. */
  97478. static RefractionTextureEnabled: boolean;
  97479. private static _ColorGradingTextureEnabled;
  97480. /**
  97481. * Are color grading textures enabled in the application.
  97482. */
  97483. static ColorGradingTextureEnabled: boolean;
  97484. private static _FresnelEnabled;
  97485. /**
  97486. * Are fresnels enabled in the application.
  97487. */
  97488. static FresnelEnabled: boolean;
  97489. private static _ClearCoatTextureEnabled;
  97490. /**
  97491. * Are clear coat textures enabled in the application.
  97492. */
  97493. static ClearCoatTextureEnabled: boolean;
  97494. private static _ClearCoatBumpTextureEnabled;
  97495. /**
  97496. * Are clear coat bump textures enabled in the application.
  97497. */
  97498. static ClearCoatBumpTextureEnabled: boolean;
  97499. private static _ClearCoatTintTextureEnabled;
  97500. /**
  97501. * Are clear coat tint textures enabled in the application.
  97502. */
  97503. static ClearCoatTintTextureEnabled: boolean;
  97504. private static _SheenTextureEnabled;
  97505. /**
  97506. * Are sheen textures enabled in the application.
  97507. */
  97508. static SheenTextureEnabled: boolean;
  97509. private static _AnisotropicTextureEnabled;
  97510. /**
  97511. * Are anisotropic textures enabled in the application.
  97512. */
  97513. static AnisotropicTextureEnabled: boolean;
  97514. private static _ThicknessTextureEnabled;
  97515. /**
  97516. * Are thickness textures enabled in the application.
  97517. */
  97518. static ThicknessTextureEnabled: boolean;
  97519. }
  97520. }
  97521. declare module BABYLON {
  97522. /** @hidden */
  97523. export var defaultFragmentDeclaration: {
  97524. name: string;
  97525. shader: string;
  97526. };
  97527. }
  97528. declare module BABYLON {
  97529. /** @hidden */
  97530. export var defaultUboDeclaration: {
  97531. name: string;
  97532. shader: string;
  97533. };
  97534. }
  97535. declare module BABYLON {
  97536. /** @hidden */
  97537. export var lightFragmentDeclaration: {
  97538. name: string;
  97539. shader: string;
  97540. };
  97541. }
  97542. declare module BABYLON {
  97543. /** @hidden */
  97544. export var lightUboDeclaration: {
  97545. name: string;
  97546. shader: string;
  97547. };
  97548. }
  97549. declare module BABYLON {
  97550. /** @hidden */
  97551. export var lightsFragmentFunctions: {
  97552. name: string;
  97553. shader: string;
  97554. };
  97555. }
  97556. declare module BABYLON {
  97557. /** @hidden */
  97558. export var shadowsFragmentFunctions: {
  97559. name: string;
  97560. shader: string;
  97561. };
  97562. }
  97563. declare module BABYLON {
  97564. /** @hidden */
  97565. export var fresnelFunction: {
  97566. name: string;
  97567. shader: string;
  97568. };
  97569. }
  97570. declare module BABYLON {
  97571. /** @hidden */
  97572. export var reflectionFunction: {
  97573. name: string;
  97574. shader: string;
  97575. };
  97576. }
  97577. declare module BABYLON {
  97578. /** @hidden */
  97579. export var bumpFragmentFunctions: {
  97580. name: string;
  97581. shader: string;
  97582. };
  97583. }
  97584. declare module BABYLON {
  97585. /** @hidden */
  97586. export var logDepthDeclaration: {
  97587. name: string;
  97588. shader: string;
  97589. };
  97590. }
  97591. declare module BABYLON {
  97592. /** @hidden */
  97593. export var bumpFragment: {
  97594. name: string;
  97595. shader: string;
  97596. };
  97597. }
  97598. declare module BABYLON {
  97599. /** @hidden */
  97600. export var depthPrePass: {
  97601. name: string;
  97602. shader: string;
  97603. };
  97604. }
  97605. declare module BABYLON {
  97606. /** @hidden */
  97607. export var lightFragment: {
  97608. name: string;
  97609. shader: string;
  97610. };
  97611. }
  97612. declare module BABYLON {
  97613. /** @hidden */
  97614. export var logDepthFragment: {
  97615. name: string;
  97616. shader: string;
  97617. };
  97618. }
  97619. declare module BABYLON {
  97620. /** @hidden */
  97621. export var defaultPixelShader: {
  97622. name: string;
  97623. shader: string;
  97624. };
  97625. }
  97626. declare module BABYLON {
  97627. /** @hidden */
  97628. export var defaultVertexDeclaration: {
  97629. name: string;
  97630. shader: string;
  97631. };
  97632. }
  97633. declare module BABYLON {
  97634. /** @hidden */
  97635. export var bumpVertexDeclaration: {
  97636. name: string;
  97637. shader: string;
  97638. };
  97639. }
  97640. declare module BABYLON {
  97641. /** @hidden */
  97642. export var bumpVertex: {
  97643. name: string;
  97644. shader: string;
  97645. };
  97646. }
  97647. declare module BABYLON {
  97648. /** @hidden */
  97649. export var fogVertex: {
  97650. name: string;
  97651. shader: string;
  97652. };
  97653. }
  97654. declare module BABYLON {
  97655. /** @hidden */
  97656. export var shadowsVertex: {
  97657. name: string;
  97658. shader: string;
  97659. };
  97660. }
  97661. declare module BABYLON {
  97662. /** @hidden */
  97663. export var pointCloudVertex: {
  97664. name: string;
  97665. shader: string;
  97666. };
  97667. }
  97668. declare module BABYLON {
  97669. /** @hidden */
  97670. export var logDepthVertex: {
  97671. name: string;
  97672. shader: string;
  97673. };
  97674. }
  97675. declare module BABYLON {
  97676. /** @hidden */
  97677. export var defaultVertexShader: {
  97678. name: string;
  97679. shader: string;
  97680. };
  97681. }
  97682. declare module BABYLON {
  97683. /** @hidden */
  97684. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  97685. MAINUV1: boolean;
  97686. MAINUV2: boolean;
  97687. DIFFUSE: boolean;
  97688. DIFFUSEDIRECTUV: number;
  97689. AMBIENT: boolean;
  97690. AMBIENTDIRECTUV: number;
  97691. OPACITY: boolean;
  97692. OPACITYDIRECTUV: number;
  97693. OPACITYRGB: boolean;
  97694. REFLECTION: boolean;
  97695. EMISSIVE: boolean;
  97696. EMISSIVEDIRECTUV: number;
  97697. SPECULAR: boolean;
  97698. SPECULARDIRECTUV: number;
  97699. BUMP: boolean;
  97700. BUMPDIRECTUV: number;
  97701. PARALLAX: boolean;
  97702. PARALLAXOCCLUSION: boolean;
  97703. SPECULAROVERALPHA: boolean;
  97704. CLIPPLANE: boolean;
  97705. CLIPPLANE2: boolean;
  97706. CLIPPLANE3: boolean;
  97707. CLIPPLANE4: boolean;
  97708. ALPHATEST: boolean;
  97709. DEPTHPREPASS: boolean;
  97710. ALPHAFROMDIFFUSE: boolean;
  97711. POINTSIZE: boolean;
  97712. FOG: boolean;
  97713. SPECULARTERM: boolean;
  97714. DIFFUSEFRESNEL: boolean;
  97715. OPACITYFRESNEL: boolean;
  97716. REFLECTIONFRESNEL: boolean;
  97717. REFRACTIONFRESNEL: boolean;
  97718. EMISSIVEFRESNEL: boolean;
  97719. FRESNEL: boolean;
  97720. NORMAL: boolean;
  97721. UV1: boolean;
  97722. UV2: boolean;
  97723. VERTEXCOLOR: boolean;
  97724. VERTEXALPHA: boolean;
  97725. NUM_BONE_INFLUENCERS: number;
  97726. BonesPerMesh: number;
  97727. BONETEXTURE: boolean;
  97728. INSTANCES: boolean;
  97729. GLOSSINESS: boolean;
  97730. ROUGHNESS: boolean;
  97731. EMISSIVEASILLUMINATION: boolean;
  97732. LINKEMISSIVEWITHDIFFUSE: boolean;
  97733. REFLECTIONFRESNELFROMSPECULAR: boolean;
  97734. LIGHTMAP: boolean;
  97735. LIGHTMAPDIRECTUV: number;
  97736. OBJECTSPACE_NORMALMAP: boolean;
  97737. USELIGHTMAPASSHADOWMAP: boolean;
  97738. REFLECTIONMAP_3D: boolean;
  97739. REFLECTIONMAP_SPHERICAL: boolean;
  97740. REFLECTIONMAP_PLANAR: boolean;
  97741. REFLECTIONMAP_CUBIC: boolean;
  97742. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  97743. REFLECTIONMAP_PROJECTION: boolean;
  97744. REFLECTIONMAP_SKYBOX: boolean;
  97745. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  97746. REFLECTIONMAP_EXPLICIT: boolean;
  97747. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  97748. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  97749. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  97750. INVERTCUBICMAP: boolean;
  97751. LOGARITHMICDEPTH: boolean;
  97752. REFRACTION: boolean;
  97753. REFRACTIONMAP_3D: boolean;
  97754. REFLECTIONOVERALPHA: boolean;
  97755. TWOSIDEDLIGHTING: boolean;
  97756. SHADOWFLOAT: boolean;
  97757. MORPHTARGETS: boolean;
  97758. MORPHTARGETS_NORMAL: boolean;
  97759. MORPHTARGETS_TANGENT: boolean;
  97760. NUM_MORPH_INFLUENCERS: number;
  97761. NONUNIFORMSCALING: boolean;
  97762. PREMULTIPLYALPHA: boolean;
  97763. IMAGEPROCESSING: boolean;
  97764. VIGNETTE: boolean;
  97765. VIGNETTEBLENDMODEMULTIPLY: boolean;
  97766. VIGNETTEBLENDMODEOPAQUE: boolean;
  97767. TONEMAPPING: boolean;
  97768. TONEMAPPING_ACES: boolean;
  97769. CONTRAST: boolean;
  97770. COLORCURVES: boolean;
  97771. COLORGRADING: boolean;
  97772. COLORGRADING3D: boolean;
  97773. SAMPLER3DGREENDEPTH: boolean;
  97774. SAMPLER3DBGRMAP: boolean;
  97775. IMAGEPROCESSINGPOSTPROCESS: boolean;
  97776. MULTIVIEW: boolean;
  97777. /**
  97778. * If the reflection texture on this material is in linear color space
  97779. * @hidden
  97780. */
  97781. IS_REFLECTION_LINEAR: boolean;
  97782. /**
  97783. * If the refraction texture on this material is in linear color space
  97784. * @hidden
  97785. */
  97786. IS_REFRACTION_LINEAR: boolean;
  97787. EXPOSURE: boolean;
  97788. constructor();
  97789. setReflectionMode(modeToEnable: string): void;
  97790. }
  97791. /**
  97792. * This is the default material used in Babylon. It is the best trade off between quality
  97793. * and performances.
  97794. * @see http://doc.babylonjs.com/babylon101/materials
  97795. */
  97796. export class StandardMaterial extends PushMaterial {
  97797. private _diffuseTexture;
  97798. /**
  97799. * The basic texture of the material as viewed under a light.
  97800. */
  97801. diffuseTexture: Nullable<BaseTexture>;
  97802. private _ambientTexture;
  97803. /**
  97804. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  97805. */
  97806. ambientTexture: Nullable<BaseTexture>;
  97807. private _opacityTexture;
  97808. /**
  97809. * Define the transparency of the material from a texture.
  97810. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  97811. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  97812. */
  97813. opacityTexture: Nullable<BaseTexture>;
  97814. private _reflectionTexture;
  97815. /**
  97816. * Define the texture used to display the reflection.
  97817. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97818. */
  97819. reflectionTexture: Nullable<BaseTexture>;
  97820. private _emissiveTexture;
  97821. /**
  97822. * Define texture of the material as if self lit.
  97823. * This will be mixed in the final result even in the absence of light.
  97824. */
  97825. emissiveTexture: Nullable<BaseTexture>;
  97826. private _specularTexture;
  97827. /**
  97828. * Define how the color and intensity of the highlight given by the light in the material.
  97829. */
  97830. specularTexture: Nullable<BaseTexture>;
  97831. private _bumpTexture;
  97832. /**
  97833. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  97834. * 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.
  97835. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  97836. */
  97837. bumpTexture: Nullable<BaseTexture>;
  97838. private _lightmapTexture;
  97839. /**
  97840. * Complex lighting can be computationally expensive to compute at runtime.
  97841. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  97842. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  97843. */
  97844. lightmapTexture: Nullable<BaseTexture>;
  97845. private _refractionTexture;
  97846. /**
  97847. * Define the texture used to display the refraction.
  97848. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97849. */
  97850. refractionTexture: Nullable<BaseTexture>;
  97851. /**
  97852. * The color of the material lit by the environmental background lighting.
  97853. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  97854. */
  97855. ambientColor: Color3;
  97856. /**
  97857. * The basic color of the material as viewed under a light.
  97858. */
  97859. diffuseColor: Color3;
  97860. /**
  97861. * Define how the color and intensity of the highlight given by the light in the material.
  97862. */
  97863. specularColor: Color3;
  97864. /**
  97865. * Define the color of the material as if self lit.
  97866. * This will be mixed in the final result even in the absence of light.
  97867. */
  97868. emissiveColor: Color3;
  97869. /**
  97870. * Defines how sharp are the highlights in the material.
  97871. * The bigger the value the sharper giving a more glossy feeling to the result.
  97872. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  97873. */
  97874. specularPower: number;
  97875. private _useAlphaFromDiffuseTexture;
  97876. /**
  97877. * Does the transparency come from the diffuse texture alpha channel.
  97878. */
  97879. useAlphaFromDiffuseTexture: boolean;
  97880. private _useEmissiveAsIllumination;
  97881. /**
  97882. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  97883. */
  97884. useEmissiveAsIllumination: boolean;
  97885. private _linkEmissiveWithDiffuse;
  97886. /**
  97887. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  97888. * the emissive level when the final color is close to one.
  97889. */
  97890. linkEmissiveWithDiffuse: boolean;
  97891. private _useSpecularOverAlpha;
  97892. /**
  97893. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  97894. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  97895. */
  97896. useSpecularOverAlpha: boolean;
  97897. private _useReflectionOverAlpha;
  97898. /**
  97899. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  97900. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  97901. */
  97902. useReflectionOverAlpha: boolean;
  97903. private _disableLighting;
  97904. /**
  97905. * Does lights from the scene impacts this material.
  97906. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  97907. */
  97908. disableLighting: boolean;
  97909. private _useObjectSpaceNormalMap;
  97910. /**
  97911. * Allows using an object space normal map (instead of tangent space).
  97912. */
  97913. useObjectSpaceNormalMap: boolean;
  97914. private _useParallax;
  97915. /**
  97916. * Is parallax enabled or not.
  97917. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97918. */
  97919. useParallax: boolean;
  97920. private _useParallaxOcclusion;
  97921. /**
  97922. * Is parallax occlusion enabled or not.
  97923. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  97924. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97925. */
  97926. useParallaxOcclusion: boolean;
  97927. /**
  97928. * 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.
  97929. */
  97930. parallaxScaleBias: number;
  97931. private _roughness;
  97932. /**
  97933. * Helps to define how blurry the reflections should appears in the material.
  97934. */
  97935. roughness: number;
  97936. /**
  97937. * In case of refraction, define the value of the indice of refraction.
  97938. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97939. */
  97940. indexOfRefraction: number;
  97941. /**
  97942. * Invert the refraction texture alongside the y axis.
  97943. * It can be useful with procedural textures or probe for instance.
  97944. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97945. */
  97946. invertRefractionY: boolean;
  97947. /**
  97948. * Defines the alpha limits in alpha test mode.
  97949. */
  97950. alphaCutOff: number;
  97951. private _useLightmapAsShadowmap;
  97952. /**
  97953. * In case of light mapping, define whether the map contains light or shadow informations.
  97954. */
  97955. useLightmapAsShadowmap: boolean;
  97956. private _diffuseFresnelParameters;
  97957. /**
  97958. * Define the diffuse fresnel parameters of the material.
  97959. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97960. */
  97961. diffuseFresnelParameters: FresnelParameters;
  97962. private _opacityFresnelParameters;
  97963. /**
  97964. * Define the opacity fresnel parameters of the material.
  97965. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97966. */
  97967. opacityFresnelParameters: FresnelParameters;
  97968. private _reflectionFresnelParameters;
  97969. /**
  97970. * Define the reflection fresnel parameters of the material.
  97971. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97972. */
  97973. reflectionFresnelParameters: FresnelParameters;
  97974. private _refractionFresnelParameters;
  97975. /**
  97976. * Define the refraction fresnel parameters of the material.
  97977. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97978. */
  97979. refractionFresnelParameters: FresnelParameters;
  97980. private _emissiveFresnelParameters;
  97981. /**
  97982. * Define the emissive fresnel parameters of the material.
  97983. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97984. */
  97985. emissiveFresnelParameters: FresnelParameters;
  97986. private _useReflectionFresnelFromSpecular;
  97987. /**
  97988. * If true automatically deducts the fresnels values from the material specularity.
  97989. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97990. */
  97991. useReflectionFresnelFromSpecular: boolean;
  97992. private _useGlossinessFromSpecularMapAlpha;
  97993. /**
  97994. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  97995. */
  97996. useGlossinessFromSpecularMapAlpha: boolean;
  97997. private _maxSimultaneousLights;
  97998. /**
  97999. * Defines the maximum number of lights that can be used in the material
  98000. */
  98001. maxSimultaneousLights: number;
  98002. private _invertNormalMapX;
  98003. /**
  98004. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  98005. */
  98006. invertNormalMapX: boolean;
  98007. private _invertNormalMapY;
  98008. /**
  98009. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  98010. */
  98011. invertNormalMapY: boolean;
  98012. private _twoSidedLighting;
  98013. /**
  98014. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  98015. */
  98016. twoSidedLighting: boolean;
  98017. /**
  98018. * Default configuration related to image processing available in the standard Material.
  98019. */
  98020. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98021. /**
  98022. * Gets the image processing configuration used either in this material.
  98023. */
  98024. /**
  98025. * Sets the Default image processing configuration used either in the this material.
  98026. *
  98027. * If sets to null, the scene one is in use.
  98028. */
  98029. imageProcessingConfiguration: ImageProcessingConfiguration;
  98030. /**
  98031. * Keep track of the image processing observer to allow dispose and replace.
  98032. */
  98033. private _imageProcessingObserver;
  98034. /**
  98035. * Attaches a new image processing configuration to the Standard Material.
  98036. * @param configuration
  98037. */
  98038. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98039. /**
  98040. * Gets wether the color curves effect is enabled.
  98041. */
  98042. /**
  98043. * Sets wether the color curves effect is enabled.
  98044. */
  98045. cameraColorCurvesEnabled: boolean;
  98046. /**
  98047. * Gets wether the color grading effect is enabled.
  98048. */
  98049. /**
  98050. * Gets wether the color grading effect is enabled.
  98051. */
  98052. cameraColorGradingEnabled: boolean;
  98053. /**
  98054. * Gets wether tonemapping is enabled or not.
  98055. */
  98056. /**
  98057. * Sets wether tonemapping is enabled or not
  98058. */
  98059. cameraToneMappingEnabled: boolean;
  98060. /**
  98061. * The camera exposure used on this material.
  98062. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98063. * This corresponds to a photographic exposure.
  98064. */
  98065. /**
  98066. * The camera exposure used on this material.
  98067. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98068. * This corresponds to a photographic exposure.
  98069. */
  98070. cameraExposure: number;
  98071. /**
  98072. * Gets The camera contrast used on this material.
  98073. */
  98074. /**
  98075. * Sets The camera contrast used on this material.
  98076. */
  98077. cameraContrast: number;
  98078. /**
  98079. * Gets the Color Grading 2D Lookup Texture.
  98080. */
  98081. /**
  98082. * Sets the Color Grading 2D Lookup Texture.
  98083. */
  98084. cameraColorGradingTexture: Nullable<BaseTexture>;
  98085. /**
  98086. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98087. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98088. * 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;
  98089. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98090. */
  98091. /**
  98092. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98093. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98094. * 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;
  98095. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98096. */
  98097. cameraColorCurves: Nullable<ColorCurves>;
  98098. /**
  98099. * Custom callback helping to override the default shader used in the material.
  98100. */
  98101. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  98102. protected _renderTargets: SmartArray<RenderTargetTexture>;
  98103. protected _worldViewProjectionMatrix: Matrix;
  98104. protected _globalAmbientColor: Color3;
  98105. protected _useLogarithmicDepth: boolean;
  98106. /**
  98107. * Instantiates a new standard material.
  98108. * This is the default material used in Babylon. It is the best trade off between quality
  98109. * and performances.
  98110. * @see http://doc.babylonjs.com/babylon101/materials
  98111. * @param name Define the name of the material in the scene
  98112. * @param scene Define the scene the material belong to
  98113. */
  98114. constructor(name: string, scene: Scene);
  98115. /**
  98116. * Gets a boolean indicating that current material needs to register RTT
  98117. */
  98118. readonly hasRenderTargetTextures: boolean;
  98119. /**
  98120. * Gets the current class name of the material e.g. "StandardMaterial"
  98121. * Mainly use in serialization.
  98122. * @returns the class name
  98123. */
  98124. getClassName(): string;
  98125. /**
  98126. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  98127. * You can try switching to logarithmic depth.
  98128. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  98129. */
  98130. useLogarithmicDepth: boolean;
  98131. /**
  98132. * Specifies if the material will require alpha blending
  98133. * @returns a boolean specifying if alpha blending is needed
  98134. */
  98135. needAlphaBlending(): boolean;
  98136. /**
  98137. * Specifies if this material should be rendered in alpha test mode
  98138. * @returns a boolean specifying if an alpha test is needed.
  98139. */
  98140. needAlphaTesting(): boolean;
  98141. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  98142. /**
  98143. * Get the texture used for alpha test purpose.
  98144. * @returns the diffuse texture in case of the standard material.
  98145. */
  98146. getAlphaTestTexture(): Nullable<BaseTexture>;
  98147. /**
  98148. * Get if the submesh is ready to be used and all its information available.
  98149. * Child classes can use it to update shaders
  98150. * @param mesh defines the mesh to check
  98151. * @param subMesh defines which submesh to check
  98152. * @param useInstances specifies that instances should be used
  98153. * @returns a boolean indicating that the submesh is ready or not
  98154. */
  98155. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98156. /**
  98157. * Builds the material UBO layouts.
  98158. * Used internally during the effect preparation.
  98159. */
  98160. buildUniformLayout(): void;
  98161. /**
  98162. * Unbinds the material from the mesh
  98163. */
  98164. unbind(): void;
  98165. /**
  98166. * Binds the submesh to this material by preparing the effect and shader to draw
  98167. * @param world defines the world transformation matrix
  98168. * @param mesh defines the mesh containing the submesh
  98169. * @param subMesh defines the submesh to bind the material to
  98170. */
  98171. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98172. /**
  98173. * Get the list of animatables in the material.
  98174. * @returns the list of animatables object used in the material
  98175. */
  98176. getAnimatables(): IAnimatable[];
  98177. /**
  98178. * Gets the active textures from the material
  98179. * @returns an array of textures
  98180. */
  98181. getActiveTextures(): BaseTexture[];
  98182. /**
  98183. * Specifies if the material uses a texture
  98184. * @param texture defines the texture to check against the material
  98185. * @returns a boolean specifying if the material uses the texture
  98186. */
  98187. hasTexture(texture: BaseTexture): boolean;
  98188. /**
  98189. * Disposes the material
  98190. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  98191. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  98192. */
  98193. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98194. /**
  98195. * Makes a duplicate of the material, and gives it a new name
  98196. * @param name defines the new name for the duplicated material
  98197. * @returns the cloned material
  98198. */
  98199. clone(name: string): StandardMaterial;
  98200. /**
  98201. * Serializes this material in a JSON representation
  98202. * @returns the serialized material object
  98203. */
  98204. serialize(): any;
  98205. /**
  98206. * Creates a standard material from parsed material data
  98207. * @param source defines the JSON representation of the material
  98208. * @param scene defines the hosting scene
  98209. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98210. * @returns a new standard material
  98211. */
  98212. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  98213. /**
  98214. * Are diffuse textures enabled in the application.
  98215. */
  98216. static DiffuseTextureEnabled: boolean;
  98217. /**
  98218. * Are ambient textures enabled in the application.
  98219. */
  98220. static AmbientTextureEnabled: boolean;
  98221. /**
  98222. * Are opacity textures enabled in the application.
  98223. */
  98224. static OpacityTextureEnabled: boolean;
  98225. /**
  98226. * Are reflection textures enabled in the application.
  98227. */
  98228. static ReflectionTextureEnabled: boolean;
  98229. /**
  98230. * Are emissive textures enabled in the application.
  98231. */
  98232. static EmissiveTextureEnabled: boolean;
  98233. /**
  98234. * Are specular textures enabled in the application.
  98235. */
  98236. static SpecularTextureEnabled: boolean;
  98237. /**
  98238. * Are bump textures enabled in the application.
  98239. */
  98240. static BumpTextureEnabled: boolean;
  98241. /**
  98242. * Are lightmap textures enabled in the application.
  98243. */
  98244. static LightmapTextureEnabled: boolean;
  98245. /**
  98246. * Are refraction textures enabled in the application.
  98247. */
  98248. static RefractionTextureEnabled: boolean;
  98249. /**
  98250. * Are color grading textures enabled in the application.
  98251. */
  98252. static ColorGradingTextureEnabled: boolean;
  98253. /**
  98254. * Are fresnels enabled in the application.
  98255. */
  98256. static FresnelEnabled: boolean;
  98257. }
  98258. }
  98259. declare module BABYLON {
  98260. /**
  98261. * A class extending Texture allowing drawing on a texture
  98262. * @see http://doc.babylonjs.com/how_to/dynamictexture
  98263. */
  98264. export class DynamicTexture extends Texture {
  98265. private _generateMipMaps;
  98266. private _canvas;
  98267. private _context;
  98268. private _engine;
  98269. /**
  98270. * Creates a DynamicTexture
  98271. * @param name defines the name of the texture
  98272. * @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
  98273. * @param scene defines the scene where you want the texture
  98274. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  98275. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  98276. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  98277. */
  98278. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  98279. /**
  98280. * Get the current class name of the texture useful for serialization or dynamic coding.
  98281. * @returns "DynamicTexture"
  98282. */
  98283. getClassName(): string;
  98284. /**
  98285. * Gets the current state of canRescale
  98286. */
  98287. readonly canRescale: boolean;
  98288. private _recreate;
  98289. /**
  98290. * Scales the texture
  98291. * @param ratio the scale factor to apply to both width and height
  98292. */
  98293. scale(ratio: number): void;
  98294. /**
  98295. * Resizes the texture
  98296. * @param width the new width
  98297. * @param height the new height
  98298. */
  98299. scaleTo(width: number, height: number): void;
  98300. /**
  98301. * Gets the context of the canvas used by the texture
  98302. * @returns the canvas context of the dynamic texture
  98303. */
  98304. getContext(): CanvasRenderingContext2D;
  98305. /**
  98306. * Clears the texture
  98307. */
  98308. clear(): void;
  98309. /**
  98310. * Updates the texture
  98311. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  98312. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  98313. */
  98314. update(invertY?: boolean, premulAlpha?: boolean): void;
  98315. /**
  98316. * Draws text onto the texture
  98317. * @param text defines the text to be drawn
  98318. * @param x defines the placement of the text from the left
  98319. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  98320. * @param font defines the font to be used with font-style, font-size, font-name
  98321. * @param color defines the color used for the text
  98322. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  98323. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  98324. * @param update defines whether texture is immediately update (default is true)
  98325. */
  98326. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  98327. /**
  98328. * Clones the texture
  98329. * @returns the clone of the texture.
  98330. */
  98331. clone(): DynamicTexture;
  98332. /**
  98333. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  98334. * @returns a serialized dynamic texture object
  98335. */
  98336. serialize(): any;
  98337. /** @hidden */
  98338. _rebuild(): void;
  98339. }
  98340. }
  98341. declare module BABYLON {
  98342. /** @hidden */
  98343. export var imageProcessingPixelShader: {
  98344. name: string;
  98345. shader: string;
  98346. };
  98347. }
  98348. declare module BABYLON {
  98349. /**
  98350. * ImageProcessingPostProcess
  98351. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  98352. */
  98353. export class ImageProcessingPostProcess extends PostProcess {
  98354. /**
  98355. * Default configuration related to image processing available in the PBR Material.
  98356. */
  98357. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98358. /**
  98359. * Gets the image processing configuration used either in this material.
  98360. */
  98361. /**
  98362. * Sets the Default image processing configuration used either in the this material.
  98363. *
  98364. * If sets to null, the scene one is in use.
  98365. */
  98366. imageProcessingConfiguration: ImageProcessingConfiguration;
  98367. /**
  98368. * Keep track of the image processing observer to allow dispose and replace.
  98369. */
  98370. private _imageProcessingObserver;
  98371. /**
  98372. * Attaches a new image processing configuration to the PBR Material.
  98373. * @param configuration
  98374. */
  98375. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  98376. /**
  98377. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  98378. */
  98379. /**
  98380. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  98381. */
  98382. colorCurves: Nullable<ColorCurves>;
  98383. /**
  98384. * Gets wether the color curves effect is enabled.
  98385. */
  98386. /**
  98387. * Sets wether the color curves effect is enabled.
  98388. */
  98389. colorCurvesEnabled: boolean;
  98390. /**
  98391. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  98392. */
  98393. /**
  98394. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  98395. */
  98396. colorGradingTexture: Nullable<BaseTexture>;
  98397. /**
  98398. * Gets wether the color grading effect is enabled.
  98399. */
  98400. /**
  98401. * Gets wether the color grading effect is enabled.
  98402. */
  98403. colorGradingEnabled: boolean;
  98404. /**
  98405. * Gets exposure used in the effect.
  98406. */
  98407. /**
  98408. * Sets exposure used in the effect.
  98409. */
  98410. exposure: number;
  98411. /**
  98412. * Gets wether tonemapping is enabled or not.
  98413. */
  98414. /**
  98415. * Sets wether tonemapping is enabled or not
  98416. */
  98417. toneMappingEnabled: boolean;
  98418. /**
  98419. * Gets the type of tone mapping effect.
  98420. */
  98421. /**
  98422. * Sets the type of tone mapping effect.
  98423. */
  98424. toneMappingType: number;
  98425. /**
  98426. * Gets contrast used in the effect.
  98427. */
  98428. /**
  98429. * Sets contrast used in the effect.
  98430. */
  98431. contrast: number;
  98432. /**
  98433. * Gets Vignette stretch size.
  98434. */
  98435. /**
  98436. * Sets Vignette stretch size.
  98437. */
  98438. vignetteStretch: number;
  98439. /**
  98440. * Gets Vignette centre X Offset.
  98441. */
  98442. /**
  98443. * Sets Vignette centre X Offset.
  98444. */
  98445. vignetteCentreX: number;
  98446. /**
  98447. * Gets Vignette centre Y Offset.
  98448. */
  98449. /**
  98450. * Sets Vignette centre Y Offset.
  98451. */
  98452. vignetteCentreY: number;
  98453. /**
  98454. * Gets Vignette weight or intensity of the vignette effect.
  98455. */
  98456. /**
  98457. * Sets Vignette weight or intensity of the vignette effect.
  98458. */
  98459. vignetteWeight: number;
  98460. /**
  98461. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  98462. * if vignetteEnabled is set to true.
  98463. */
  98464. /**
  98465. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  98466. * if vignetteEnabled is set to true.
  98467. */
  98468. vignetteColor: Color4;
  98469. /**
  98470. * Gets Camera field of view used by the Vignette effect.
  98471. */
  98472. /**
  98473. * Sets Camera field of view used by the Vignette effect.
  98474. */
  98475. vignetteCameraFov: number;
  98476. /**
  98477. * Gets the vignette blend mode allowing different kind of effect.
  98478. */
  98479. /**
  98480. * Sets the vignette blend mode allowing different kind of effect.
  98481. */
  98482. vignetteBlendMode: number;
  98483. /**
  98484. * Gets wether the vignette effect is enabled.
  98485. */
  98486. /**
  98487. * Sets wether the vignette effect is enabled.
  98488. */
  98489. vignetteEnabled: boolean;
  98490. private _fromLinearSpace;
  98491. /**
  98492. * Gets wether the input of the processing is in Gamma or Linear Space.
  98493. */
  98494. /**
  98495. * Sets wether the input of the processing is in Gamma or Linear Space.
  98496. */
  98497. fromLinearSpace: boolean;
  98498. /**
  98499. * Defines cache preventing GC.
  98500. */
  98501. private _defines;
  98502. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  98503. /**
  98504. * "ImageProcessingPostProcess"
  98505. * @returns "ImageProcessingPostProcess"
  98506. */
  98507. getClassName(): string;
  98508. protected _updateParameters(): void;
  98509. dispose(camera?: Camera): void;
  98510. }
  98511. }
  98512. declare module BABYLON {
  98513. /**
  98514. * Class containing static functions to help procedurally build meshes
  98515. */
  98516. export class GroundBuilder {
  98517. /**
  98518. * Creates a ground mesh
  98519. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  98520. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  98521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98522. * @param name defines the name of the mesh
  98523. * @param options defines the options used to create the mesh
  98524. * @param scene defines the hosting scene
  98525. * @returns the ground mesh
  98526. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  98527. */
  98528. static CreateGround(name: string, options: {
  98529. width?: number;
  98530. height?: number;
  98531. subdivisions?: number;
  98532. subdivisionsX?: number;
  98533. subdivisionsY?: number;
  98534. updatable?: boolean;
  98535. }, scene: any): Mesh;
  98536. /**
  98537. * Creates a tiled ground mesh
  98538. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  98539. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  98540. * * 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
  98541. * * 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
  98542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98543. * @param name defines the name of the mesh
  98544. * @param options defines the options used to create the mesh
  98545. * @param scene defines the hosting scene
  98546. * @returns the tiled ground mesh
  98547. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  98548. */
  98549. static CreateTiledGround(name: string, options: {
  98550. xmin: number;
  98551. zmin: number;
  98552. xmax: number;
  98553. zmax: number;
  98554. subdivisions?: {
  98555. w: number;
  98556. h: number;
  98557. };
  98558. precision?: {
  98559. w: number;
  98560. h: number;
  98561. };
  98562. updatable?: boolean;
  98563. }, scene?: Nullable<Scene>): Mesh;
  98564. /**
  98565. * Creates a ground mesh from a height map
  98566. * * The parameter `url` sets the URL of the height map image resource.
  98567. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  98568. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  98569. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  98570. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  98571. * * 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.
  98572. * * 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).
  98573. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98575. * @param name defines the name of the mesh
  98576. * @param url defines the url to the height map
  98577. * @param options defines the options used to create the mesh
  98578. * @param scene defines the hosting scene
  98579. * @returns the ground mesh
  98580. * @see https://doc.babylonjs.com/babylon101/height_map
  98581. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  98582. */
  98583. static CreateGroundFromHeightMap(name: string, url: string, options: {
  98584. width?: number;
  98585. height?: number;
  98586. subdivisions?: number;
  98587. minHeight?: number;
  98588. maxHeight?: number;
  98589. colorFilter?: Color3;
  98590. alphaFilter?: number;
  98591. updatable?: boolean;
  98592. onReady?: (mesh: GroundMesh) => void;
  98593. }, scene?: Nullable<Scene>): GroundMesh;
  98594. }
  98595. }
  98596. declare module BABYLON {
  98597. /**
  98598. * Class containing static functions to help procedurally build meshes
  98599. */
  98600. export class TorusBuilder {
  98601. /**
  98602. * Creates a torus mesh
  98603. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  98604. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  98605. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  98606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98607. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98609. * @param name defines the name of the mesh
  98610. * @param options defines the options used to create the mesh
  98611. * @param scene defines the hosting scene
  98612. * @returns the torus mesh
  98613. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  98614. */
  98615. static CreateTorus(name: string, options: {
  98616. diameter?: number;
  98617. thickness?: number;
  98618. tessellation?: number;
  98619. updatable?: boolean;
  98620. sideOrientation?: number;
  98621. frontUVs?: Vector4;
  98622. backUVs?: Vector4;
  98623. }, scene: any): Mesh;
  98624. }
  98625. }
  98626. declare module BABYLON {
  98627. /**
  98628. * Class containing static functions to help procedurally build meshes
  98629. */
  98630. export class CylinderBuilder {
  98631. /**
  98632. * Creates a cylinder or a cone mesh
  98633. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  98634. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  98635. * * 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.
  98636. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  98637. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  98638. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  98639. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  98640. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  98641. * * 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).
  98642. * * 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
  98643. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  98644. * * 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
  98645. * * 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.
  98646. * * If `enclose` is false, a ring surface is one element.
  98647. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  98648. * * 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
  98649. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98650. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98652. * @param name defines the name of the mesh
  98653. * @param options defines the options used to create the mesh
  98654. * @param scene defines the hosting scene
  98655. * @returns the cylinder mesh
  98656. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  98657. */
  98658. static CreateCylinder(name: string, options: {
  98659. height?: number;
  98660. diameterTop?: number;
  98661. diameterBottom?: number;
  98662. diameter?: number;
  98663. tessellation?: number;
  98664. subdivisions?: number;
  98665. arc?: number;
  98666. faceColors?: Color4[];
  98667. faceUV?: Vector4[];
  98668. updatable?: boolean;
  98669. hasRings?: boolean;
  98670. enclose?: boolean;
  98671. sideOrientation?: number;
  98672. frontUVs?: Vector4;
  98673. backUVs?: Vector4;
  98674. }, scene: any): Mesh;
  98675. }
  98676. }
  98677. declare module BABYLON {
  98678. /**
  98679. * Manager for handling gamepads
  98680. */
  98681. export class GamepadManager {
  98682. private _scene?;
  98683. private _babylonGamepads;
  98684. private _oneGamepadConnected;
  98685. /** @hidden */
  98686. _isMonitoring: boolean;
  98687. private _gamepadEventSupported;
  98688. private _gamepadSupport;
  98689. /**
  98690. * observable to be triggered when the gamepad controller has been connected
  98691. */
  98692. onGamepadConnectedObservable: Observable<Gamepad>;
  98693. /**
  98694. * observable to be triggered when the gamepad controller has been disconnected
  98695. */
  98696. onGamepadDisconnectedObservable: Observable<Gamepad>;
  98697. private _onGamepadConnectedEvent;
  98698. private _onGamepadDisconnectedEvent;
  98699. /**
  98700. * Initializes the gamepad manager
  98701. * @param _scene BabylonJS scene
  98702. */
  98703. constructor(_scene?: Scene | undefined);
  98704. /**
  98705. * The gamepads in the game pad manager
  98706. */
  98707. readonly gamepads: Gamepad[];
  98708. /**
  98709. * Get the gamepad controllers based on type
  98710. * @param type The type of gamepad controller
  98711. * @returns Nullable gamepad
  98712. */
  98713. getGamepadByType(type?: number): Nullable<Gamepad>;
  98714. /**
  98715. * Disposes the gamepad manager
  98716. */
  98717. dispose(): void;
  98718. private _addNewGamepad;
  98719. private _startMonitoringGamepads;
  98720. private _stopMonitoringGamepads;
  98721. /** @hidden */
  98722. _checkGamepadsStatus(): void;
  98723. private _updateGamepadObjects;
  98724. }
  98725. }
  98726. declare module BABYLON {
  98727. interface Scene {
  98728. /** @hidden */
  98729. _gamepadManager: Nullable<GamepadManager>;
  98730. /**
  98731. * Gets the gamepad manager associated with the scene
  98732. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  98733. */
  98734. gamepadManager: GamepadManager;
  98735. }
  98736. /**
  98737. * Interface representing a free camera inputs manager
  98738. */
  98739. interface FreeCameraInputsManager {
  98740. /**
  98741. * Adds gamepad input support to the FreeCameraInputsManager.
  98742. * @returns the FreeCameraInputsManager
  98743. */
  98744. addGamepad(): FreeCameraInputsManager;
  98745. }
  98746. /**
  98747. * Interface representing an arc rotate camera inputs manager
  98748. */
  98749. interface ArcRotateCameraInputsManager {
  98750. /**
  98751. * Adds gamepad input support to the ArcRotateCamera InputManager.
  98752. * @returns the camera inputs manager
  98753. */
  98754. addGamepad(): ArcRotateCameraInputsManager;
  98755. }
  98756. /**
  98757. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  98758. */
  98759. export class GamepadSystemSceneComponent implements ISceneComponent {
  98760. /**
  98761. * The component name helpfull to identify the component in the list of scene components.
  98762. */
  98763. readonly name: string;
  98764. /**
  98765. * The scene the component belongs to.
  98766. */
  98767. scene: Scene;
  98768. /**
  98769. * Creates a new instance of the component for the given scene
  98770. * @param scene Defines the scene to register the component in
  98771. */
  98772. constructor(scene: Scene);
  98773. /**
  98774. * Registers the component in a given scene
  98775. */
  98776. register(): void;
  98777. /**
  98778. * Rebuilds the elements related to this component in case of
  98779. * context lost for instance.
  98780. */
  98781. rebuild(): void;
  98782. /**
  98783. * Disposes the component and the associated ressources
  98784. */
  98785. dispose(): void;
  98786. private _beforeCameraUpdate;
  98787. }
  98788. }
  98789. declare module BABYLON {
  98790. /**
  98791. * Options to modify the vr teleportation behavior.
  98792. */
  98793. export interface VRTeleportationOptions {
  98794. /**
  98795. * The name of the mesh which should be used as the teleportation floor. (default: null)
  98796. */
  98797. floorMeshName?: string;
  98798. /**
  98799. * A list of meshes to be used as the teleportation floor. (default: empty)
  98800. */
  98801. floorMeshes?: Mesh[];
  98802. }
  98803. /**
  98804. * Options to modify the vr experience helper's behavior.
  98805. */
  98806. export interface VRExperienceHelperOptions extends WebVROptions {
  98807. /**
  98808. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  98809. */
  98810. createDeviceOrientationCamera?: boolean;
  98811. /**
  98812. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  98813. */
  98814. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  98815. /**
  98816. * Uses the main button on the controller to toggle the laser casted. (default: true)
  98817. */
  98818. laserToggle?: boolean;
  98819. /**
  98820. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  98821. */
  98822. floorMeshes?: Mesh[];
  98823. /**
  98824. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  98825. */
  98826. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  98827. }
  98828. /**
  98829. * Event containing information after VR has been entered
  98830. */
  98831. export class OnAfterEnteringVRObservableEvent {
  98832. /**
  98833. * If entering vr was successful
  98834. */
  98835. success: boolean;
  98836. }
  98837. /**
  98838. * Helps to quickly add VR support to an existing scene.
  98839. * See http://doc.babylonjs.com/how_to/webvr_helper
  98840. */
  98841. export class VRExperienceHelper {
  98842. /** Options to modify the vr experience helper's behavior. */
  98843. webVROptions: VRExperienceHelperOptions;
  98844. private _scene;
  98845. private _position;
  98846. private _btnVR;
  98847. private _btnVRDisplayed;
  98848. private _webVRsupported;
  98849. private _webVRready;
  98850. private _webVRrequesting;
  98851. private _webVRpresenting;
  98852. private _hasEnteredVR;
  98853. private _fullscreenVRpresenting;
  98854. private _canvas;
  98855. private _webVRCamera;
  98856. private _vrDeviceOrientationCamera;
  98857. private _deviceOrientationCamera;
  98858. private _existingCamera;
  98859. private _onKeyDown;
  98860. private _onVrDisplayPresentChange;
  98861. private _onVRDisplayChanged;
  98862. private _onVRRequestPresentStart;
  98863. private _onVRRequestPresentComplete;
  98864. /**
  98865. * Observable raised right before entering VR.
  98866. */
  98867. onEnteringVRObservable: Observable<VRExperienceHelper>;
  98868. /**
  98869. * Observable raised when entering VR has completed.
  98870. */
  98871. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  98872. /**
  98873. * Observable raised when exiting VR.
  98874. */
  98875. onExitingVRObservable: Observable<VRExperienceHelper>;
  98876. /**
  98877. * Observable raised when controller mesh is loaded.
  98878. */
  98879. onControllerMeshLoadedObservable: Observable<WebVRController>;
  98880. /** Return this.onEnteringVRObservable
  98881. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  98882. */
  98883. readonly onEnteringVR: Observable<VRExperienceHelper>;
  98884. /** Return this.onExitingVRObservable
  98885. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  98886. */
  98887. readonly onExitingVR: Observable<VRExperienceHelper>;
  98888. /** Return this.onControllerMeshLoadedObservable
  98889. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  98890. */
  98891. readonly onControllerMeshLoaded: Observable<WebVRController>;
  98892. private _rayLength;
  98893. private _useCustomVRButton;
  98894. private _teleportationRequested;
  98895. private _teleportActive;
  98896. private _floorMeshName;
  98897. private _floorMeshesCollection;
  98898. private _rotationAllowed;
  98899. private _teleportBackwardsVector;
  98900. private _teleportationTarget;
  98901. private _isDefaultTeleportationTarget;
  98902. private _postProcessMove;
  98903. private _teleportationFillColor;
  98904. private _teleportationBorderColor;
  98905. private _rotationAngle;
  98906. private _haloCenter;
  98907. private _cameraGazer;
  98908. private _padSensibilityUp;
  98909. private _padSensibilityDown;
  98910. private _leftController;
  98911. private _rightController;
  98912. /**
  98913. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  98914. */
  98915. onNewMeshSelected: Observable<AbstractMesh>;
  98916. /**
  98917. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  98918. */
  98919. onNewMeshPicked: Observable<PickingInfo>;
  98920. private _circleEase;
  98921. /**
  98922. * Observable raised before camera teleportation
  98923. */
  98924. onBeforeCameraTeleport: Observable<Vector3>;
  98925. /**
  98926. * Observable raised after camera teleportation
  98927. */
  98928. onAfterCameraTeleport: Observable<Vector3>;
  98929. /**
  98930. * Observable raised when current selected mesh gets unselected
  98931. */
  98932. onSelectedMeshUnselected: Observable<AbstractMesh>;
  98933. private _raySelectionPredicate;
  98934. /**
  98935. * To be optionaly changed by user to define custom ray selection
  98936. */
  98937. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  98938. /**
  98939. * To be optionaly changed by user to define custom selection logic (after ray selection)
  98940. */
  98941. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  98942. /**
  98943. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  98944. */
  98945. teleportationEnabled: boolean;
  98946. private _defaultHeight;
  98947. private _teleportationInitialized;
  98948. private _interactionsEnabled;
  98949. private _interactionsRequested;
  98950. private _displayGaze;
  98951. private _displayLaserPointer;
  98952. /**
  98953. * The mesh used to display where the user is going to teleport.
  98954. */
  98955. /**
  98956. * Sets the mesh to be used to display where the user is going to teleport.
  98957. */
  98958. teleportationTarget: Mesh;
  98959. /**
  98960. * 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
  98961. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  98962. * See http://doc.babylonjs.com/resources/baking_transformations
  98963. */
  98964. gazeTrackerMesh: Mesh;
  98965. /**
  98966. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  98967. */
  98968. updateGazeTrackerScale: boolean;
  98969. /**
  98970. * If the gaze trackers color should be updated when selecting meshes
  98971. */
  98972. updateGazeTrackerColor: boolean;
  98973. /**
  98974. * The gaze tracking mesh corresponding to the left controller
  98975. */
  98976. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  98977. /**
  98978. * The gaze tracking mesh corresponding to the right controller
  98979. */
  98980. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  98981. /**
  98982. * If the ray of the gaze should be displayed.
  98983. */
  98984. /**
  98985. * Sets if the ray of the gaze should be displayed.
  98986. */
  98987. displayGaze: boolean;
  98988. /**
  98989. * If the ray of the LaserPointer should be displayed.
  98990. */
  98991. /**
  98992. * Sets if the ray of the LaserPointer should be displayed.
  98993. */
  98994. displayLaserPointer: boolean;
  98995. /**
  98996. * The deviceOrientationCamera used as the camera when not in VR.
  98997. */
  98998. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  98999. /**
  99000. * Based on the current WebVR support, returns the current VR camera used.
  99001. */
  99002. readonly currentVRCamera: Nullable<Camera>;
  99003. /**
  99004. * The webVRCamera which is used when in VR.
  99005. */
  99006. readonly webVRCamera: WebVRFreeCamera;
  99007. /**
  99008. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  99009. */
  99010. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  99011. private readonly _teleportationRequestInitiated;
  99012. /**
  99013. * Defines wether or not Pointer lock should be requested when switching to
  99014. * full screen.
  99015. */
  99016. requestPointerLockOnFullScreen: boolean;
  99017. /**
  99018. * Instantiates a VRExperienceHelper.
  99019. * Helps to quickly add VR support to an existing scene.
  99020. * @param scene The scene the VRExperienceHelper belongs to.
  99021. * @param webVROptions Options to modify the vr experience helper's behavior.
  99022. */
  99023. constructor(scene: Scene,
  99024. /** Options to modify the vr experience helper's behavior. */
  99025. webVROptions?: VRExperienceHelperOptions);
  99026. private _onDefaultMeshLoaded;
  99027. private _onResize;
  99028. private _onFullscreenChange;
  99029. /**
  99030. * Gets a value indicating if we are currently in VR mode.
  99031. */
  99032. readonly isInVRMode: boolean;
  99033. private onVrDisplayPresentChange;
  99034. private onVRDisplayChanged;
  99035. private moveButtonToBottomRight;
  99036. private displayVRButton;
  99037. private updateButtonVisibility;
  99038. private _cachedAngularSensibility;
  99039. /**
  99040. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  99041. * Otherwise, will use the fullscreen API.
  99042. */
  99043. enterVR(): void;
  99044. /**
  99045. * Attempt to exit VR, or fullscreen.
  99046. */
  99047. exitVR(): void;
  99048. /**
  99049. * The position of the vr experience helper.
  99050. */
  99051. /**
  99052. * Sets the position of the vr experience helper.
  99053. */
  99054. position: Vector3;
  99055. /**
  99056. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  99057. */
  99058. enableInteractions(): void;
  99059. private readonly _noControllerIsActive;
  99060. private beforeRender;
  99061. private _isTeleportationFloor;
  99062. /**
  99063. * Adds a floor mesh to be used for teleportation.
  99064. * @param floorMesh the mesh to be used for teleportation.
  99065. */
  99066. addFloorMesh(floorMesh: Mesh): void;
  99067. /**
  99068. * Removes a floor mesh from being used for teleportation.
  99069. * @param floorMesh the mesh to be removed.
  99070. */
  99071. removeFloorMesh(floorMesh: Mesh): void;
  99072. /**
  99073. * Enables interactions and teleportation using the VR controllers and gaze.
  99074. * @param vrTeleportationOptions options to modify teleportation behavior.
  99075. */
  99076. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  99077. private _onNewGamepadConnected;
  99078. private _tryEnableInteractionOnController;
  99079. private _onNewGamepadDisconnected;
  99080. private _enableInteractionOnController;
  99081. private _checkTeleportWithRay;
  99082. private _checkRotate;
  99083. private _checkTeleportBackwards;
  99084. private _enableTeleportationOnController;
  99085. private _createTeleportationCircles;
  99086. private _displayTeleportationTarget;
  99087. private _hideTeleportationTarget;
  99088. private _rotateCamera;
  99089. private _moveTeleportationSelectorTo;
  99090. private _workingVector;
  99091. private _workingQuaternion;
  99092. private _workingMatrix;
  99093. /**
  99094. * Teleports the users feet to the desired location
  99095. * @param location The location where the user's feet should be placed
  99096. */
  99097. teleportCamera(location: Vector3): void;
  99098. private _convertNormalToDirectionOfRay;
  99099. private _castRayAndSelectObject;
  99100. private _notifySelectedMeshUnselected;
  99101. /**
  99102. * Sets the color of the laser ray from the vr controllers.
  99103. * @param color new color for the ray.
  99104. */
  99105. changeLaserColor(color: Color3): void;
  99106. /**
  99107. * Sets the color of the ray from the vr headsets gaze.
  99108. * @param color new color for the ray.
  99109. */
  99110. changeGazeColor(color: Color3): void;
  99111. /**
  99112. * Exits VR and disposes of the vr experience helper
  99113. */
  99114. dispose(): void;
  99115. /**
  99116. * Gets the name of the VRExperienceHelper class
  99117. * @returns "VRExperienceHelper"
  99118. */
  99119. getClassName(): string;
  99120. }
  99121. }
  99122. declare module BABYLON {
  99123. /**
  99124. * Manages an XRSession
  99125. * @see https://doc.babylonjs.com/how_to/webxr
  99126. */
  99127. export class WebXRSessionManager implements IDisposable {
  99128. private scene;
  99129. /**
  99130. * Fires every time a new xrFrame arrives which can be used to update the camera
  99131. */
  99132. onXRFrameObservable: Observable<any>;
  99133. /**
  99134. * Fires when the xr session is ended either by the device or manually done
  99135. */
  99136. onXRSessionEnded: Observable<any>;
  99137. /** @hidden */
  99138. _xrSession: XRSession;
  99139. /** @hidden */
  99140. _frameOfReference: XRFrameOfReference;
  99141. /** @hidden */
  99142. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  99143. /** @hidden */
  99144. _currentXRFrame: Nullable<XRFrame>;
  99145. private _xrNavigator;
  99146. private _xrDevice;
  99147. private _tmpMatrix;
  99148. /**
  99149. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  99150. * @param scene The scene which the session should be created for
  99151. */
  99152. constructor(scene: Scene);
  99153. /**
  99154. * Initializes the manager
  99155. * After initialization enterXR can be called to start an XR session
  99156. * @returns Promise which resolves after it is initialized
  99157. */
  99158. initializeAsync(): Promise<void>;
  99159. /**
  99160. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  99161. * @param sessionCreationOptions xr options to create the session with
  99162. * @param frameOfReferenceType option to configure how the xr pose is expressed
  99163. * @returns Promise which resolves after it enters XR
  99164. */
  99165. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  99166. /**
  99167. * Stops the xrSession and restores the renderloop
  99168. * @returns Promise which resolves after it exits XR
  99169. */
  99170. exitXRAsync(): Promise<void>;
  99171. /**
  99172. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99173. * @param ray ray to cast into the environment
  99174. * @returns Promise which resolves with a collision point in the environment if it exists
  99175. */
  99176. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99177. /**
  99178. * Checks if a session would be supported for the creation options specified
  99179. * @param options creation options to check if they are supported
  99180. * @returns true if supported
  99181. */
  99182. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99183. /**
  99184. * @hidden
  99185. * Converts the render layer of xrSession to a render target
  99186. * @param session session to create render target for
  99187. * @param scene scene the new render target should be created for
  99188. */
  99189. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  99190. /**
  99191. * Disposes of the session manager
  99192. */
  99193. dispose(): void;
  99194. }
  99195. }
  99196. declare module BABYLON {
  99197. /**
  99198. * WebXR Camera which holds the views for the xrSession
  99199. * @see https://doc.babylonjs.com/how_to/webxr
  99200. */
  99201. export class WebXRCamera extends FreeCamera {
  99202. private static _TmpMatrix;
  99203. /**
  99204. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  99205. * @param name the name of the camera
  99206. * @param scene the scene to add the camera to
  99207. */
  99208. constructor(name: string, scene: Scene);
  99209. private _updateNumberOfRigCameras;
  99210. /** @hidden */
  99211. _updateForDualEyeDebugging(pupilDistance?: number): void;
  99212. /**
  99213. * Updates the cameras position from the current pose information of the XR session
  99214. * @param xrSessionManager the session containing pose information
  99215. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  99216. */
  99217. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  99218. }
  99219. }
  99220. declare module BABYLON {
  99221. /**
  99222. * States of the webXR experience
  99223. */
  99224. export enum WebXRState {
  99225. /**
  99226. * Transitioning to being in XR mode
  99227. */
  99228. ENTERING_XR = 0,
  99229. /**
  99230. * Transitioning to non XR mode
  99231. */
  99232. EXITING_XR = 1,
  99233. /**
  99234. * In XR mode and presenting
  99235. */
  99236. IN_XR = 2,
  99237. /**
  99238. * Not entered XR mode
  99239. */
  99240. NOT_IN_XR = 3
  99241. }
  99242. /**
  99243. * Helper class used to enable XR
  99244. * @see https://doc.babylonjs.com/how_to/webxr
  99245. */
  99246. export class WebXRExperienceHelper implements IDisposable {
  99247. private scene;
  99248. /**
  99249. * 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
  99250. */
  99251. container: AbstractMesh;
  99252. /**
  99253. * Camera used to render xr content
  99254. */
  99255. camera: WebXRCamera;
  99256. /**
  99257. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  99258. */
  99259. state: WebXRState;
  99260. private _setState;
  99261. private static _TmpVector;
  99262. /**
  99263. * Fires when the state of the experience helper has changed
  99264. */
  99265. onStateChangedObservable: Observable<WebXRState>;
  99266. /** @hidden */
  99267. _sessionManager: WebXRSessionManager;
  99268. private _nonVRCamera;
  99269. private _originalSceneAutoClear;
  99270. private _supported;
  99271. /**
  99272. * Creates the experience helper
  99273. * @param scene the scene to attach the experience helper to
  99274. * @returns a promise for the experience helper
  99275. */
  99276. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  99277. /**
  99278. * Creates a WebXRExperienceHelper
  99279. * @param scene The scene the helper should be created in
  99280. */
  99281. private constructor();
  99282. /**
  99283. * Exits XR mode and returns the scene to its original state
  99284. * @returns promise that resolves after xr mode has exited
  99285. */
  99286. exitXRAsync(): Promise<void>;
  99287. /**
  99288. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  99289. * @param sessionCreationOptions options for the XR session
  99290. * @param frameOfReference frame of reference of the XR session
  99291. * @returns promise that resolves after xr mode has entered
  99292. */
  99293. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  99294. /**
  99295. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99296. * @param ray ray to cast into the environment
  99297. * @returns Promise which resolves with a collision point in the environment if it exists
  99298. */
  99299. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99300. /**
  99301. * Updates the global position of the camera by moving the camera's container
  99302. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  99303. * @param position The desired global position of the camera
  99304. */
  99305. setPositionOfCameraUsingContainer(position: Vector3): void;
  99306. /**
  99307. * Rotates the xr camera by rotating the camera's container around the camera's position
  99308. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  99309. * @param rotation the desired quaternion rotation to apply to the camera
  99310. */
  99311. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  99312. /**
  99313. * Checks if the creation options are supported by the xr session
  99314. * @param options creation options
  99315. * @returns true if supported
  99316. */
  99317. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99318. /**
  99319. * Disposes of the experience helper
  99320. */
  99321. dispose(): void;
  99322. }
  99323. }
  99324. declare module BABYLON {
  99325. /**
  99326. * Button which can be used to enter a different mode of XR
  99327. */
  99328. export class WebXREnterExitUIButton {
  99329. /** button element */
  99330. element: HTMLElement;
  99331. /** XR initialization options for the button */
  99332. initializationOptions: XRSessionCreationOptions;
  99333. /**
  99334. * Creates a WebXREnterExitUIButton
  99335. * @param element button element
  99336. * @param initializationOptions XR initialization options for the button
  99337. */
  99338. constructor(
  99339. /** button element */
  99340. element: HTMLElement,
  99341. /** XR initialization options for the button */
  99342. initializationOptions: XRSessionCreationOptions);
  99343. /**
  99344. * Overwritable function which can be used to update the button's visuals when the state changes
  99345. * @param activeButton the current active button in the UI
  99346. */
  99347. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  99348. }
  99349. /**
  99350. * Options to create the webXR UI
  99351. */
  99352. export class WebXREnterExitUIOptions {
  99353. /**
  99354. * Context to enter xr with
  99355. */
  99356. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  99357. /**
  99358. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  99359. */
  99360. customButtons?: Array<WebXREnterExitUIButton>;
  99361. }
  99362. /**
  99363. * UI to allow the user to enter/exit XR mode
  99364. */
  99365. export class WebXREnterExitUI implements IDisposable {
  99366. private scene;
  99367. private _overlay;
  99368. private _buttons;
  99369. private _activeButton;
  99370. /**
  99371. * Fired every time the active button is changed.
  99372. *
  99373. * When xr is entered via a button that launches xr that button will be the callback parameter
  99374. *
  99375. * When exiting xr the callback parameter will be null)
  99376. */
  99377. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  99378. /**
  99379. * Creates UI to allow the user to enter/exit XR mode
  99380. * @param scene the scene to add the ui to
  99381. * @param helper the xr experience helper to enter/exit xr with
  99382. * @param options options to configure the UI
  99383. * @returns the created ui
  99384. */
  99385. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  99386. private constructor();
  99387. private _updateButtons;
  99388. /**
  99389. * Disposes of the object
  99390. */
  99391. dispose(): void;
  99392. }
  99393. }
  99394. declare module BABYLON {
  99395. /**
  99396. * Represents an XR input
  99397. */
  99398. export class WebXRController {
  99399. /**
  99400. * 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
  99401. */
  99402. grip?: AbstractMesh;
  99403. /**
  99404. * Pointer which can be used to select objects or attach a visible laser to
  99405. */
  99406. pointer: AbstractMesh;
  99407. /**
  99408. * Creates the controller
  99409. * @see https://doc.babylonjs.com/how_to/webxr
  99410. * @param scene the scene which the controller should be associated to
  99411. */
  99412. constructor(scene: Scene);
  99413. /**
  99414. * Disposes of the object
  99415. */
  99416. dispose(): void;
  99417. }
  99418. /**
  99419. * XR input used to track XR inputs such as controllers/rays
  99420. */
  99421. export class WebXRInput implements IDisposable {
  99422. private helper;
  99423. /**
  99424. * XR controllers being tracked
  99425. */
  99426. controllers: Array<WebXRController>;
  99427. private _tmpMatrix;
  99428. private _frameObserver;
  99429. /**
  99430. * Initializes the WebXRInput
  99431. * @param helper experience helper which the input should be created for
  99432. */
  99433. constructor(helper: WebXRExperienceHelper);
  99434. /**
  99435. * Disposes of the object
  99436. */
  99437. dispose(): void;
  99438. }
  99439. }
  99440. declare module BABYLON {
  99441. /**
  99442. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  99443. */
  99444. export class WebXRManagedOutputCanvas implements IDisposable {
  99445. private _canvas;
  99446. /**
  99447. * xrpresent context of the canvas which can be used to display/mirror xr content
  99448. */
  99449. canvasContext: Nullable<WebGLRenderingContext>;
  99450. /**
  99451. * Initializes the canvas to be added/removed upon entering/exiting xr
  99452. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  99453. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  99454. */
  99455. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  99456. /**
  99457. * Disposes of the object
  99458. */
  99459. dispose(): void;
  99460. private _setManagedOutputCanvas;
  99461. private _addCanvas;
  99462. private _removeCanvas;
  99463. }
  99464. }
  99465. declare module BABYLON {
  99466. /**
  99467. * Contains an array of blocks representing the octree
  99468. */
  99469. export interface IOctreeContainer<T> {
  99470. /**
  99471. * Blocks within the octree
  99472. */
  99473. blocks: Array<OctreeBlock<T>>;
  99474. }
  99475. /**
  99476. * Class used to store a cell in an octree
  99477. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99478. */
  99479. export class OctreeBlock<T> {
  99480. /**
  99481. * Gets the content of the current block
  99482. */
  99483. entries: T[];
  99484. /**
  99485. * Gets the list of block children
  99486. */
  99487. blocks: Array<OctreeBlock<T>>;
  99488. private _depth;
  99489. private _maxDepth;
  99490. private _capacity;
  99491. private _minPoint;
  99492. private _maxPoint;
  99493. private _boundingVectors;
  99494. private _creationFunc;
  99495. /**
  99496. * Creates a new block
  99497. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  99498. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  99499. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  99500. * @param depth defines the current depth of this block in the octree
  99501. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  99502. * @param creationFunc defines a callback to call when an element is added to the block
  99503. */
  99504. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  99505. /**
  99506. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  99507. */
  99508. readonly capacity: number;
  99509. /**
  99510. * Gets the minimum vector (in world space) of the block's bounding box
  99511. */
  99512. readonly minPoint: Vector3;
  99513. /**
  99514. * Gets the maximum vector (in world space) of the block's bounding box
  99515. */
  99516. readonly maxPoint: Vector3;
  99517. /**
  99518. * Add a new element to this block
  99519. * @param entry defines the element to add
  99520. */
  99521. addEntry(entry: T): void;
  99522. /**
  99523. * Remove an element from this block
  99524. * @param entry defines the element to remove
  99525. */
  99526. removeEntry(entry: T): void;
  99527. /**
  99528. * Add an array of elements to this block
  99529. * @param entries defines the array of elements to add
  99530. */
  99531. addEntries(entries: T[]): void;
  99532. /**
  99533. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  99534. * @param frustumPlanes defines the frustum planes to test
  99535. * @param selection defines the array to store current content if selection is positive
  99536. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99537. */
  99538. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  99539. /**
  99540. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  99541. * @param sphereCenter defines the bounding sphere center
  99542. * @param sphereRadius defines the bounding sphere radius
  99543. * @param selection defines the array to store current content if selection is positive
  99544. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99545. */
  99546. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  99547. /**
  99548. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  99549. * @param ray defines the ray to test with
  99550. * @param selection defines the array to store current content if selection is positive
  99551. */
  99552. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  99553. /**
  99554. * Subdivide the content into child blocks (this block will then be empty)
  99555. */
  99556. createInnerBlocks(): void;
  99557. /**
  99558. * @hidden
  99559. */
  99560. 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;
  99561. }
  99562. }
  99563. declare module BABYLON {
  99564. /**
  99565. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  99566. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99567. */
  99568. export class Octree<T> {
  99569. /** 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.) */
  99570. maxDepth: number;
  99571. /**
  99572. * Blocks within the octree containing objects
  99573. */
  99574. blocks: Array<OctreeBlock<T>>;
  99575. /**
  99576. * Content stored in the octree
  99577. */
  99578. dynamicContent: T[];
  99579. private _maxBlockCapacity;
  99580. private _selectionContent;
  99581. private _creationFunc;
  99582. /**
  99583. * Creates a octree
  99584. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99585. * @param creationFunc function to be used to instatiate the octree
  99586. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  99587. * @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.)
  99588. */
  99589. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  99590. /** 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.) */
  99591. maxDepth?: number);
  99592. /**
  99593. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  99594. * @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);
  99595. * @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);
  99596. * @param entries meshes to be added to the octree blocks
  99597. */
  99598. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  99599. /**
  99600. * Adds a mesh to the octree
  99601. * @param entry Mesh to add to the octree
  99602. */
  99603. addMesh(entry: T): void;
  99604. /**
  99605. * Remove an element from the octree
  99606. * @param entry defines the element to remove
  99607. */
  99608. removeMesh(entry: T): void;
  99609. /**
  99610. * Selects an array of meshes within the frustum
  99611. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  99612. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  99613. * @returns array of meshes within the frustum
  99614. */
  99615. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  99616. /**
  99617. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  99618. * @param sphereCenter defines the bounding sphere center
  99619. * @param sphereRadius defines the bounding sphere radius
  99620. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99621. * @returns an array of objects that intersect the sphere
  99622. */
  99623. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  99624. /**
  99625. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  99626. * @param ray defines the ray to test with
  99627. * @returns array of intersected objects
  99628. */
  99629. intersectsRay(ray: Ray): SmartArray<T>;
  99630. /**
  99631. * Adds a mesh into the octree block if it intersects the block
  99632. */
  99633. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  99634. /**
  99635. * Adds a submesh into the octree block if it intersects the block
  99636. */
  99637. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  99638. }
  99639. }
  99640. declare module BABYLON {
  99641. interface Scene {
  99642. /**
  99643. * @hidden
  99644. * Backing Filed
  99645. */
  99646. _selectionOctree: Octree<AbstractMesh>;
  99647. /**
  99648. * Gets the octree used to boost mesh selection (picking)
  99649. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99650. */
  99651. selectionOctree: Octree<AbstractMesh>;
  99652. /**
  99653. * Creates or updates the octree used to boost selection (picking)
  99654. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99655. * @param maxCapacity defines the maximum capacity per leaf
  99656. * @param maxDepth defines the maximum depth of the octree
  99657. * @returns an octree of AbstractMesh
  99658. */
  99659. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  99660. }
  99661. interface AbstractMesh {
  99662. /**
  99663. * @hidden
  99664. * Backing Field
  99665. */
  99666. _submeshesOctree: Octree<SubMesh>;
  99667. /**
  99668. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  99669. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  99670. * @param maxCapacity defines the maximum size of each block (64 by default)
  99671. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  99672. * @returns the new octree
  99673. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  99674. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99675. */
  99676. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  99677. }
  99678. /**
  99679. * Defines the octree scene component responsible to manage any octrees
  99680. * in a given scene.
  99681. */
  99682. export class OctreeSceneComponent {
  99683. /**
  99684. * The component name helpfull to identify the component in the list of scene components.
  99685. */
  99686. readonly name: string;
  99687. /**
  99688. * The scene the component belongs to.
  99689. */
  99690. scene: Scene;
  99691. /**
  99692. * Indicates if the meshes have been checked to make sure they are isEnabled()
  99693. */
  99694. readonly checksIsEnabled: boolean;
  99695. /**
  99696. * Creates a new instance of the component for the given scene
  99697. * @param scene Defines the scene to register the component in
  99698. */
  99699. constructor(scene: Scene);
  99700. /**
  99701. * Registers the component in a given scene
  99702. */
  99703. register(): void;
  99704. /**
  99705. * Return the list of active meshes
  99706. * @returns the list of active meshes
  99707. */
  99708. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  99709. /**
  99710. * Return the list of active sub meshes
  99711. * @param mesh The mesh to get the candidates sub meshes from
  99712. * @returns the list of active sub meshes
  99713. */
  99714. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  99715. private _tempRay;
  99716. /**
  99717. * Return the list of sub meshes intersecting with a given local ray
  99718. * @param mesh defines the mesh to find the submesh for
  99719. * @param localRay defines the ray in local space
  99720. * @returns the list of intersecting sub meshes
  99721. */
  99722. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  99723. /**
  99724. * Return the list of sub meshes colliding with a collider
  99725. * @param mesh defines the mesh to find the submesh for
  99726. * @param collider defines the collider to evaluate the collision against
  99727. * @returns the list of colliding sub meshes
  99728. */
  99729. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  99730. /**
  99731. * Rebuilds the elements related to this component in case of
  99732. * context lost for instance.
  99733. */
  99734. rebuild(): void;
  99735. /**
  99736. * Disposes the component and the associated ressources.
  99737. */
  99738. dispose(): void;
  99739. }
  99740. }
  99741. declare module BABYLON {
  99742. /**
  99743. * Renders a layer on top of an existing scene
  99744. */
  99745. export class UtilityLayerRenderer implements IDisposable {
  99746. /** the original scene that will be rendered on top of */
  99747. originalScene: Scene;
  99748. private _pointerCaptures;
  99749. private _lastPointerEvents;
  99750. private static _DefaultUtilityLayer;
  99751. private static _DefaultKeepDepthUtilityLayer;
  99752. private _sharedGizmoLight;
  99753. /**
  99754. * @hidden
  99755. * Light which used by gizmos to get light shading
  99756. */
  99757. _getSharedGizmoLight(): HemisphericLight;
  99758. /**
  99759. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  99760. */
  99761. pickUtilitySceneFirst: boolean;
  99762. /**
  99763. * 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)
  99764. */
  99765. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  99766. /**
  99767. * 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)
  99768. */
  99769. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  99770. /**
  99771. * The scene that is rendered on top of the original scene
  99772. */
  99773. utilityLayerScene: Scene;
  99774. /**
  99775. * If the utility layer should automatically be rendered on top of existing scene
  99776. */
  99777. shouldRender: boolean;
  99778. /**
  99779. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  99780. */
  99781. onlyCheckPointerDownEvents: boolean;
  99782. /**
  99783. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  99784. */
  99785. processAllEvents: boolean;
  99786. /**
  99787. * Observable raised when the pointer move from the utility layer scene to the main scene
  99788. */
  99789. onPointerOutObservable: Observable<number>;
  99790. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  99791. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  99792. private _afterRenderObserver;
  99793. private _sceneDisposeObserver;
  99794. private _originalPointerObserver;
  99795. /**
  99796. * Instantiates a UtilityLayerRenderer
  99797. * @param originalScene the original scene that will be rendered on top of
  99798. * @param handleEvents boolean indicating if the utility layer should handle events
  99799. */
  99800. constructor(
  99801. /** the original scene that will be rendered on top of */
  99802. originalScene: Scene, handleEvents?: boolean);
  99803. private _notifyObservers;
  99804. /**
  99805. * Renders the utility layers scene on top of the original scene
  99806. */
  99807. render(): void;
  99808. /**
  99809. * Disposes of the renderer
  99810. */
  99811. dispose(): void;
  99812. private _updateCamera;
  99813. }
  99814. }
  99815. declare module BABYLON {
  99816. /**
  99817. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  99818. */
  99819. export class Gizmo implements IDisposable {
  99820. /** The utility layer the gizmo will be added to */
  99821. gizmoLayer: UtilityLayerRenderer;
  99822. /**
  99823. * The root mesh of the gizmo
  99824. */
  99825. _rootMesh: Mesh;
  99826. private _attachedMesh;
  99827. /**
  99828. * Ratio for the scale of the gizmo (Default: 1)
  99829. */
  99830. scaleRatio: number;
  99831. private _tmpMatrix;
  99832. /**
  99833. * If a custom mesh has been set (Default: false)
  99834. */
  99835. protected _customMeshSet: boolean;
  99836. /**
  99837. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  99838. * * When set, interactions will be enabled
  99839. */
  99840. attachedMesh: Nullable<AbstractMesh>;
  99841. /**
  99842. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  99843. * @param mesh The mesh to replace the default mesh of the gizmo
  99844. */
  99845. setCustomMesh(mesh: Mesh): void;
  99846. /**
  99847. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  99848. */
  99849. updateGizmoRotationToMatchAttachedMesh: boolean;
  99850. /**
  99851. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  99852. */
  99853. updateGizmoPositionToMatchAttachedMesh: boolean;
  99854. /**
  99855. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  99856. */
  99857. protected _updateScale: boolean;
  99858. protected _interactionsEnabled: boolean;
  99859. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99860. private _beforeRenderObserver;
  99861. /**
  99862. * Creates a gizmo
  99863. * @param gizmoLayer The utility layer the gizmo will be added to
  99864. */
  99865. constructor(
  99866. /** The utility layer the gizmo will be added to */
  99867. gizmoLayer?: UtilityLayerRenderer);
  99868. private _tempVector;
  99869. /**
  99870. * @hidden
  99871. * Updates the gizmo to match the attached mesh's position/rotation
  99872. */
  99873. protected _update(): void;
  99874. /**
  99875. * Disposes of the gizmo
  99876. */
  99877. dispose(): void;
  99878. }
  99879. }
  99880. declare module BABYLON {
  99881. /**
  99882. * Single axis drag gizmo
  99883. */
  99884. export class AxisDragGizmo extends Gizmo {
  99885. /**
  99886. * Drag behavior responsible for the gizmos dragging interactions
  99887. */
  99888. dragBehavior: PointerDragBehavior;
  99889. private _pointerObserver;
  99890. /**
  99891. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99892. */
  99893. snapDistance: number;
  99894. /**
  99895. * Event that fires each time the gizmo snaps to a new location.
  99896. * * snapDistance is the the change in distance
  99897. */
  99898. onSnapObservable: Observable<{
  99899. snapDistance: number;
  99900. }>;
  99901. /** @hidden */
  99902. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  99903. /** @hidden */
  99904. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  99905. /**
  99906. * Creates an AxisDragGizmo
  99907. * @param gizmoLayer The utility layer the gizmo will be added to
  99908. * @param dragAxis The axis which the gizmo will be able to drag on
  99909. * @param color The color of the gizmo
  99910. */
  99911. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99912. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99913. /**
  99914. * Disposes of the gizmo
  99915. */
  99916. dispose(): void;
  99917. }
  99918. }
  99919. declare module BABYLON.Debug {
  99920. /**
  99921. * The Axes viewer will show 3 axes in a specific point in space
  99922. */
  99923. export class AxesViewer {
  99924. private _xAxis;
  99925. private _yAxis;
  99926. private _zAxis;
  99927. private _scaleLinesFactor;
  99928. private _instanced;
  99929. /**
  99930. * Gets the hosting scene
  99931. */
  99932. scene: Scene;
  99933. /**
  99934. * Gets or sets a number used to scale line length
  99935. */
  99936. scaleLines: number;
  99937. /** Gets the node hierarchy used to render x-axis */
  99938. readonly xAxis: TransformNode;
  99939. /** Gets the node hierarchy used to render y-axis */
  99940. readonly yAxis: TransformNode;
  99941. /** Gets the node hierarchy used to render z-axis */
  99942. readonly zAxis: TransformNode;
  99943. /**
  99944. * Creates a new AxesViewer
  99945. * @param scene defines the hosting scene
  99946. * @param scaleLines defines a number used to scale line length (1 by default)
  99947. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  99948. * @param xAxis defines the node hierarchy used to render the x-axis
  99949. * @param yAxis defines the node hierarchy used to render the y-axis
  99950. * @param zAxis defines the node hierarchy used to render the z-axis
  99951. */
  99952. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  99953. /**
  99954. * Force the viewer to update
  99955. * @param position defines the position of the viewer
  99956. * @param xaxis defines the x axis of the viewer
  99957. * @param yaxis defines the y axis of the viewer
  99958. * @param zaxis defines the z axis of the viewer
  99959. */
  99960. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  99961. /**
  99962. * Creates an instance of this axes viewer.
  99963. * @returns a new axes viewer with instanced meshes
  99964. */
  99965. createInstance(): AxesViewer;
  99966. /** Releases resources */
  99967. dispose(): void;
  99968. private static _SetRenderingGroupId;
  99969. }
  99970. }
  99971. declare module BABYLON.Debug {
  99972. /**
  99973. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  99974. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  99975. */
  99976. export class BoneAxesViewer extends AxesViewer {
  99977. /**
  99978. * Gets or sets the target mesh where to display the axes viewer
  99979. */
  99980. mesh: Nullable<Mesh>;
  99981. /**
  99982. * Gets or sets the target bone where to display the axes viewer
  99983. */
  99984. bone: Nullable<Bone>;
  99985. /** Gets current position */
  99986. pos: Vector3;
  99987. /** Gets direction of X axis */
  99988. xaxis: Vector3;
  99989. /** Gets direction of Y axis */
  99990. yaxis: Vector3;
  99991. /** Gets direction of Z axis */
  99992. zaxis: Vector3;
  99993. /**
  99994. * Creates a new BoneAxesViewer
  99995. * @param scene defines the hosting scene
  99996. * @param bone defines the target bone
  99997. * @param mesh defines the target mesh
  99998. * @param scaleLines defines a scaling factor for line length (1 by default)
  99999. */
  100000. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  100001. /**
  100002. * Force the viewer to update
  100003. */
  100004. update(): void;
  100005. /** Releases resources */
  100006. dispose(): void;
  100007. }
  100008. }
  100009. declare module BABYLON {
  100010. /**
  100011. * Interface used to define scene explorer extensibility option
  100012. */
  100013. export interface IExplorerExtensibilityOption {
  100014. /**
  100015. * Define the option label
  100016. */
  100017. label: string;
  100018. /**
  100019. * Defines the action to execute on click
  100020. */
  100021. action: (entity: any) => void;
  100022. }
  100023. /**
  100024. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  100025. */
  100026. export interface IExplorerExtensibilityGroup {
  100027. /**
  100028. * Defines a predicate to test if a given type mut be extended
  100029. */
  100030. predicate: (entity: any) => boolean;
  100031. /**
  100032. * Gets the list of options added to a type
  100033. */
  100034. entries: IExplorerExtensibilityOption[];
  100035. }
  100036. /**
  100037. * Interface used to define the options to use to create the Inspector
  100038. */
  100039. export interface IInspectorOptions {
  100040. /**
  100041. * Display in overlay mode (default: false)
  100042. */
  100043. overlay?: boolean;
  100044. /**
  100045. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  100046. */
  100047. globalRoot?: HTMLElement;
  100048. /**
  100049. * Display the Scene explorer
  100050. */
  100051. showExplorer?: boolean;
  100052. /**
  100053. * Display the property inspector
  100054. */
  100055. showInspector?: boolean;
  100056. /**
  100057. * Display in embed mode (both panes on the right)
  100058. */
  100059. embedMode?: boolean;
  100060. /**
  100061. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  100062. */
  100063. handleResize?: boolean;
  100064. /**
  100065. * Allow the panes to popup (default: true)
  100066. */
  100067. enablePopup?: boolean;
  100068. /**
  100069. * Allow the panes to be closed by users (default: true)
  100070. */
  100071. enableClose?: boolean;
  100072. /**
  100073. * Optional list of extensibility entries
  100074. */
  100075. explorerExtensibility?: IExplorerExtensibilityGroup[];
  100076. /**
  100077. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  100078. */
  100079. inspectorURL?: string;
  100080. }
  100081. interface Scene {
  100082. /**
  100083. * @hidden
  100084. * Backing field
  100085. */
  100086. _debugLayer: DebugLayer;
  100087. /**
  100088. * Gets the debug layer (aka Inspector) associated with the scene
  100089. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100090. */
  100091. debugLayer: DebugLayer;
  100092. }
  100093. /**
  100094. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100095. * what is happening in your scene
  100096. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100097. */
  100098. export class DebugLayer {
  100099. /**
  100100. * Define the url to get the inspector script from.
  100101. * By default it uses the babylonjs CDN.
  100102. * @ignoreNaming
  100103. */
  100104. static InspectorURL: string;
  100105. private _scene;
  100106. private BJSINSPECTOR;
  100107. /**
  100108. * Observable triggered when a property is changed through the inspector.
  100109. */
  100110. onPropertyChangedObservable: Observable<{
  100111. object: any;
  100112. property: string;
  100113. value: any;
  100114. initialValue: any;
  100115. }>;
  100116. /**
  100117. * Instantiates a new debug layer.
  100118. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100119. * what is happening in your scene
  100120. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100121. * @param scene Defines the scene to inspect
  100122. */
  100123. constructor(scene: Scene);
  100124. /** Creates the inspector window. */
  100125. private _createInspector;
  100126. /**
  100127. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  100128. * @param entity defines the entity to select
  100129. * @param lineContainerTitle defines the specific block to highlight
  100130. */
  100131. select(entity: any, lineContainerTitle?: string): void;
  100132. /** Get the inspector from bundle or global */
  100133. private _getGlobalInspector;
  100134. /**
  100135. * Get if the inspector is visible or not.
  100136. * @returns true if visible otherwise, false
  100137. */
  100138. isVisible(): boolean;
  100139. /**
  100140. * Hide the inspector and close its window.
  100141. */
  100142. hide(): void;
  100143. /**
  100144. * Launch the debugLayer.
  100145. * @param config Define the configuration of the inspector
  100146. * @return a promise fulfilled when the debug layer is visible
  100147. */
  100148. show(config?: IInspectorOptions): Promise<DebugLayer>;
  100149. }
  100150. }
  100151. declare module BABYLON {
  100152. /**
  100153. * Class containing static functions to help procedurally build meshes
  100154. */
  100155. export class BoxBuilder {
  100156. /**
  100157. * Creates a box mesh
  100158. * * The parameter `size` sets the size (float) of each box side (default 1)
  100159. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  100160. * * 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)
  100161. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  100162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100163. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100165. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  100166. * @param name defines the name of the mesh
  100167. * @param options defines the options used to create the mesh
  100168. * @param scene defines the hosting scene
  100169. * @returns the box mesh
  100170. */
  100171. static CreateBox(name: string, options: {
  100172. size?: number;
  100173. width?: number;
  100174. height?: number;
  100175. depth?: number;
  100176. faceUV?: Vector4[];
  100177. faceColors?: Color4[];
  100178. sideOrientation?: number;
  100179. frontUVs?: Vector4;
  100180. backUVs?: Vector4;
  100181. updatable?: boolean;
  100182. }, scene?: Nullable<Scene>): Mesh;
  100183. }
  100184. }
  100185. declare module BABYLON {
  100186. /**
  100187. * Class containing static functions to help procedurally build meshes
  100188. */
  100189. export class SphereBuilder {
  100190. /**
  100191. * Creates a sphere mesh
  100192. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  100193. * * 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`)
  100194. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  100195. * * 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
  100196. * * 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)
  100197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100198. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100200. * @param name defines the name of the mesh
  100201. * @param options defines the options used to create the mesh
  100202. * @param scene defines the hosting scene
  100203. * @returns the sphere mesh
  100204. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  100205. */
  100206. static CreateSphere(name: string, options: {
  100207. segments?: number;
  100208. diameter?: number;
  100209. diameterX?: number;
  100210. diameterY?: number;
  100211. diameterZ?: number;
  100212. arc?: number;
  100213. slice?: number;
  100214. sideOrientation?: number;
  100215. frontUVs?: Vector4;
  100216. backUVs?: Vector4;
  100217. updatable?: boolean;
  100218. }, scene: any): Mesh;
  100219. }
  100220. }
  100221. declare module BABYLON.Debug {
  100222. /**
  100223. * Used to show the physics impostor around the specific mesh
  100224. */
  100225. export class PhysicsViewer {
  100226. /** @hidden */
  100227. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  100228. /** @hidden */
  100229. protected _meshes: Array<Nullable<AbstractMesh>>;
  100230. /** @hidden */
  100231. protected _scene: Nullable<Scene>;
  100232. /** @hidden */
  100233. protected _numMeshes: number;
  100234. /** @hidden */
  100235. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  100236. private _renderFunction;
  100237. private _utilityLayer;
  100238. private _debugBoxMesh;
  100239. private _debugSphereMesh;
  100240. private _debugCylinderMesh;
  100241. private _debugMaterial;
  100242. private _debugMeshMeshes;
  100243. /**
  100244. * Creates a new PhysicsViewer
  100245. * @param scene defines the hosting scene
  100246. */
  100247. constructor(scene: Scene);
  100248. /** @hidden */
  100249. protected _updateDebugMeshes(): void;
  100250. /**
  100251. * Renders a specified physic impostor
  100252. * @param impostor defines the impostor to render
  100253. * @param targetMesh defines the mesh represented by the impostor
  100254. * @returns the new debug mesh used to render the impostor
  100255. */
  100256. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  100257. /**
  100258. * Hides a specified physic impostor
  100259. * @param impostor defines the impostor to hide
  100260. */
  100261. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  100262. private _getDebugMaterial;
  100263. private _getDebugBoxMesh;
  100264. private _getDebugSphereMesh;
  100265. private _getDebugCylinderMesh;
  100266. private _getDebugMeshMesh;
  100267. private _getDebugMesh;
  100268. /** Releases all resources */
  100269. dispose(): void;
  100270. }
  100271. }
  100272. declare module BABYLON {
  100273. /**
  100274. * Class containing static functions to help procedurally build meshes
  100275. */
  100276. export class LinesBuilder {
  100277. /**
  100278. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  100279. * * 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
  100280. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  100281. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  100282. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  100283. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  100284. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  100285. * * 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
  100286. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  100287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100288. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  100289. * @param name defines the name of the new line system
  100290. * @param options defines the options used to create the line system
  100291. * @param scene defines the hosting scene
  100292. * @returns a new line system mesh
  100293. */
  100294. static CreateLineSystem(name: string, options: {
  100295. lines: Vector3[][];
  100296. updatable?: boolean;
  100297. instance?: Nullable<LinesMesh>;
  100298. colors?: Nullable<Color4[][]>;
  100299. useVertexAlpha?: boolean;
  100300. }, scene: Nullable<Scene>): LinesMesh;
  100301. /**
  100302. * Creates a line mesh
  100303. * 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
  100304. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  100305. * * The parameter `points` is an array successive Vector3
  100306. * * 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
  100307. * * The optional parameter `colors` is an array of successive Color4, one per line point
  100308. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  100309. * * When updating an instance, remember that only point positions can change, not the number of points
  100310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100311. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  100312. * @param name defines the name of the new line system
  100313. * @param options defines the options used to create the line system
  100314. * @param scene defines the hosting scene
  100315. * @returns a new line mesh
  100316. */
  100317. static CreateLines(name: string, options: {
  100318. points: Vector3[];
  100319. updatable?: boolean;
  100320. instance?: Nullable<LinesMesh>;
  100321. colors?: Color4[];
  100322. useVertexAlpha?: boolean;
  100323. }, scene?: Nullable<Scene>): LinesMesh;
  100324. /**
  100325. * Creates a dashed line mesh
  100326. * * 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
  100327. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  100328. * * The parameter `points` is an array successive Vector3
  100329. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  100330. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  100331. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  100332. * * 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
  100333. * * When updating an instance, remember that only point positions can change, not the number of points
  100334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100335. * @param name defines the name of the mesh
  100336. * @param options defines the options used to create the mesh
  100337. * @param scene defines the hosting scene
  100338. * @returns the dashed line mesh
  100339. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  100340. */
  100341. static CreateDashedLines(name: string, options: {
  100342. points: Vector3[];
  100343. dashSize?: number;
  100344. gapSize?: number;
  100345. dashNb?: number;
  100346. updatable?: boolean;
  100347. instance?: LinesMesh;
  100348. }, scene?: Nullable<Scene>): LinesMesh;
  100349. }
  100350. }
  100351. declare module BABYLON {
  100352. /**
  100353. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  100354. * in order to better appreciate the issue one might have.
  100355. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  100356. */
  100357. export class RayHelper {
  100358. /**
  100359. * Defines the ray we are currently tryin to visualize.
  100360. */
  100361. ray: Nullable<Ray>;
  100362. private _renderPoints;
  100363. private _renderLine;
  100364. private _renderFunction;
  100365. private _scene;
  100366. private _updateToMeshFunction;
  100367. private _attachedToMesh;
  100368. private _meshSpaceDirection;
  100369. private _meshSpaceOrigin;
  100370. /**
  100371. * Helper function to create a colored helper in a scene in one line.
  100372. * @param ray Defines the ray we are currently tryin to visualize
  100373. * @param scene Defines the scene the ray is used in
  100374. * @param color Defines the color we want to see the ray in
  100375. * @returns The newly created ray helper.
  100376. */
  100377. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  100378. /**
  100379. * Instantiate a new ray helper.
  100380. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  100381. * in order to better appreciate the issue one might have.
  100382. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  100383. * @param ray Defines the ray we are currently tryin to visualize
  100384. */
  100385. constructor(ray: Ray);
  100386. /**
  100387. * Shows the ray we are willing to debug.
  100388. * @param scene Defines the scene the ray needs to be rendered in
  100389. * @param color Defines the color the ray needs to be rendered in
  100390. */
  100391. show(scene: Scene, color?: Color3): void;
  100392. /**
  100393. * Hides the ray we are debugging.
  100394. */
  100395. hide(): void;
  100396. private _render;
  100397. /**
  100398. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  100399. * @param mesh Defines the mesh we want the helper attached to
  100400. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  100401. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  100402. * @param length Defines the length of the ray
  100403. */
  100404. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  100405. /**
  100406. * Detach the ray helper from the mesh it has previously been attached to.
  100407. */
  100408. detachFromMesh(): void;
  100409. private _updateToMesh;
  100410. /**
  100411. * Dispose the helper and release its associated resources.
  100412. */
  100413. dispose(): void;
  100414. }
  100415. }
  100416. declare module BABYLON.Debug {
  100417. /**
  100418. * Class used to render a debug view of a given skeleton
  100419. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  100420. */
  100421. export class SkeletonViewer {
  100422. /** defines the skeleton to render */
  100423. skeleton: Skeleton;
  100424. /** defines the mesh attached to the skeleton */
  100425. mesh: AbstractMesh;
  100426. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  100427. autoUpdateBonesMatrices: boolean;
  100428. /** defines the rendering group id to use with the viewer */
  100429. renderingGroupId: number;
  100430. /** Gets or sets the color used to render the skeleton */
  100431. color: Color3;
  100432. private _scene;
  100433. private _debugLines;
  100434. private _debugMesh;
  100435. private _isEnabled;
  100436. private _renderFunction;
  100437. private _utilityLayer;
  100438. /**
  100439. * Returns the mesh used to render the bones
  100440. */
  100441. readonly debugMesh: Nullable<LinesMesh>;
  100442. /**
  100443. * Creates a new SkeletonViewer
  100444. * @param skeleton defines the skeleton to render
  100445. * @param mesh defines the mesh attached to the skeleton
  100446. * @param scene defines the hosting scene
  100447. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  100448. * @param renderingGroupId defines the rendering group id to use with the viewer
  100449. */
  100450. constructor(
  100451. /** defines the skeleton to render */
  100452. skeleton: Skeleton,
  100453. /** defines the mesh attached to the skeleton */
  100454. mesh: AbstractMesh, scene: Scene,
  100455. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  100456. autoUpdateBonesMatrices?: boolean,
  100457. /** defines the rendering group id to use with the viewer */
  100458. renderingGroupId?: number);
  100459. /** Gets or sets a boolean indicating if the viewer is enabled */
  100460. isEnabled: boolean;
  100461. private _getBonePosition;
  100462. private _getLinesForBonesWithLength;
  100463. private _getLinesForBonesNoLength;
  100464. /** Update the viewer to sync with current skeleton state */
  100465. update(): void;
  100466. /** Release associated resources */
  100467. dispose(): void;
  100468. }
  100469. }
  100470. declare module BABYLON {
  100471. /**
  100472. * Options to create the null engine
  100473. */
  100474. export class NullEngineOptions {
  100475. /**
  100476. * Render width (Default: 512)
  100477. */
  100478. renderWidth: number;
  100479. /**
  100480. * Render height (Default: 256)
  100481. */
  100482. renderHeight: number;
  100483. /**
  100484. * Texture size (Default: 512)
  100485. */
  100486. textureSize: number;
  100487. /**
  100488. * If delta time between frames should be constant
  100489. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100490. */
  100491. deterministicLockstep: boolean;
  100492. /**
  100493. * Maximum about of steps between frames (Default: 4)
  100494. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100495. */
  100496. lockstepMaxSteps: number;
  100497. }
  100498. /**
  100499. * The null engine class provides support for headless version of babylon.js.
  100500. * This can be used in server side scenario or for testing purposes
  100501. */
  100502. export class NullEngine extends Engine {
  100503. private _options;
  100504. /**
  100505. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100506. */
  100507. isDeterministicLockStep(): boolean;
  100508. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  100509. getLockstepMaxSteps(): number;
  100510. /**
  100511. * Sets hardware scaling, used to save performance if needed
  100512. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100513. */
  100514. getHardwareScalingLevel(): number;
  100515. constructor(options?: NullEngineOptions);
  100516. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  100517. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  100518. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  100519. getRenderWidth(useScreen?: boolean): number;
  100520. getRenderHeight(useScreen?: boolean): number;
  100521. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  100522. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  100523. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  100524. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  100525. bindSamplers(effect: Effect): void;
  100526. enableEffect(effect: Effect): void;
  100527. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  100528. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  100529. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  100530. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  100531. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  100532. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  100533. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  100534. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  100535. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  100536. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  100537. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  100538. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  100539. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  100540. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  100541. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  100542. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  100543. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  100544. setFloat(uniform: WebGLUniformLocation, value: number): void;
  100545. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  100546. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  100547. setBool(uniform: WebGLUniformLocation, bool: number): void;
  100548. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  100549. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  100550. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  100551. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  100552. bindBuffers(vertexBuffers: {
  100553. [key: string]: VertexBuffer;
  100554. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  100555. wipeCaches(bruteForce?: boolean): void;
  100556. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  100557. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  100558. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  100559. /** @hidden */
  100560. _createTexture(): WebGLTexture;
  100561. /** @hidden */
  100562. _releaseTexture(texture: InternalTexture): void;
  100563. 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;
  100564. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  100565. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  100566. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  100567. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  100568. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  100569. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  100570. areAllEffectsReady(): boolean;
  100571. /**
  100572. * @hidden
  100573. * Get the current error code of the webGL context
  100574. * @returns the error code
  100575. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  100576. */
  100577. getError(): number;
  100578. /** @hidden */
  100579. _getUnpackAlignement(): number;
  100580. /** @hidden */
  100581. _unpackFlipY(value: boolean): void;
  100582. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  100583. /**
  100584. * Updates a dynamic vertex buffer.
  100585. * @param vertexBuffer the vertex buffer to update
  100586. * @param data the data used to update the vertex buffer
  100587. * @param byteOffset the byte offset of the data (optional)
  100588. * @param byteLength the byte length of the data (optional)
  100589. */
  100590. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  100591. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  100592. /** @hidden */
  100593. _bindTexture(channel: number, texture: InternalTexture): void;
  100594. /** @hidden */
  100595. _releaseBuffer(buffer: WebGLBuffer): boolean;
  100596. releaseEffects(): void;
  100597. displayLoadingUI(): void;
  100598. hideLoadingUI(): void;
  100599. /** @hidden */
  100600. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100601. /** @hidden */
  100602. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100603. /** @hidden */
  100604. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100605. /** @hidden */
  100606. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  100607. }
  100608. }
  100609. declare module BABYLON {
  100610. /** @hidden */
  100611. export class _OcclusionDataStorage {
  100612. /** @hidden */
  100613. occlusionInternalRetryCounter: number;
  100614. /** @hidden */
  100615. isOcclusionQueryInProgress: boolean;
  100616. /** @hidden */
  100617. isOccluded: boolean;
  100618. /** @hidden */
  100619. occlusionRetryCount: number;
  100620. /** @hidden */
  100621. occlusionType: number;
  100622. /** @hidden */
  100623. occlusionQueryAlgorithmType: number;
  100624. }
  100625. interface Engine {
  100626. /**
  100627. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  100628. * @return the new query
  100629. */
  100630. createQuery(): WebGLQuery;
  100631. /**
  100632. * Delete and release a webGL query
  100633. * @param query defines the query to delete
  100634. * @return the current engine
  100635. */
  100636. deleteQuery(query: WebGLQuery): Engine;
  100637. /**
  100638. * Check if a given query has resolved and got its value
  100639. * @param query defines the query to check
  100640. * @returns true if the query got its value
  100641. */
  100642. isQueryResultAvailable(query: WebGLQuery): boolean;
  100643. /**
  100644. * Gets the value of a given query
  100645. * @param query defines the query to check
  100646. * @returns the value of the query
  100647. */
  100648. getQueryResult(query: WebGLQuery): number;
  100649. /**
  100650. * Initiates an occlusion query
  100651. * @param algorithmType defines the algorithm to use
  100652. * @param query defines the query to use
  100653. * @returns the current engine
  100654. * @see http://doc.babylonjs.com/features/occlusionquery
  100655. */
  100656. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  100657. /**
  100658. * Ends an occlusion query
  100659. * @see http://doc.babylonjs.com/features/occlusionquery
  100660. * @param algorithmType defines the algorithm to use
  100661. * @returns the current engine
  100662. */
  100663. endOcclusionQuery(algorithmType: number): Engine;
  100664. /**
  100665. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  100666. * Please note that only one query can be issued at a time
  100667. * @returns a time token used to track the time span
  100668. */
  100669. startTimeQuery(): Nullable<_TimeToken>;
  100670. /**
  100671. * Ends a time query
  100672. * @param token defines the token used to measure the time span
  100673. * @returns the time spent (in ns)
  100674. */
  100675. endTimeQuery(token: _TimeToken): int;
  100676. /** @hidden */
  100677. _currentNonTimestampToken: Nullable<_TimeToken>;
  100678. /** @hidden */
  100679. _createTimeQuery(): WebGLQuery;
  100680. /** @hidden */
  100681. _deleteTimeQuery(query: WebGLQuery): void;
  100682. /** @hidden */
  100683. _getGlAlgorithmType(algorithmType: number): number;
  100684. /** @hidden */
  100685. _getTimeQueryResult(query: WebGLQuery): any;
  100686. /** @hidden */
  100687. _getTimeQueryAvailability(query: WebGLQuery): any;
  100688. }
  100689. interface AbstractMesh {
  100690. /**
  100691. * Backing filed
  100692. * @hidden
  100693. */
  100694. __occlusionDataStorage: _OcclusionDataStorage;
  100695. /**
  100696. * Access property
  100697. * @hidden
  100698. */
  100699. _occlusionDataStorage: _OcclusionDataStorage;
  100700. /**
  100701. * 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.
  100702. * The default value is -1 which means don't break the query and wait till the result
  100703. * @see http://doc.babylonjs.com/features/occlusionquery
  100704. */
  100705. occlusionRetryCount: number;
  100706. /**
  100707. * 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:
  100708. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  100709. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  100710. * * 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.
  100711. * @see http://doc.babylonjs.com/features/occlusionquery
  100712. */
  100713. occlusionType: number;
  100714. /**
  100715. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  100716. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  100717. * * 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.
  100718. * @see http://doc.babylonjs.com/features/occlusionquery
  100719. */
  100720. occlusionQueryAlgorithmType: number;
  100721. /**
  100722. * 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
  100723. * @see http://doc.babylonjs.com/features/occlusionquery
  100724. */
  100725. isOccluded: boolean;
  100726. /**
  100727. * Flag to check the progress status of the query
  100728. * @see http://doc.babylonjs.com/features/occlusionquery
  100729. */
  100730. isOcclusionQueryInProgress: boolean;
  100731. }
  100732. }
  100733. declare module BABYLON {
  100734. /** @hidden */
  100735. export var _forceTransformFeedbackToBundle: boolean;
  100736. interface Engine {
  100737. /**
  100738. * Creates a webGL transform feedback object
  100739. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  100740. * @returns the webGL transform feedback object
  100741. */
  100742. createTransformFeedback(): WebGLTransformFeedback;
  100743. /**
  100744. * Delete a webGL transform feedback object
  100745. * @param value defines the webGL transform feedback object to delete
  100746. */
  100747. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  100748. /**
  100749. * Bind a webGL transform feedback object to the webgl context
  100750. * @param value defines the webGL transform feedback object to bind
  100751. */
  100752. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  100753. /**
  100754. * Begins a transform feedback operation
  100755. * @param usePoints defines if points or triangles must be used
  100756. */
  100757. beginTransformFeedback(usePoints: boolean): void;
  100758. /**
  100759. * Ends a transform feedback operation
  100760. */
  100761. endTransformFeedback(): void;
  100762. /**
  100763. * Specify the varyings to use with transform feedback
  100764. * @param program defines the associated webGL program
  100765. * @param value defines the list of strings representing the varying names
  100766. */
  100767. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  100768. /**
  100769. * Bind a webGL buffer for a transform feedback operation
  100770. * @param value defines the webGL buffer to bind
  100771. */
  100772. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  100773. }
  100774. }
  100775. declare module BABYLON {
  100776. /**
  100777. * Gather the list of clipboard event types as constants.
  100778. */
  100779. export class ClipboardEventTypes {
  100780. /**
  100781. * The clipboard event is fired when a copy command is active (pressed).
  100782. */
  100783. static readonly COPY: number;
  100784. /**
  100785. * The clipboard event is fired when a cut command is active (pressed).
  100786. */
  100787. static readonly CUT: number;
  100788. /**
  100789. * The clipboard event is fired when a paste command is active (pressed).
  100790. */
  100791. static readonly PASTE: number;
  100792. }
  100793. /**
  100794. * This class is used to store clipboard related info for the onClipboardObservable event.
  100795. */
  100796. export class ClipboardInfo {
  100797. /**
  100798. * Defines the type of event (BABYLON.ClipboardEventTypes)
  100799. */
  100800. type: number;
  100801. /**
  100802. * Defines the related dom event
  100803. */
  100804. event: ClipboardEvent;
  100805. /**
  100806. *Creates an instance of ClipboardInfo.
  100807. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  100808. * @param event Defines the related dom event
  100809. */
  100810. constructor(
  100811. /**
  100812. * Defines the type of event (BABYLON.ClipboardEventTypes)
  100813. */
  100814. type: number,
  100815. /**
  100816. * Defines the related dom event
  100817. */
  100818. event: ClipboardEvent);
  100819. /**
  100820. * Get the clipboard event's type from the keycode.
  100821. * @param keyCode Defines the keyCode for the current keyboard event.
  100822. * @return {number}
  100823. */
  100824. static GetTypeFromCharacter(keyCode: number): number;
  100825. }
  100826. }
  100827. declare module BABYLON {
  100828. /**
  100829. * Class used to represent data loading progression
  100830. */
  100831. export class SceneLoaderProgressEvent {
  100832. /** defines if data length to load can be evaluated */
  100833. readonly lengthComputable: boolean;
  100834. /** defines the loaded data length */
  100835. readonly loaded: number;
  100836. /** defines the data length to load */
  100837. readonly total: number;
  100838. /**
  100839. * Create a new progress event
  100840. * @param lengthComputable defines if data length to load can be evaluated
  100841. * @param loaded defines the loaded data length
  100842. * @param total defines the data length to load
  100843. */
  100844. constructor(
  100845. /** defines if data length to load can be evaluated */
  100846. lengthComputable: boolean,
  100847. /** defines the loaded data length */
  100848. loaded: number,
  100849. /** defines the data length to load */
  100850. total: number);
  100851. /**
  100852. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  100853. * @param event defines the source event
  100854. * @returns a new SceneLoaderProgressEvent
  100855. */
  100856. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  100857. }
  100858. /**
  100859. * Interface used by SceneLoader plugins to define supported file extensions
  100860. */
  100861. export interface ISceneLoaderPluginExtensions {
  100862. /**
  100863. * Defines the list of supported extensions
  100864. */
  100865. [extension: string]: {
  100866. isBinary: boolean;
  100867. };
  100868. }
  100869. /**
  100870. * Interface used by SceneLoader plugin factory
  100871. */
  100872. export interface ISceneLoaderPluginFactory {
  100873. /**
  100874. * Defines the name of the factory
  100875. */
  100876. name: string;
  100877. /**
  100878. * Function called to create a new plugin
  100879. * @return the new plugin
  100880. */
  100881. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  100882. /**
  100883. * Boolean indicating if the plugin can direct load specific data
  100884. */
  100885. canDirectLoad?: (data: string) => boolean;
  100886. }
  100887. /**
  100888. * Interface used to define a SceneLoader plugin
  100889. */
  100890. export interface ISceneLoaderPlugin {
  100891. /**
  100892. * The friendly name of this plugin.
  100893. */
  100894. name: string;
  100895. /**
  100896. * The file extensions supported by this plugin.
  100897. */
  100898. extensions: string | ISceneLoaderPluginExtensions;
  100899. /**
  100900. * Import meshes into a scene.
  100901. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100902. * @param scene The scene to import into
  100903. * @param data The data to import
  100904. * @param rootUrl The root url for scene and resources
  100905. * @param meshes The meshes array to import into
  100906. * @param particleSystems The particle systems array to import into
  100907. * @param skeletons The skeletons array to import into
  100908. * @param onError The callback when import fails
  100909. * @returns True if successful or false otherwise
  100910. */
  100911. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  100912. /**
  100913. * Load into a scene.
  100914. * @param scene The scene to load into
  100915. * @param data The data to import
  100916. * @param rootUrl The root url for scene and resources
  100917. * @param onError The callback when import fails
  100918. * @returns true if successful or false otherwise
  100919. */
  100920. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  100921. /**
  100922. * The callback that returns true if the data can be directly loaded.
  100923. */
  100924. canDirectLoad?: (data: string) => boolean;
  100925. /**
  100926. * The callback that allows custom handling of the root url based on the response url.
  100927. */
  100928. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  100929. /**
  100930. * Load into an asset container.
  100931. * @param scene The scene to load into
  100932. * @param data The data to import
  100933. * @param rootUrl The root url for scene and resources
  100934. * @param onError The callback when import fails
  100935. * @returns The loaded asset container
  100936. */
  100937. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  100938. }
  100939. /**
  100940. * Interface used to define an async SceneLoader plugin
  100941. */
  100942. export interface ISceneLoaderPluginAsync {
  100943. /**
  100944. * The friendly name of this plugin.
  100945. */
  100946. name: string;
  100947. /**
  100948. * The file extensions supported by this plugin.
  100949. */
  100950. extensions: string | ISceneLoaderPluginExtensions;
  100951. /**
  100952. * Import meshes into a scene.
  100953. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100954. * @param scene The scene to import into
  100955. * @param data The data to import
  100956. * @param rootUrl The root url for scene and resources
  100957. * @param onProgress The callback when the load progresses
  100958. * @param fileName Defines the name of the file to load
  100959. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  100960. */
  100961. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  100962. meshes: AbstractMesh[];
  100963. particleSystems: IParticleSystem[];
  100964. skeletons: Skeleton[];
  100965. animationGroups: AnimationGroup[];
  100966. }>;
  100967. /**
  100968. * Load into a scene.
  100969. * @param scene The scene to load into
  100970. * @param data The data to import
  100971. * @param rootUrl The root url for scene and resources
  100972. * @param onProgress The callback when the load progresses
  100973. * @param fileName Defines the name of the file to load
  100974. * @returns Nothing
  100975. */
  100976. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  100977. /**
  100978. * The callback that returns true if the data can be directly loaded.
  100979. */
  100980. canDirectLoad?: (data: string) => boolean;
  100981. /**
  100982. * The callback that allows custom handling of the root url based on the response url.
  100983. */
  100984. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  100985. /**
  100986. * Load into an asset container.
  100987. * @param scene The scene to load into
  100988. * @param data The data to import
  100989. * @param rootUrl The root url for scene and resources
  100990. * @param onProgress The callback when the load progresses
  100991. * @param fileName Defines the name of the file to load
  100992. * @returns The loaded asset container
  100993. */
  100994. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  100995. }
  100996. /**
  100997. * Class used to load scene from various file formats using registered plugins
  100998. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  100999. */
  101000. export class SceneLoader {
  101001. /**
  101002. * No logging while loading
  101003. */
  101004. static readonly NO_LOGGING: number;
  101005. /**
  101006. * Minimal logging while loading
  101007. */
  101008. static readonly MINIMAL_LOGGING: number;
  101009. /**
  101010. * Summary logging while loading
  101011. */
  101012. static readonly SUMMARY_LOGGING: number;
  101013. /**
  101014. * Detailled logging while loading
  101015. */
  101016. static readonly DETAILED_LOGGING: number;
  101017. /**
  101018. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  101019. */
  101020. static ForceFullSceneLoadingForIncremental: boolean;
  101021. /**
  101022. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  101023. */
  101024. static ShowLoadingScreen: boolean;
  101025. /**
  101026. * Defines the current logging level (while loading the scene)
  101027. * @ignorenaming
  101028. */
  101029. static loggingLevel: number;
  101030. /**
  101031. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  101032. */
  101033. static CleanBoneMatrixWeights: boolean;
  101034. /**
  101035. * Event raised when a plugin is used to load a scene
  101036. */
  101037. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  101038. private static _registeredPlugins;
  101039. private static _getDefaultPlugin;
  101040. private static _getPluginForExtension;
  101041. private static _getPluginForDirectLoad;
  101042. private static _getPluginForFilename;
  101043. private static _getDirectLoad;
  101044. private static _loadData;
  101045. private static _getFileInfo;
  101046. /**
  101047. * Gets a plugin that can load the given extension
  101048. * @param extension defines the extension to load
  101049. * @returns a plugin or null if none works
  101050. */
  101051. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  101052. /**
  101053. * Gets a boolean indicating that the given extension can be loaded
  101054. * @param extension defines the extension to load
  101055. * @returns true if the extension is supported
  101056. */
  101057. static IsPluginForExtensionAvailable(extension: string): boolean;
  101058. /**
  101059. * Adds a new plugin to the list of registered plugins
  101060. * @param plugin defines the plugin to add
  101061. */
  101062. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  101063. /**
  101064. * Import meshes into a scene
  101065. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101066. * @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)
  101067. * @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)
  101068. * @param scene the instance of BABYLON.Scene to append to
  101069. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  101070. * @param onProgress a callback with a progress event for each file being loaded
  101071. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101072. * @param pluginExtension the extension used to determine the plugin
  101073. * @returns The loaded plugin
  101074. */
  101075. 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>;
  101076. /**
  101077. * Import meshes into a scene
  101078. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101079. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  101080. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  101081. * @param scene the instance of BABYLON.Scene to append to
  101082. * @param onProgress a callback with a progress event for each file being loaded
  101083. * @param pluginExtension the extension used to determine the plugin
  101084. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  101085. */
  101086. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  101087. meshes: AbstractMesh[];
  101088. particleSystems: IParticleSystem[];
  101089. skeletons: Skeleton[];
  101090. animationGroups: AnimationGroup[];
  101091. }>;
  101092. /**
  101093. * Load a scene
  101094. * @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)
  101095. * @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)
  101096. * @param engine is the instance of BABYLON.Engine to use to create the scene
  101097. * @param onSuccess a callback with the scene when import succeeds
  101098. * @param onProgress a callback with a progress event for each file being loaded
  101099. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101100. * @param pluginExtension the extension used to determine the plugin
  101101. * @returns The loaded plugin
  101102. */
  101103. 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>;
  101104. /**
  101105. * Load a scene
  101106. * @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)
  101107. * @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)
  101108. * @param engine is the instance of BABYLON.Engine to use to create the scene
  101109. * @param onProgress a callback with a progress event for each file being loaded
  101110. * @param pluginExtension the extension used to determine the plugin
  101111. * @returns The loaded scene
  101112. */
  101113. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  101114. /**
  101115. * Append a scene
  101116. * @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)
  101117. * @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)
  101118. * @param scene is the instance of BABYLON.Scene to append to
  101119. * @param onSuccess a callback with the scene when import succeeds
  101120. * @param onProgress a callback with a progress event for each file being loaded
  101121. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101122. * @param pluginExtension the extension used to determine the plugin
  101123. * @returns The loaded plugin
  101124. */
  101125. 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>;
  101126. /**
  101127. * Append a scene
  101128. * @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)
  101129. * @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)
  101130. * @param scene is the instance of BABYLON.Scene to append to
  101131. * @param onProgress a callback with a progress event for each file being loaded
  101132. * @param pluginExtension the extension used to determine the plugin
  101133. * @returns The given scene
  101134. */
  101135. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  101136. /**
  101137. * Load a scene into an asset container
  101138. * @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)
  101139. * @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)
  101140. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  101141. * @param onSuccess a callback with the scene when import succeeds
  101142. * @param onProgress a callback with a progress event for each file being loaded
  101143. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101144. * @param pluginExtension the extension used to determine the plugin
  101145. * @returns The loaded plugin
  101146. */
  101147. 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>;
  101148. /**
  101149. * Load a scene into an asset container
  101150. * @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)
  101151. * @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)
  101152. * @param scene is the instance of Scene to append to
  101153. * @param onProgress a callback with a progress event for each file being loaded
  101154. * @param pluginExtension the extension used to determine the plugin
  101155. * @returns The loaded asset container
  101156. */
  101157. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  101158. }
  101159. }
  101160. declare module BABYLON {
  101161. /**
  101162. * Google Daydream controller
  101163. */
  101164. export class DaydreamController extends WebVRController {
  101165. /**
  101166. * Base Url for the controller model.
  101167. */
  101168. static MODEL_BASE_URL: string;
  101169. /**
  101170. * File name for the controller model.
  101171. */
  101172. static MODEL_FILENAME: string;
  101173. /**
  101174. * Gamepad Id prefix used to identify Daydream Controller.
  101175. */
  101176. static readonly GAMEPAD_ID_PREFIX: string;
  101177. /**
  101178. * Creates a new DaydreamController from a gamepad
  101179. * @param vrGamepad the gamepad that the controller should be created from
  101180. */
  101181. constructor(vrGamepad: any);
  101182. /**
  101183. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101184. * @param scene scene in which to add meshes
  101185. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101186. */
  101187. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101188. /**
  101189. * Called once for each button that changed state since the last frame
  101190. * @param buttonIdx Which button index changed
  101191. * @param state New state of the button
  101192. * @param changes Which properties on the state changed since last frame
  101193. */
  101194. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101195. }
  101196. }
  101197. declare module BABYLON {
  101198. /**
  101199. * Gear VR Controller
  101200. */
  101201. export class GearVRController extends WebVRController {
  101202. /**
  101203. * Base Url for the controller model.
  101204. */
  101205. static MODEL_BASE_URL: string;
  101206. /**
  101207. * File name for the controller model.
  101208. */
  101209. static MODEL_FILENAME: string;
  101210. /**
  101211. * Gamepad Id prefix used to identify this controller.
  101212. */
  101213. static readonly GAMEPAD_ID_PREFIX: string;
  101214. private readonly _buttonIndexToObservableNameMap;
  101215. /**
  101216. * Creates a new GearVRController from a gamepad
  101217. * @param vrGamepad the gamepad that the controller should be created from
  101218. */
  101219. constructor(vrGamepad: any);
  101220. /**
  101221. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101222. * @param scene scene in which to add meshes
  101223. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101224. */
  101225. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101226. /**
  101227. * Called once for each button that changed state since the last frame
  101228. * @param buttonIdx Which button index changed
  101229. * @param state New state of the button
  101230. * @param changes Which properties on the state changed since last frame
  101231. */
  101232. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101233. }
  101234. }
  101235. declare module BABYLON {
  101236. /**
  101237. * Generic Controller
  101238. */
  101239. export class GenericController extends WebVRController {
  101240. /**
  101241. * Base Url for the controller model.
  101242. */
  101243. static readonly MODEL_BASE_URL: string;
  101244. /**
  101245. * File name for the controller model.
  101246. */
  101247. static readonly MODEL_FILENAME: string;
  101248. /**
  101249. * Creates a new GenericController from a gamepad
  101250. * @param vrGamepad the gamepad that the controller should be created from
  101251. */
  101252. constructor(vrGamepad: any);
  101253. /**
  101254. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101255. * @param scene scene in which to add meshes
  101256. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101257. */
  101258. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101259. /**
  101260. * Called once for each button that changed state since the last frame
  101261. * @param buttonIdx Which button index changed
  101262. * @param state New state of the button
  101263. * @param changes Which properties on the state changed since last frame
  101264. */
  101265. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101266. }
  101267. }
  101268. declare module BABYLON {
  101269. /**
  101270. * Oculus Touch Controller
  101271. */
  101272. export class OculusTouchController extends WebVRController {
  101273. /**
  101274. * Base Url for the controller model.
  101275. */
  101276. static MODEL_BASE_URL: string;
  101277. /**
  101278. * File name for the left controller model.
  101279. */
  101280. static MODEL_LEFT_FILENAME: string;
  101281. /**
  101282. * File name for the right controller model.
  101283. */
  101284. static MODEL_RIGHT_FILENAME: string;
  101285. /**
  101286. * Fired when the secondary trigger on this controller is modified
  101287. */
  101288. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  101289. /**
  101290. * Fired when the thumb rest on this controller is modified
  101291. */
  101292. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  101293. /**
  101294. * Creates a new OculusTouchController from a gamepad
  101295. * @param vrGamepad the gamepad that the controller should be created from
  101296. */
  101297. constructor(vrGamepad: any);
  101298. /**
  101299. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101300. * @param scene scene in which to add meshes
  101301. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101302. */
  101303. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101304. /**
  101305. * Fired when the A button on this controller is modified
  101306. */
  101307. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101308. /**
  101309. * Fired when the B button on this controller is modified
  101310. */
  101311. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101312. /**
  101313. * Fired when the X button on this controller is modified
  101314. */
  101315. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101316. /**
  101317. * Fired when the Y button on this controller is modified
  101318. */
  101319. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101320. /**
  101321. * Called once for each button that changed state since the last frame
  101322. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  101323. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  101324. * 2) secondary trigger (same)
  101325. * 3) A (right) X (left), touch, pressed = value
  101326. * 4) B / Y
  101327. * 5) thumb rest
  101328. * @param buttonIdx Which button index changed
  101329. * @param state New state of the button
  101330. * @param changes Which properties on the state changed since last frame
  101331. */
  101332. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101333. }
  101334. }
  101335. declare module BABYLON {
  101336. /**
  101337. * Vive Controller
  101338. */
  101339. export class ViveController extends WebVRController {
  101340. /**
  101341. * Base Url for the controller model.
  101342. */
  101343. static MODEL_BASE_URL: string;
  101344. /**
  101345. * File name for the controller model.
  101346. */
  101347. static MODEL_FILENAME: string;
  101348. /**
  101349. * Creates a new ViveController from a gamepad
  101350. * @param vrGamepad the gamepad that the controller should be created from
  101351. */
  101352. constructor(vrGamepad: any);
  101353. /**
  101354. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101355. * @param scene scene in which to add meshes
  101356. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101357. */
  101358. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101359. /**
  101360. * Fired when the left button on this controller is modified
  101361. */
  101362. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101363. /**
  101364. * Fired when the right button on this controller is modified
  101365. */
  101366. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101367. /**
  101368. * Fired when the menu button on this controller is modified
  101369. */
  101370. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101371. /**
  101372. * Called once for each button that changed state since the last frame
  101373. * Vive mapping:
  101374. * 0: touchpad
  101375. * 1: trigger
  101376. * 2: left AND right buttons
  101377. * 3: menu button
  101378. * @param buttonIdx Which button index changed
  101379. * @param state New state of the button
  101380. * @param changes Which properties on the state changed since last frame
  101381. */
  101382. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101383. }
  101384. }
  101385. declare module BABYLON {
  101386. /**
  101387. * Defines the WindowsMotionController object that the state of the windows motion controller
  101388. */
  101389. export class WindowsMotionController extends WebVRController {
  101390. /**
  101391. * The base url used to load the left and right controller models
  101392. */
  101393. static MODEL_BASE_URL: string;
  101394. /**
  101395. * The name of the left controller model file
  101396. */
  101397. static MODEL_LEFT_FILENAME: string;
  101398. /**
  101399. * The name of the right controller model file
  101400. */
  101401. static MODEL_RIGHT_FILENAME: string;
  101402. /**
  101403. * The controller name prefix for this controller type
  101404. */
  101405. static readonly GAMEPAD_ID_PREFIX: string;
  101406. /**
  101407. * The controller id pattern for this controller type
  101408. */
  101409. private static readonly GAMEPAD_ID_PATTERN;
  101410. private _loadedMeshInfo;
  101411. private readonly _mapping;
  101412. /**
  101413. * Fired when the trackpad on this controller is clicked
  101414. */
  101415. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  101416. /**
  101417. * Fired when the trackpad on this controller is modified
  101418. */
  101419. onTrackpadValuesChangedObservable: Observable<StickValues>;
  101420. /**
  101421. * The current x and y values of this controller's trackpad
  101422. */
  101423. trackpad: StickValues;
  101424. /**
  101425. * Creates a new WindowsMotionController from a gamepad
  101426. * @param vrGamepad the gamepad that the controller should be created from
  101427. */
  101428. constructor(vrGamepad: any);
  101429. /**
  101430. * Fired when the trigger on this controller is modified
  101431. */
  101432. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101433. /**
  101434. * Fired when the menu button on this controller is modified
  101435. */
  101436. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101437. /**
  101438. * Fired when the grip button on this controller is modified
  101439. */
  101440. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101441. /**
  101442. * Fired when the thumbstick button on this controller is modified
  101443. */
  101444. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101445. /**
  101446. * Fired when the touchpad button on this controller is modified
  101447. */
  101448. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101449. /**
  101450. * Fired when the touchpad values on this controller are modified
  101451. */
  101452. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  101453. private _updateTrackpad;
  101454. /**
  101455. * Called once per frame by the engine.
  101456. */
  101457. update(): void;
  101458. /**
  101459. * Called once for each button that changed state since the last frame
  101460. * @param buttonIdx Which button index changed
  101461. * @param state New state of the button
  101462. * @param changes Which properties on the state changed since last frame
  101463. */
  101464. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101465. /**
  101466. * Moves the buttons on the controller mesh based on their current state
  101467. * @param buttonName the name of the button to move
  101468. * @param buttonValue the value of the button which determines the buttons new position
  101469. */
  101470. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  101471. /**
  101472. * Moves the axis on the controller mesh based on its current state
  101473. * @param axis the index of the axis
  101474. * @param axisValue the value of the axis which determines the meshes new position
  101475. * @hidden
  101476. */
  101477. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  101478. /**
  101479. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101480. * @param scene scene in which to add meshes
  101481. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101482. */
  101483. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  101484. /**
  101485. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  101486. * can be transformed by button presses and axes values, based on this._mapping.
  101487. *
  101488. * @param scene scene in which the meshes exist
  101489. * @param meshes list of meshes that make up the controller model to process
  101490. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  101491. */
  101492. private processModel;
  101493. private createMeshInfo;
  101494. /**
  101495. * Gets the ray of the controller in the direction the controller is pointing
  101496. * @param length the length the resulting ray should be
  101497. * @returns a ray in the direction the controller is pointing
  101498. */
  101499. getForwardRay(length?: number): Ray;
  101500. /**
  101501. * Disposes of the controller
  101502. */
  101503. dispose(): void;
  101504. }
  101505. }
  101506. declare module BABYLON {
  101507. /**
  101508. * Single axis scale gizmo
  101509. */
  101510. export class AxisScaleGizmo extends Gizmo {
  101511. private _coloredMaterial;
  101512. /**
  101513. * Drag behavior responsible for the gizmos dragging interactions
  101514. */
  101515. dragBehavior: PointerDragBehavior;
  101516. private _pointerObserver;
  101517. /**
  101518. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101519. */
  101520. snapDistance: number;
  101521. /**
  101522. * Event that fires each time the gizmo snaps to a new location.
  101523. * * snapDistance is the the change in distance
  101524. */
  101525. onSnapObservable: Observable<{
  101526. snapDistance: number;
  101527. }>;
  101528. /**
  101529. * If the scaling operation should be done on all axis (default: false)
  101530. */
  101531. uniformScaling: boolean;
  101532. /**
  101533. * Creates an AxisScaleGizmo
  101534. * @param gizmoLayer The utility layer the gizmo will be added to
  101535. * @param dragAxis The axis which the gizmo will be able to scale on
  101536. * @param color The color of the gizmo
  101537. */
  101538. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  101539. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101540. /**
  101541. * Disposes of the gizmo
  101542. */
  101543. dispose(): void;
  101544. /**
  101545. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  101546. * @param mesh The mesh to replace the default mesh of the gizmo
  101547. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  101548. */
  101549. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  101550. }
  101551. }
  101552. declare module BABYLON {
  101553. /**
  101554. * Bounding box gizmo
  101555. */
  101556. export class BoundingBoxGizmo extends Gizmo {
  101557. private _lineBoundingBox;
  101558. private _rotateSpheresParent;
  101559. private _scaleBoxesParent;
  101560. private _boundingDimensions;
  101561. private _renderObserver;
  101562. private _pointerObserver;
  101563. private _scaleDragSpeed;
  101564. private _tmpQuaternion;
  101565. private _tmpVector;
  101566. private _tmpRotationMatrix;
  101567. /**
  101568. * 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)
  101569. */
  101570. ignoreChildren: boolean;
  101571. /**
  101572. * 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)
  101573. */
  101574. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  101575. /**
  101576. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  101577. */
  101578. rotationSphereSize: number;
  101579. /**
  101580. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  101581. */
  101582. scaleBoxSize: number;
  101583. /**
  101584. * 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)
  101585. */
  101586. fixedDragMeshScreenSize: boolean;
  101587. /**
  101588. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  101589. */
  101590. fixedDragMeshScreenSizeDistanceFactor: number;
  101591. /**
  101592. * Fired when a rotation sphere or scale box is dragged
  101593. */
  101594. onDragStartObservable: Observable<{}>;
  101595. /**
  101596. * Fired when a scale box is dragged
  101597. */
  101598. onScaleBoxDragObservable: Observable<{}>;
  101599. /**
  101600. * Fired when a scale box drag is ended
  101601. */
  101602. onScaleBoxDragEndObservable: Observable<{}>;
  101603. /**
  101604. * Fired when a rotation sphere is dragged
  101605. */
  101606. onRotationSphereDragObservable: Observable<{}>;
  101607. /**
  101608. * Fired when a rotation sphere drag is ended
  101609. */
  101610. onRotationSphereDragEndObservable: Observable<{}>;
  101611. /**
  101612. * 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)
  101613. */
  101614. scalePivot: Nullable<Vector3>;
  101615. private _anchorMesh;
  101616. private _existingMeshScale;
  101617. private _dragMesh;
  101618. private pointerDragBehavior;
  101619. private coloredMaterial;
  101620. private hoverColoredMaterial;
  101621. /**
  101622. * Sets the color of the bounding box gizmo
  101623. * @param color the color to set
  101624. */
  101625. setColor(color: Color3): void;
  101626. /**
  101627. * Creates an BoundingBoxGizmo
  101628. * @param gizmoLayer The utility layer the gizmo will be added to
  101629. * @param color The color of the gizmo
  101630. */
  101631. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  101632. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101633. private _selectNode;
  101634. /**
  101635. * Updates the bounding box information for the Gizmo
  101636. */
  101637. updateBoundingBox(): void;
  101638. private _updateRotationSpheres;
  101639. private _updateScaleBoxes;
  101640. /**
  101641. * Enables rotation on the specified axis and disables rotation on the others
  101642. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  101643. */
  101644. setEnabledRotationAxis(axis: string): void;
  101645. /**
  101646. * Enables/disables scaling
  101647. * @param enable if scaling should be enabled
  101648. */
  101649. setEnabledScaling(enable: boolean): void;
  101650. private _updateDummy;
  101651. /**
  101652. * Enables a pointer drag behavior on the bounding box of the gizmo
  101653. */
  101654. enableDragBehavior(): void;
  101655. /**
  101656. * Disposes of the gizmo
  101657. */
  101658. dispose(): void;
  101659. /**
  101660. * 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)
  101661. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  101662. * @returns the bounding box mesh with the passed in mesh as a child
  101663. */
  101664. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  101665. /**
  101666. * CustomMeshes are not supported by this gizmo
  101667. * @param mesh The mesh to replace the default mesh of the gizmo
  101668. */
  101669. setCustomMesh(mesh: Mesh): void;
  101670. }
  101671. }
  101672. declare module BABYLON {
  101673. /**
  101674. * Single plane rotation gizmo
  101675. */
  101676. export class PlaneRotationGizmo extends Gizmo {
  101677. /**
  101678. * Drag behavior responsible for the gizmos dragging interactions
  101679. */
  101680. dragBehavior: PointerDragBehavior;
  101681. private _pointerObserver;
  101682. /**
  101683. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  101684. */
  101685. snapDistance: number;
  101686. /**
  101687. * Event that fires each time the gizmo snaps to a new location.
  101688. * * snapDistance is the the change in distance
  101689. */
  101690. onSnapObservable: Observable<{
  101691. snapDistance: number;
  101692. }>;
  101693. /**
  101694. * Creates a PlaneRotationGizmo
  101695. * @param gizmoLayer The utility layer the gizmo will be added to
  101696. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  101697. * @param color The color of the gizmo
  101698. * @param tessellation Amount of tessellation to be used when creating rotation circles
  101699. */
  101700. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  101701. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101702. /**
  101703. * Disposes of the gizmo
  101704. */
  101705. dispose(): void;
  101706. }
  101707. }
  101708. declare module BABYLON {
  101709. /**
  101710. * Gizmo that enables rotating a mesh along 3 axis
  101711. */
  101712. export class RotationGizmo extends Gizmo {
  101713. /**
  101714. * Internal gizmo used for interactions on the x axis
  101715. */
  101716. xGizmo: PlaneRotationGizmo;
  101717. /**
  101718. * Internal gizmo used for interactions on the y axis
  101719. */
  101720. yGizmo: PlaneRotationGizmo;
  101721. /**
  101722. * Internal gizmo used for interactions on the z axis
  101723. */
  101724. zGizmo: PlaneRotationGizmo;
  101725. /** Fires an event when any of it's sub gizmos are dragged */
  101726. onDragStartObservable: Observable<{}>;
  101727. /** Fires an event when any of it's sub gizmos are released from dragging */
  101728. onDragEndObservable: Observable<{}>;
  101729. attachedMesh: Nullable<AbstractMesh>;
  101730. /**
  101731. * Creates a RotationGizmo
  101732. * @param gizmoLayer The utility layer the gizmo will be added to
  101733. * @param tessellation Amount of tessellation to be used when creating rotation circles
  101734. */
  101735. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  101736. updateGizmoRotationToMatchAttachedMesh: boolean;
  101737. /**
  101738. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101739. */
  101740. snapDistance: number;
  101741. /**
  101742. * Ratio for the scale of the gizmo (Default: 1)
  101743. */
  101744. scaleRatio: number;
  101745. /**
  101746. * Disposes of the gizmo
  101747. */
  101748. dispose(): void;
  101749. /**
  101750. * CustomMeshes are not supported by this gizmo
  101751. * @param mesh The mesh to replace the default mesh of the gizmo
  101752. */
  101753. setCustomMesh(mesh: Mesh): void;
  101754. }
  101755. }
  101756. declare module BABYLON {
  101757. /**
  101758. * Gizmo that enables dragging a mesh along 3 axis
  101759. */
  101760. export class PositionGizmo extends Gizmo {
  101761. /**
  101762. * Internal gizmo used for interactions on the x axis
  101763. */
  101764. xGizmo: AxisDragGizmo;
  101765. /**
  101766. * Internal gizmo used for interactions on the y axis
  101767. */
  101768. yGizmo: AxisDragGizmo;
  101769. /**
  101770. * Internal gizmo used for interactions on the z axis
  101771. */
  101772. zGizmo: AxisDragGizmo;
  101773. /** Fires an event when any of it's sub gizmos are dragged */
  101774. onDragStartObservable: Observable<{}>;
  101775. /** Fires an event when any of it's sub gizmos are released from dragging */
  101776. onDragEndObservable: Observable<{}>;
  101777. attachedMesh: Nullable<AbstractMesh>;
  101778. /**
  101779. * Creates a PositionGizmo
  101780. * @param gizmoLayer The utility layer the gizmo will be added to
  101781. */
  101782. constructor(gizmoLayer?: UtilityLayerRenderer);
  101783. updateGizmoRotationToMatchAttachedMesh: boolean;
  101784. /**
  101785. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101786. */
  101787. snapDistance: number;
  101788. /**
  101789. * Ratio for the scale of the gizmo (Default: 1)
  101790. */
  101791. scaleRatio: number;
  101792. /**
  101793. * Disposes of the gizmo
  101794. */
  101795. dispose(): void;
  101796. /**
  101797. * CustomMeshes are not supported by this gizmo
  101798. * @param mesh The mesh to replace the default mesh of the gizmo
  101799. */
  101800. setCustomMesh(mesh: Mesh): void;
  101801. }
  101802. }
  101803. declare module BABYLON {
  101804. /**
  101805. * Class containing static functions to help procedurally build meshes
  101806. */
  101807. export class PolyhedronBuilder {
  101808. /**
  101809. * Creates a polyhedron mesh
  101810. * * 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
  101811. * * The parameter `size` (positive float, default 1) sets the polygon size
  101812. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  101813. * * 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`
  101814. * * 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
  101815. * * 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)`)
  101816. * * 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
  101817. * * 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
  101818. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101819. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101821. * @param name defines the name of the mesh
  101822. * @param options defines the options used to create the mesh
  101823. * @param scene defines the hosting scene
  101824. * @returns the polyhedron mesh
  101825. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  101826. */
  101827. static CreatePolyhedron(name: string, options: {
  101828. type?: number;
  101829. size?: number;
  101830. sizeX?: number;
  101831. sizeY?: number;
  101832. sizeZ?: number;
  101833. custom?: any;
  101834. faceUV?: Vector4[];
  101835. faceColors?: Color4[];
  101836. flat?: boolean;
  101837. updatable?: boolean;
  101838. sideOrientation?: number;
  101839. frontUVs?: Vector4;
  101840. backUVs?: Vector4;
  101841. }, scene?: Nullable<Scene>): Mesh;
  101842. }
  101843. }
  101844. declare module BABYLON {
  101845. /**
  101846. * Gizmo that enables scaling a mesh along 3 axis
  101847. */
  101848. export class ScaleGizmo extends Gizmo {
  101849. /**
  101850. * Internal gizmo used for interactions on the x axis
  101851. */
  101852. xGizmo: AxisScaleGizmo;
  101853. /**
  101854. * Internal gizmo used for interactions on the y axis
  101855. */
  101856. yGizmo: AxisScaleGizmo;
  101857. /**
  101858. * Internal gizmo used for interactions on the z axis
  101859. */
  101860. zGizmo: AxisScaleGizmo;
  101861. /**
  101862. * Internal gizmo used to scale all axis equally
  101863. */
  101864. uniformScaleGizmo: AxisScaleGizmo;
  101865. /** Fires an event when any of it's sub gizmos are dragged */
  101866. onDragStartObservable: Observable<{}>;
  101867. /** Fires an event when any of it's sub gizmos are released from dragging */
  101868. onDragEndObservable: Observable<{}>;
  101869. attachedMesh: Nullable<AbstractMesh>;
  101870. /**
  101871. * Creates a ScaleGizmo
  101872. * @param gizmoLayer The utility layer the gizmo will be added to
  101873. */
  101874. constructor(gizmoLayer?: UtilityLayerRenderer);
  101875. updateGizmoRotationToMatchAttachedMesh: boolean;
  101876. /**
  101877. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101878. */
  101879. snapDistance: number;
  101880. /**
  101881. * Ratio for the scale of the gizmo (Default: 1)
  101882. */
  101883. scaleRatio: number;
  101884. /**
  101885. * Disposes of the gizmo
  101886. */
  101887. dispose(): void;
  101888. }
  101889. }
  101890. declare module BABYLON {
  101891. /**
  101892. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  101893. */
  101894. export class GizmoManager implements IDisposable {
  101895. private scene;
  101896. /**
  101897. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  101898. */
  101899. gizmos: {
  101900. positionGizmo: Nullable<PositionGizmo>;
  101901. rotationGizmo: Nullable<RotationGizmo>;
  101902. scaleGizmo: Nullable<ScaleGizmo>;
  101903. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  101904. };
  101905. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  101906. clearGizmoOnEmptyPointerEvent: boolean;
  101907. /** Fires an event when the manager is attached to a mesh */
  101908. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  101909. private _gizmosEnabled;
  101910. private _pointerObserver;
  101911. private _attachedMesh;
  101912. private _boundingBoxColor;
  101913. private _defaultUtilityLayer;
  101914. private _defaultKeepDepthUtilityLayer;
  101915. /**
  101916. * When bounding box gizmo is enabled, this can be used to track drag/end events
  101917. */
  101918. boundingBoxDragBehavior: SixDofDragBehavior;
  101919. /**
  101920. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  101921. */
  101922. attachableMeshes: Nullable<Array<AbstractMesh>>;
  101923. /**
  101924. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  101925. */
  101926. usePointerToAttachGizmos: boolean;
  101927. /**
  101928. * Instatiates a gizmo manager
  101929. * @param scene the scene to overlay the gizmos on top of
  101930. */
  101931. constructor(scene: Scene);
  101932. /**
  101933. * Attaches a set of gizmos to the specified mesh
  101934. * @param mesh The mesh the gizmo's should be attached to
  101935. */
  101936. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  101937. /**
  101938. * If the position gizmo is enabled
  101939. */
  101940. positionGizmoEnabled: boolean;
  101941. /**
  101942. * If the rotation gizmo is enabled
  101943. */
  101944. rotationGizmoEnabled: boolean;
  101945. /**
  101946. * If the scale gizmo is enabled
  101947. */
  101948. scaleGizmoEnabled: boolean;
  101949. /**
  101950. * If the boundingBox gizmo is enabled
  101951. */
  101952. boundingBoxGizmoEnabled: boolean;
  101953. /**
  101954. * Disposes of the gizmo manager
  101955. */
  101956. dispose(): void;
  101957. }
  101958. }
  101959. declare module BABYLON {
  101960. /**
  101961. * A directional light is defined by a direction (what a surprise!).
  101962. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  101963. * 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.
  101964. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101965. */
  101966. export class DirectionalLight extends ShadowLight {
  101967. private _shadowFrustumSize;
  101968. /**
  101969. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  101970. */
  101971. /**
  101972. * Specifies a fix frustum size for the shadow generation.
  101973. */
  101974. shadowFrustumSize: number;
  101975. private _shadowOrthoScale;
  101976. /**
  101977. * Gets the shadow projection scale against the optimal computed one.
  101978. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101979. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101980. */
  101981. /**
  101982. * Sets the shadow projection scale against the optimal computed one.
  101983. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101984. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101985. */
  101986. shadowOrthoScale: number;
  101987. /**
  101988. * Automatically compute the projection matrix to best fit (including all the casters)
  101989. * on each frame.
  101990. */
  101991. autoUpdateExtends: boolean;
  101992. private _orthoLeft;
  101993. private _orthoRight;
  101994. private _orthoTop;
  101995. private _orthoBottom;
  101996. /**
  101997. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  101998. * The directional light is emitted from everywhere in the given direction.
  101999. * It can cast shadows.
  102000. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102001. * @param name The friendly name of the light
  102002. * @param direction The direction of the light
  102003. * @param scene The scene the light belongs to
  102004. */
  102005. constructor(name: string, direction: Vector3, scene: Scene);
  102006. /**
  102007. * Returns the string "DirectionalLight".
  102008. * @return The class name
  102009. */
  102010. getClassName(): string;
  102011. /**
  102012. * Returns the integer 1.
  102013. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102014. */
  102015. getTypeID(): number;
  102016. /**
  102017. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  102018. * Returns the DirectionalLight Shadow projection matrix.
  102019. */
  102020. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102021. /**
  102022. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  102023. * Returns the DirectionalLight Shadow projection matrix.
  102024. */
  102025. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  102026. /**
  102027. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  102028. * Returns the DirectionalLight Shadow projection matrix.
  102029. */
  102030. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102031. protected _buildUniformLayout(): void;
  102032. /**
  102033. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  102034. * @param effect The effect to update
  102035. * @param lightIndex The index of the light in the effect to update
  102036. * @returns The directional light
  102037. */
  102038. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  102039. /**
  102040. * Gets the minZ used for shadow according to both the scene and the light.
  102041. *
  102042. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102043. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102044. * @param activeCamera The camera we are returning the min for
  102045. * @returns the depth min z
  102046. */
  102047. getDepthMinZ(activeCamera: Camera): number;
  102048. /**
  102049. * Gets the maxZ used for shadow according to both the scene and the light.
  102050. *
  102051. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102052. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102053. * @param activeCamera The camera we are returning the max for
  102054. * @returns the depth max z
  102055. */
  102056. getDepthMaxZ(activeCamera: Camera): number;
  102057. /**
  102058. * Prepares the list of defines specific to the light type.
  102059. * @param defines the list of defines
  102060. * @param lightIndex defines the index of the light for the effect
  102061. */
  102062. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102063. }
  102064. }
  102065. declare module BABYLON {
  102066. /**
  102067. * Class containing static functions to help procedurally build meshes
  102068. */
  102069. export class HemisphereBuilder {
  102070. /**
  102071. * Creates a hemisphere mesh
  102072. * @param name defines the name of the mesh
  102073. * @param options defines the options used to create the mesh
  102074. * @param scene defines the hosting scene
  102075. * @returns the hemisphere mesh
  102076. */
  102077. static CreateHemisphere(name: string, options: {
  102078. segments?: number;
  102079. diameter?: number;
  102080. sideOrientation?: number;
  102081. }, scene: any): Mesh;
  102082. }
  102083. }
  102084. declare module BABYLON {
  102085. /**
  102086. * A spot light is defined by a position, a direction, an angle, and an exponent.
  102087. * These values define a cone of light starting from the position, emitting toward the direction.
  102088. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  102089. * and the exponent defines the speed of the decay of the light with distance (reach).
  102090. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102091. */
  102092. export class SpotLight extends ShadowLight {
  102093. private _angle;
  102094. private _innerAngle;
  102095. private _cosHalfAngle;
  102096. private _lightAngleScale;
  102097. private _lightAngleOffset;
  102098. /**
  102099. * Gets the cone angle of the spot light in Radians.
  102100. */
  102101. /**
  102102. * Sets the cone angle of the spot light in Radians.
  102103. */
  102104. angle: number;
  102105. /**
  102106. * Only used in gltf falloff mode, this defines the angle where
  102107. * the directional falloff will start before cutting at angle which could be seen
  102108. * as outer angle.
  102109. */
  102110. /**
  102111. * Only used in gltf falloff mode, this defines the angle where
  102112. * the directional falloff will start before cutting at angle which could be seen
  102113. * as outer angle.
  102114. */
  102115. innerAngle: number;
  102116. private _shadowAngleScale;
  102117. /**
  102118. * Allows scaling the angle of the light for shadow generation only.
  102119. */
  102120. /**
  102121. * Allows scaling the angle of the light for shadow generation only.
  102122. */
  102123. shadowAngleScale: number;
  102124. /**
  102125. * The light decay speed with the distance from the emission spot.
  102126. */
  102127. exponent: number;
  102128. private _projectionTextureMatrix;
  102129. /**
  102130. * Allows reading the projecton texture
  102131. */
  102132. readonly projectionTextureMatrix: Matrix;
  102133. protected _projectionTextureLightNear: number;
  102134. /**
  102135. * Gets the near clip of the Spotlight for texture projection.
  102136. */
  102137. /**
  102138. * Sets the near clip of the Spotlight for texture projection.
  102139. */
  102140. projectionTextureLightNear: number;
  102141. protected _projectionTextureLightFar: number;
  102142. /**
  102143. * Gets the far clip of the Spotlight for texture projection.
  102144. */
  102145. /**
  102146. * Sets the far clip of the Spotlight for texture projection.
  102147. */
  102148. projectionTextureLightFar: number;
  102149. protected _projectionTextureUpDirection: Vector3;
  102150. /**
  102151. * Gets the Up vector of the Spotlight for texture projection.
  102152. */
  102153. /**
  102154. * Sets the Up vector of the Spotlight for texture projection.
  102155. */
  102156. projectionTextureUpDirection: Vector3;
  102157. private _projectionTexture;
  102158. /**
  102159. * Gets the projection texture of the light.
  102160. */
  102161. /**
  102162. * Sets the projection texture of the light.
  102163. */
  102164. projectionTexture: Nullable<BaseTexture>;
  102165. private _projectionTextureViewLightDirty;
  102166. private _projectionTextureProjectionLightDirty;
  102167. private _projectionTextureDirty;
  102168. private _projectionTextureViewTargetVector;
  102169. private _projectionTextureViewLightMatrix;
  102170. private _projectionTextureProjectionLightMatrix;
  102171. private _projectionTextureScalingMatrix;
  102172. /**
  102173. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  102174. * It can cast shadows.
  102175. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102176. * @param name The light friendly name
  102177. * @param position The position of the spot light in the scene
  102178. * @param direction The direction of the light in the scene
  102179. * @param angle The cone angle of the light in Radians
  102180. * @param exponent The light decay speed with the distance from the emission spot
  102181. * @param scene The scene the lights belongs to
  102182. */
  102183. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  102184. /**
  102185. * Returns the string "SpotLight".
  102186. * @returns the class name
  102187. */
  102188. getClassName(): string;
  102189. /**
  102190. * Returns the integer 2.
  102191. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102192. */
  102193. getTypeID(): number;
  102194. /**
  102195. * Overrides the direction setter to recompute the projection texture view light Matrix.
  102196. */
  102197. protected _setDirection(value: Vector3): void;
  102198. /**
  102199. * Overrides the position setter to recompute the projection texture view light Matrix.
  102200. */
  102201. protected _setPosition(value: Vector3): void;
  102202. /**
  102203. * 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.
  102204. * Returns the SpotLight.
  102205. */
  102206. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102207. protected _computeProjectionTextureViewLightMatrix(): void;
  102208. protected _computeProjectionTextureProjectionLightMatrix(): void;
  102209. /**
  102210. * Main function for light texture projection matrix computing.
  102211. */
  102212. protected _computeProjectionTextureMatrix(): void;
  102213. protected _buildUniformLayout(): void;
  102214. private _computeAngleValues;
  102215. /**
  102216. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  102217. * @param effect The effect to update
  102218. * @param lightIndex The index of the light in the effect to update
  102219. * @returns The spot light
  102220. */
  102221. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  102222. /**
  102223. * Disposes the light and the associated resources.
  102224. */
  102225. dispose(): void;
  102226. /**
  102227. * Prepares the list of defines specific to the light type.
  102228. * @param defines the list of defines
  102229. * @param lightIndex defines the index of the light for the effect
  102230. */
  102231. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102232. }
  102233. }
  102234. declare module BABYLON {
  102235. /**
  102236. * Gizmo that enables viewing a light
  102237. */
  102238. export class LightGizmo extends Gizmo {
  102239. private _lightMesh;
  102240. private _material;
  102241. /**
  102242. * Creates a LightGizmo
  102243. * @param gizmoLayer The utility layer the gizmo will be added to
  102244. */
  102245. constructor(gizmoLayer?: UtilityLayerRenderer);
  102246. private _light;
  102247. /**
  102248. * The light that the gizmo is attached to
  102249. */
  102250. light: Nullable<Light>;
  102251. /**
  102252. * @hidden
  102253. * Updates the gizmo to match the attached mesh's position/rotation
  102254. */
  102255. protected _update(): void;
  102256. private static _Scale;
  102257. /**
  102258. * Creates the lines for a light mesh
  102259. */
  102260. private static _createLightLines;
  102261. private static _CreateHemisphericLightMesh;
  102262. private static _CreatePointLightMesh;
  102263. private static _CreateSpotLightMesh;
  102264. private static _CreateDirectionalLightMesh;
  102265. }
  102266. }
  102267. declare module BABYLON {
  102268. /** @hidden */
  102269. export var backgroundFragmentDeclaration: {
  102270. name: string;
  102271. shader: string;
  102272. };
  102273. }
  102274. declare module BABYLON {
  102275. /** @hidden */
  102276. export var backgroundUboDeclaration: {
  102277. name: string;
  102278. shader: string;
  102279. };
  102280. }
  102281. declare module BABYLON {
  102282. /** @hidden */
  102283. export var backgroundPixelShader: {
  102284. name: string;
  102285. shader: string;
  102286. };
  102287. }
  102288. declare module BABYLON {
  102289. /** @hidden */
  102290. export var backgroundVertexDeclaration: {
  102291. name: string;
  102292. shader: string;
  102293. };
  102294. }
  102295. declare module BABYLON {
  102296. /** @hidden */
  102297. export var backgroundVertexShader: {
  102298. name: string;
  102299. shader: string;
  102300. };
  102301. }
  102302. declare module BABYLON {
  102303. /**
  102304. * Background material used to create an efficient environement around your scene.
  102305. */
  102306. export class BackgroundMaterial extends PushMaterial {
  102307. /**
  102308. * Standard reflectance value at parallel view angle.
  102309. */
  102310. static StandardReflectance0: number;
  102311. /**
  102312. * Standard reflectance value at grazing angle.
  102313. */
  102314. static StandardReflectance90: number;
  102315. protected _primaryColor: Color3;
  102316. /**
  102317. * Key light Color (multiply against the environement texture)
  102318. */
  102319. primaryColor: Color3;
  102320. protected __perceptualColor: Nullable<Color3>;
  102321. /**
  102322. * Experimental Internal Use Only.
  102323. *
  102324. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  102325. * This acts as a helper to set the primary color to a more "human friendly" value.
  102326. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  102327. * output color as close as possible from the chosen value.
  102328. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  102329. * part of lighting setup.)
  102330. */
  102331. _perceptualColor: Nullable<Color3>;
  102332. protected _primaryColorShadowLevel: float;
  102333. /**
  102334. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  102335. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  102336. */
  102337. primaryColorShadowLevel: float;
  102338. protected _primaryColorHighlightLevel: float;
  102339. /**
  102340. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  102341. * The primary color is used at the level chosen to define what the white area would look.
  102342. */
  102343. primaryColorHighlightLevel: float;
  102344. protected _reflectionTexture: Nullable<BaseTexture>;
  102345. /**
  102346. * Reflection Texture used in the material.
  102347. * Should be author in a specific way for the best result (refer to the documentation).
  102348. */
  102349. reflectionTexture: Nullable<BaseTexture>;
  102350. protected _reflectionBlur: float;
  102351. /**
  102352. * Reflection Texture level of blur.
  102353. *
  102354. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  102355. * texture twice.
  102356. */
  102357. reflectionBlur: float;
  102358. protected _diffuseTexture: Nullable<BaseTexture>;
  102359. /**
  102360. * Diffuse Texture used in the material.
  102361. * Should be author in a specific way for the best result (refer to the documentation).
  102362. */
  102363. diffuseTexture: Nullable<BaseTexture>;
  102364. protected _shadowLights: Nullable<IShadowLight[]>;
  102365. /**
  102366. * Specify the list of lights casting shadow on the material.
  102367. * All scene shadow lights will be included if null.
  102368. */
  102369. shadowLights: Nullable<IShadowLight[]>;
  102370. protected _shadowLevel: float;
  102371. /**
  102372. * Helps adjusting the shadow to a softer level if required.
  102373. * 0 means black shadows and 1 means no shadows.
  102374. */
  102375. shadowLevel: float;
  102376. protected _sceneCenter: Vector3;
  102377. /**
  102378. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  102379. * It is usually zero but might be interesting to modify according to your setup.
  102380. */
  102381. sceneCenter: Vector3;
  102382. protected _opacityFresnel: boolean;
  102383. /**
  102384. * This helps specifying that the material is falling off to the sky box at grazing angle.
  102385. * This helps ensuring a nice transition when the camera goes under the ground.
  102386. */
  102387. opacityFresnel: boolean;
  102388. protected _reflectionFresnel: boolean;
  102389. /**
  102390. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  102391. * This helps adding a mirror texture on the ground.
  102392. */
  102393. reflectionFresnel: boolean;
  102394. protected _reflectionFalloffDistance: number;
  102395. /**
  102396. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  102397. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  102398. */
  102399. reflectionFalloffDistance: number;
  102400. protected _reflectionAmount: number;
  102401. /**
  102402. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  102403. */
  102404. reflectionAmount: number;
  102405. protected _reflectionReflectance0: number;
  102406. /**
  102407. * This specifies the weight of the reflection at grazing angle.
  102408. */
  102409. reflectionReflectance0: number;
  102410. protected _reflectionReflectance90: number;
  102411. /**
  102412. * This specifies the weight of the reflection at a perpendicular point of view.
  102413. */
  102414. reflectionReflectance90: number;
  102415. /**
  102416. * Sets the reflection reflectance fresnel values according to the default standard
  102417. * empirically know to work well :-)
  102418. */
  102419. reflectionStandardFresnelWeight: number;
  102420. protected _useRGBColor: boolean;
  102421. /**
  102422. * Helps to directly use the maps channels instead of their level.
  102423. */
  102424. useRGBColor: boolean;
  102425. protected _enableNoise: boolean;
  102426. /**
  102427. * This helps reducing the banding effect that could occur on the background.
  102428. */
  102429. enableNoise: boolean;
  102430. /**
  102431. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102432. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  102433. * Recommended to be keep at 1.0 except for special cases.
  102434. */
  102435. fovMultiplier: number;
  102436. private _fovMultiplier;
  102437. /**
  102438. * Enable the FOV adjustment feature controlled by fovMultiplier.
  102439. */
  102440. useEquirectangularFOV: boolean;
  102441. private _maxSimultaneousLights;
  102442. /**
  102443. * Number of Simultaneous lights allowed on the material.
  102444. */
  102445. maxSimultaneousLights: int;
  102446. /**
  102447. * Default configuration related to image processing available in the Background Material.
  102448. */
  102449. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102450. /**
  102451. * Keep track of the image processing observer to allow dispose and replace.
  102452. */
  102453. private _imageProcessingObserver;
  102454. /**
  102455. * Attaches a new image processing configuration to the PBR Material.
  102456. * @param configuration (if null the scene configuration will be use)
  102457. */
  102458. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102459. /**
  102460. * Gets the image processing configuration used either in this material.
  102461. */
  102462. /**
  102463. * Sets the Default image processing configuration used either in the this material.
  102464. *
  102465. * If sets to null, the scene one is in use.
  102466. */
  102467. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  102468. /**
  102469. * Gets wether the color curves effect is enabled.
  102470. */
  102471. /**
  102472. * Sets wether the color curves effect is enabled.
  102473. */
  102474. cameraColorCurvesEnabled: boolean;
  102475. /**
  102476. * Gets wether the color grading effect is enabled.
  102477. */
  102478. /**
  102479. * Gets wether the color grading effect is enabled.
  102480. */
  102481. cameraColorGradingEnabled: boolean;
  102482. /**
  102483. * Gets wether tonemapping is enabled or not.
  102484. */
  102485. /**
  102486. * Sets wether tonemapping is enabled or not
  102487. */
  102488. cameraToneMappingEnabled: boolean;
  102489. /**
  102490. * The camera exposure used on this material.
  102491. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102492. * This corresponds to a photographic exposure.
  102493. */
  102494. /**
  102495. * The camera exposure used on this material.
  102496. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102497. * This corresponds to a photographic exposure.
  102498. */
  102499. cameraExposure: float;
  102500. /**
  102501. * Gets The camera contrast used on this material.
  102502. */
  102503. /**
  102504. * Sets The camera contrast used on this material.
  102505. */
  102506. cameraContrast: float;
  102507. /**
  102508. * Gets the Color Grading 2D Lookup Texture.
  102509. */
  102510. /**
  102511. * Sets the Color Grading 2D Lookup Texture.
  102512. */
  102513. cameraColorGradingTexture: Nullable<BaseTexture>;
  102514. /**
  102515. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102516. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102517. * 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;
  102518. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102519. */
  102520. /**
  102521. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102522. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102523. * 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;
  102524. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102525. */
  102526. cameraColorCurves: Nullable<ColorCurves>;
  102527. /**
  102528. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  102529. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  102530. */
  102531. switchToBGR: boolean;
  102532. private _renderTargets;
  102533. private _reflectionControls;
  102534. private _white;
  102535. private _primaryShadowColor;
  102536. private _primaryHighlightColor;
  102537. /**
  102538. * Instantiates a Background Material in the given scene
  102539. * @param name The friendly name of the material
  102540. * @param scene The scene to add the material to
  102541. */
  102542. constructor(name: string, scene: Scene);
  102543. /**
  102544. * Gets a boolean indicating that current material needs to register RTT
  102545. */
  102546. readonly hasRenderTargetTextures: boolean;
  102547. /**
  102548. * The entire material has been created in order to prevent overdraw.
  102549. * @returns false
  102550. */
  102551. needAlphaTesting(): boolean;
  102552. /**
  102553. * The entire material has been created in order to prevent overdraw.
  102554. * @returns true if blending is enable
  102555. */
  102556. needAlphaBlending(): boolean;
  102557. /**
  102558. * Checks wether the material is ready to be rendered for a given mesh.
  102559. * @param mesh The mesh to render
  102560. * @param subMesh The submesh to check against
  102561. * @param useInstances Specify wether or not the material is used with instances
  102562. * @returns true if all the dependencies are ready (Textures, Effects...)
  102563. */
  102564. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102565. /**
  102566. * Compute the primary color according to the chosen perceptual color.
  102567. */
  102568. private _computePrimaryColorFromPerceptualColor;
  102569. /**
  102570. * Compute the highlights and shadow colors according to their chosen levels.
  102571. */
  102572. private _computePrimaryColors;
  102573. /**
  102574. * Build the uniform buffer used in the material.
  102575. */
  102576. buildUniformLayout(): void;
  102577. /**
  102578. * Unbind the material.
  102579. */
  102580. unbind(): void;
  102581. /**
  102582. * Bind only the world matrix to the material.
  102583. * @param world The world matrix to bind.
  102584. */
  102585. bindOnlyWorldMatrix(world: Matrix): void;
  102586. /**
  102587. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  102588. * @param world The world matrix to bind.
  102589. * @param subMesh The submesh to bind for.
  102590. */
  102591. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102592. /**
  102593. * Dispose the material.
  102594. * @param forceDisposeEffect Force disposal of the associated effect.
  102595. * @param forceDisposeTextures Force disposal of the associated textures.
  102596. */
  102597. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102598. /**
  102599. * Clones the material.
  102600. * @param name The cloned name.
  102601. * @returns The cloned material.
  102602. */
  102603. clone(name: string): BackgroundMaterial;
  102604. /**
  102605. * Serializes the current material to its JSON representation.
  102606. * @returns The JSON representation.
  102607. */
  102608. serialize(): any;
  102609. /**
  102610. * Gets the class name of the material
  102611. * @returns "BackgroundMaterial"
  102612. */
  102613. getClassName(): string;
  102614. /**
  102615. * Parse a JSON input to create back a background material.
  102616. * @param source The JSON data to parse
  102617. * @param scene The scene to create the parsed material in
  102618. * @param rootUrl The root url of the assets the material depends upon
  102619. * @returns the instantiated BackgroundMaterial.
  102620. */
  102621. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  102622. }
  102623. }
  102624. declare module BABYLON {
  102625. /**
  102626. * Represents the different options available during the creation of
  102627. * a Environment helper.
  102628. *
  102629. * This can control the default ground, skybox and image processing setup of your scene.
  102630. */
  102631. export interface IEnvironmentHelperOptions {
  102632. /**
  102633. * Specifies wether or not to create a ground.
  102634. * True by default.
  102635. */
  102636. createGround: boolean;
  102637. /**
  102638. * Specifies the ground size.
  102639. * 15 by default.
  102640. */
  102641. groundSize: number;
  102642. /**
  102643. * The texture used on the ground for the main color.
  102644. * Comes from the BabylonJS CDN by default.
  102645. *
  102646. * Remarks: Can be either a texture or a url.
  102647. */
  102648. groundTexture: string | BaseTexture;
  102649. /**
  102650. * The color mixed in the ground texture by default.
  102651. * BabylonJS clearColor by default.
  102652. */
  102653. groundColor: Color3;
  102654. /**
  102655. * Specifies the ground opacity.
  102656. * 1 by default.
  102657. */
  102658. groundOpacity: number;
  102659. /**
  102660. * Enables the ground to receive shadows.
  102661. * True by default.
  102662. */
  102663. enableGroundShadow: boolean;
  102664. /**
  102665. * Helps preventing the shadow to be fully black on the ground.
  102666. * 0.5 by default.
  102667. */
  102668. groundShadowLevel: number;
  102669. /**
  102670. * Creates a mirror texture attach to the ground.
  102671. * false by default.
  102672. */
  102673. enableGroundMirror: boolean;
  102674. /**
  102675. * Specifies the ground mirror size ratio.
  102676. * 0.3 by default as the default kernel is 64.
  102677. */
  102678. groundMirrorSizeRatio: number;
  102679. /**
  102680. * Specifies the ground mirror blur kernel size.
  102681. * 64 by default.
  102682. */
  102683. groundMirrorBlurKernel: number;
  102684. /**
  102685. * Specifies the ground mirror visibility amount.
  102686. * 1 by default
  102687. */
  102688. groundMirrorAmount: number;
  102689. /**
  102690. * Specifies the ground mirror reflectance weight.
  102691. * This uses the standard weight of the background material to setup the fresnel effect
  102692. * of the mirror.
  102693. * 1 by default.
  102694. */
  102695. groundMirrorFresnelWeight: number;
  102696. /**
  102697. * Specifies the ground mirror Falloff distance.
  102698. * This can helps reducing the size of the reflection.
  102699. * 0 by Default.
  102700. */
  102701. groundMirrorFallOffDistance: number;
  102702. /**
  102703. * Specifies the ground mirror texture type.
  102704. * Unsigned Int by Default.
  102705. */
  102706. groundMirrorTextureType: number;
  102707. /**
  102708. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  102709. * the shown objects.
  102710. */
  102711. groundYBias: number;
  102712. /**
  102713. * Specifies wether or not to create a skybox.
  102714. * True by default.
  102715. */
  102716. createSkybox: boolean;
  102717. /**
  102718. * Specifies the skybox size.
  102719. * 20 by default.
  102720. */
  102721. skyboxSize: number;
  102722. /**
  102723. * The texture used on the skybox for the main color.
  102724. * Comes from the BabylonJS CDN by default.
  102725. *
  102726. * Remarks: Can be either a texture or a url.
  102727. */
  102728. skyboxTexture: string | BaseTexture;
  102729. /**
  102730. * The color mixed in the skybox texture by default.
  102731. * BabylonJS clearColor by default.
  102732. */
  102733. skyboxColor: Color3;
  102734. /**
  102735. * The background rotation around the Y axis of the scene.
  102736. * This helps aligning the key lights of your scene with the background.
  102737. * 0 by default.
  102738. */
  102739. backgroundYRotation: number;
  102740. /**
  102741. * Compute automatically the size of the elements to best fit with the scene.
  102742. */
  102743. sizeAuto: boolean;
  102744. /**
  102745. * Default position of the rootMesh if autoSize is not true.
  102746. */
  102747. rootPosition: Vector3;
  102748. /**
  102749. * Sets up the image processing in the scene.
  102750. * true by default.
  102751. */
  102752. setupImageProcessing: boolean;
  102753. /**
  102754. * The texture used as your environment texture in the scene.
  102755. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  102756. *
  102757. * Remarks: Can be either a texture or a url.
  102758. */
  102759. environmentTexture: string | BaseTexture;
  102760. /**
  102761. * The value of the exposure to apply to the scene.
  102762. * 0.6 by default if setupImageProcessing is true.
  102763. */
  102764. cameraExposure: number;
  102765. /**
  102766. * The value of the contrast to apply to the scene.
  102767. * 1.6 by default if setupImageProcessing is true.
  102768. */
  102769. cameraContrast: number;
  102770. /**
  102771. * Specifies wether or not tonemapping should be enabled in the scene.
  102772. * true by default if setupImageProcessing is true.
  102773. */
  102774. toneMappingEnabled: boolean;
  102775. }
  102776. /**
  102777. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  102778. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  102779. * It also helps with the default setup of your imageProcessing configuration.
  102780. */
  102781. export class EnvironmentHelper {
  102782. /**
  102783. * Default ground texture URL.
  102784. */
  102785. private static _groundTextureCDNUrl;
  102786. /**
  102787. * Default skybox texture URL.
  102788. */
  102789. private static _skyboxTextureCDNUrl;
  102790. /**
  102791. * Default environment texture URL.
  102792. */
  102793. private static _environmentTextureCDNUrl;
  102794. /**
  102795. * Creates the default options for the helper.
  102796. */
  102797. private static _getDefaultOptions;
  102798. private _rootMesh;
  102799. /**
  102800. * Gets the root mesh created by the helper.
  102801. */
  102802. readonly rootMesh: Mesh;
  102803. private _skybox;
  102804. /**
  102805. * Gets the skybox created by the helper.
  102806. */
  102807. readonly skybox: Nullable<Mesh>;
  102808. private _skyboxTexture;
  102809. /**
  102810. * Gets the skybox texture created by the helper.
  102811. */
  102812. readonly skyboxTexture: Nullable<BaseTexture>;
  102813. private _skyboxMaterial;
  102814. /**
  102815. * Gets the skybox material created by the helper.
  102816. */
  102817. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  102818. private _ground;
  102819. /**
  102820. * Gets the ground mesh created by the helper.
  102821. */
  102822. readonly ground: Nullable<Mesh>;
  102823. private _groundTexture;
  102824. /**
  102825. * Gets the ground texture created by the helper.
  102826. */
  102827. readonly groundTexture: Nullable<BaseTexture>;
  102828. private _groundMirror;
  102829. /**
  102830. * Gets the ground mirror created by the helper.
  102831. */
  102832. readonly groundMirror: Nullable<MirrorTexture>;
  102833. /**
  102834. * Gets the ground mirror render list to helps pushing the meshes
  102835. * you wish in the ground reflection.
  102836. */
  102837. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  102838. private _groundMaterial;
  102839. /**
  102840. * Gets the ground material created by the helper.
  102841. */
  102842. readonly groundMaterial: Nullable<BackgroundMaterial>;
  102843. /**
  102844. * Stores the creation options.
  102845. */
  102846. private readonly _scene;
  102847. private _options;
  102848. /**
  102849. * This observable will be notified with any error during the creation of the environment,
  102850. * mainly texture creation errors.
  102851. */
  102852. onErrorObservable: Observable<{
  102853. message?: string;
  102854. exception?: any;
  102855. }>;
  102856. /**
  102857. * constructor
  102858. * @param options Defines the options we want to customize the helper
  102859. * @param scene The scene to add the material to
  102860. */
  102861. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  102862. /**
  102863. * Updates the background according to the new options
  102864. * @param options
  102865. */
  102866. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  102867. /**
  102868. * Sets the primary color of all the available elements.
  102869. * @param color the main color to affect to the ground and the background
  102870. */
  102871. setMainColor(color: Color3): void;
  102872. /**
  102873. * Setup the image processing according to the specified options.
  102874. */
  102875. private _setupImageProcessing;
  102876. /**
  102877. * Setup the environment texture according to the specified options.
  102878. */
  102879. private _setupEnvironmentTexture;
  102880. /**
  102881. * Setup the background according to the specified options.
  102882. */
  102883. private _setupBackground;
  102884. /**
  102885. * Get the scene sizes according to the setup.
  102886. */
  102887. private _getSceneSize;
  102888. /**
  102889. * Setup the ground according to the specified options.
  102890. */
  102891. private _setupGround;
  102892. /**
  102893. * Setup the ground material according to the specified options.
  102894. */
  102895. private _setupGroundMaterial;
  102896. /**
  102897. * Setup the ground diffuse texture according to the specified options.
  102898. */
  102899. private _setupGroundDiffuseTexture;
  102900. /**
  102901. * Setup the ground mirror texture according to the specified options.
  102902. */
  102903. private _setupGroundMirrorTexture;
  102904. /**
  102905. * Setup the ground to receive the mirror texture.
  102906. */
  102907. private _setupMirrorInGroundMaterial;
  102908. /**
  102909. * Setup the skybox according to the specified options.
  102910. */
  102911. private _setupSkybox;
  102912. /**
  102913. * Setup the skybox material according to the specified options.
  102914. */
  102915. private _setupSkyboxMaterial;
  102916. /**
  102917. * Setup the skybox reflection texture according to the specified options.
  102918. */
  102919. private _setupSkyboxReflectionTexture;
  102920. private _errorHandler;
  102921. /**
  102922. * Dispose all the elements created by the Helper.
  102923. */
  102924. dispose(): void;
  102925. }
  102926. }
  102927. declare module BABYLON {
  102928. /**
  102929. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  102930. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  102931. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  102932. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  102933. */
  102934. export class PhotoDome extends TransformNode {
  102935. private _useDirectMapping;
  102936. /**
  102937. * The texture being displayed on the sphere
  102938. */
  102939. protected _photoTexture: Texture;
  102940. /**
  102941. * Gets or sets the texture being displayed on the sphere
  102942. */
  102943. photoTexture: Texture;
  102944. /**
  102945. * Observable raised when an error occured while loading the 360 image
  102946. */
  102947. onLoadErrorObservable: Observable<string>;
  102948. /**
  102949. * The skybox material
  102950. */
  102951. protected _material: BackgroundMaterial;
  102952. /**
  102953. * The surface used for the skybox
  102954. */
  102955. protected _mesh: Mesh;
  102956. /**
  102957. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102958. * Also see the options.resolution property.
  102959. */
  102960. fovMultiplier: number;
  102961. /**
  102962. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  102963. * @param name Element's name, child elements will append suffixes for their own names.
  102964. * @param urlsOfPhoto defines the url of the photo to display
  102965. * @param options defines an object containing optional or exposed sub element properties
  102966. * @param onError defines a callback called when an error occured while loading the texture
  102967. */
  102968. constructor(name: string, urlOfPhoto: string, options: {
  102969. resolution?: number;
  102970. size?: number;
  102971. useDirectMapping?: boolean;
  102972. faceForward?: boolean;
  102973. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  102974. /**
  102975. * Releases resources associated with this node.
  102976. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102977. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102978. */
  102979. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102980. }
  102981. }
  102982. declare module BABYLON {
  102983. /** @hidden */
  102984. export var rgbdDecodePixelShader: {
  102985. name: string;
  102986. shader: string;
  102987. };
  102988. }
  102989. declare module BABYLON {
  102990. /**
  102991. * Class used to host texture specific utilities
  102992. */
  102993. export class BRDFTextureTools {
  102994. /**
  102995. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  102996. * @param texture the texture to expand.
  102997. */
  102998. private static _ExpandDefaultBRDFTexture;
  102999. /**
  103000. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  103001. * @param scene defines the hosting scene
  103002. * @returns the environment BRDF texture
  103003. */
  103004. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  103005. private static _environmentBRDFBase64Texture;
  103006. }
  103007. }
  103008. declare module BABYLON {
  103009. /**
  103010. * @hidden
  103011. */
  103012. export interface IMaterialClearCoatDefines {
  103013. CLEARCOAT: boolean;
  103014. CLEARCOAT_DEFAULTIOR: boolean;
  103015. CLEARCOAT_TEXTURE: boolean;
  103016. CLEARCOAT_TEXTUREDIRECTUV: number;
  103017. CLEARCOAT_BUMP: boolean;
  103018. CLEARCOAT_BUMPDIRECTUV: number;
  103019. CLEARCOAT_TINT: boolean;
  103020. CLEARCOAT_TINT_TEXTURE: boolean;
  103021. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  103022. /** @hidden */
  103023. _areTexturesDirty: boolean;
  103024. }
  103025. /**
  103026. * Define the code related to the clear coat parameters of the pbr material.
  103027. */
  103028. export class PBRClearCoatConfiguration {
  103029. /**
  103030. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103031. * The default fits with a polyurethane material.
  103032. */
  103033. private static readonly _DefaultIndiceOfRefraction;
  103034. private _isEnabled;
  103035. /**
  103036. * Defines if the clear coat is enabled in the material.
  103037. */
  103038. isEnabled: boolean;
  103039. /**
  103040. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  103041. */
  103042. intensity: number;
  103043. /**
  103044. * Defines the clear coat layer roughness.
  103045. */
  103046. roughness: number;
  103047. private _indiceOfRefraction;
  103048. /**
  103049. * Defines the indice of refraction of the clear coat.
  103050. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103051. * The default fits with a polyurethane material.
  103052. * Changing the default value is more performance intensive.
  103053. */
  103054. indiceOfRefraction: number;
  103055. private _texture;
  103056. /**
  103057. * Stores the clear coat values in a texture.
  103058. */
  103059. texture: Nullable<BaseTexture>;
  103060. private _bumpTexture;
  103061. /**
  103062. * Define the clear coat specific bump texture.
  103063. */
  103064. bumpTexture: Nullable<BaseTexture>;
  103065. private _isTintEnabled;
  103066. /**
  103067. * Defines if the clear coat tint is enabled in the material.
  103068. */
  103069. isTintEnabled: boolean;
  103070. /**
  103071. * Defines the clear coat tint of the material.
  103072. * This is only use if tint is enabled
  103073. */
  103074. tintColor: Color3;
  103075. /**
  103076. * Defines the distance at which the tint color should be found in the
  103077. * clear coat media.
  103078. * This is only use if tint is enabled
  103079. */
  103080. tintColorAtDistance: number;
  103081. /**
  103082. * Defines the clear coat layer thickness.
  103083. * This is only use if tint is enabled
  103084. */
  103085. tintThickness: number;
  103086. private _tintTexture;
  103087. /**
  103088. * Stores the clear tint values in a texture.
  103089. * rgb is tint
  103090. * a is a thickness factor
  103091. */
  103092. tintTexture: Nullable<BaseTexture>;
  103093. /** @hidden */
  103094. private _internalMarkAllSubMeshesAsTexturesDirty;
  103095. /** @hidden */
  103096. _markAllSubMeshesAsTexturesDirty(): void;
  103097. /**
  103098. * Instantiate a new istance of clear coat configuration.
  103099. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103100. */
  103101. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103102. /**
  103103. * Gets wehter the submesh is ready to be used or not.
  103104. * @param defines the list of "defines" to update.
  103105. * @param scene defines the scene the material belongs to.
  103106. * @param engine defines the engine the material belongs to.
  103107. * @param disableBumpMap defines wether the material disables bump or not.
  103108. * @returns - boolean indicating that the submesh is ready or not.
  103109. */
  103110. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  103111. /**
  103112. * Checks to see if a texture is used in the material.
  103113. * @param defines the list of "defines" to update.
  103114. * @param scene defines the scene to the material belongs to.
  103115. */
  103116. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  103117. /**
  103118. * Binds the material data.
  103119. * @param uniformBuffer defines the Uniform buffer to fill in.
  103120. * @param scene defines the scene the material belongs to.
  103121. * @param engine defines the engine the material belongs to.
  103122. * @param disableBumpMap defines wether the material disables bump or not.
  103123. * @param isFrozen defines wether the material is frozen or not.
  103124. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  103125. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  103126. */
  103127. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  103128. /**
  103129. * Checks to see if a texture is used in the material.
  103130. * @param texture - Base texture to use.
  103131. * @returns - Boolean specifying if a texture is used in the material.
  103132. */
  103133. hasTexture(texture: BaseTexture): boolean;
  103134. /**
  103135. * Returns an array of the actively used textures.
  103136. * @param activeTextures Array of BaseTextures
  103137. */
  103138. getActiveTextures(activeTextures: BaseTexture[]): void;
  103139. /**
  103140. * Returns the animatable textures.
  103141. * @param animatables Array of animatable textures.
  103142. */
  103143. getAnimatables(animatables: IAnimatable[]): void;
  103144. /**
  103145. * Disposes the resources of the material.
  103146. * @param forceDisposeTextures - Forces the disposal of all textures.
  103147. */
  103148. dispose(forceDisposeTextures?: boolean): void;
  103149. /**
  103150. * Get the current class name of the texture useful for serialization or dynamic coding.
  103151. * @returns "PBRClearCoatConfiguration"
  103152. */
  103153. getClassName(): string;
  103154. /**
  103155. * Add fallbacks to the effect fallbacks list.
  103156. * @param defines defines the Base texture to use.
  103157. * @param fallbacks defines the current fallback list.
  103158. * @param currentRank defines the current fallback rank.
  103159. * @returns the new fallback rank.
  103160. */
  103161. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103162. /**
  103163. * Add the required uniforms to the current list.
  103164. * @param uniforms defines the current uniform list.
  103165. */
  103166. static AddUniforms(uniforms: string[]): void;
  103167. /**
  103168. * Add the required samplers to the current list.
  103169. * @param samplers defines the current sampler list.
  103170. */
  103171. static AddSamplers(samplers: string[]): void;
  103172. /**
  103173. * Add the required uniforms to the current buffer.
  103174. * @param uniformBuffer defines the current uniform buffer.
  103175. */
  103176. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103177. /**
  103178. * Makes a duplicate of the current configuration into another one.
  103179. * @param clearCoatConfiguration define the config where to copy the info
  103180. */
  103181. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  103182. /**
  103183. * Serializes this clear coat configuration.
  103184. * @returns - An object with the serialized config.
  103185. */
  103186. serialize(): any;
  103187. /**
  103188. * Parses a Clear Coat Configuration from a serialized object.
  103189. * @param source - Serialized object.
  103190. */
  103191. parse(source: any): void;
  103192. }
  103193. }
  103194. declare module BABYLON {
  103195. /**
  103196. * @hidden
  103197. */
  103198. export interface IMaterialAnisotropicDefines {
  103199. ANISOTROPIC: boolean;
  103200. ANISOTROPIC_TEXTURE: boolean;
  103201. ANISOTROPIC_TEXTUREDIRECTUV: number;
  103202. MAINUV1: boolean;
  103203. _areTexturesDirty: boolean;
  103204. _needUVs: boolean;
  103205. }
  103206. /**
  103207. * Define the code related to the anisotropic parameters of the pbr material.
  103208. */
  103209. export class PBRAnisotropicConfiguration {
  103210. private _isEnabled;
  103211. /**
  103212. * Defines if the anisotropy is enabled in the material.
  103213. */
  103214. isEnabled: boolean;
  103215. /**
  103216. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  103217. */
  103218. intensity: number;
  103219. /**
  103220. * Defines if the effect is along the tangents, bitangents or in between.
  103221. * By default, the effect is "strectching" the highlights along the tangents.
  103222. */
  103223. direction: Vector2;
  103224. private _texture;
  103225. /**
  103226. * Stores the anisotropy values in a texture.
  103227. * rg is direction (like normal from -1 to 1)
  103228. * b is a intensity
  103229. */
  103230. texture: Nullable<BaseTexture>;
  103231. /** @hidden */
  103232. private _internalMarkAllSubMeshesAsTexturesDirty;
  103233. /** @hidden */
  103234. _markAllSubMeshesAsTexturesDirty(): void;
  103235. /**
  103236. * Instantiate a new istance of anisotropy configuration.
  103237. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103238. */
  103239. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103240. /**
  103241. * Specifies that the submesh is ready to be used.
  103242. * @param defines the list of "defines" to update.
  103243. * @param scene defines the scene the material belongs to.
  103244. * @returns - boolean indicating that the submesh is ready or not.
  103245. */
  103246. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  103247. /**
  103248. * Checks to see if a texture is used in the material.
  103249. * @param defines the list of "defines" to update.
  103250. * @param mesh the mesh we are preparing the defines for.
  103251. * @param scene defines the scene the material belongs to.
  103252. */
  103253. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  103254. /**
  103255. * Binds the material data.
  103256. * @param uniformBuffer defines the Uniform buffer to fill in.
  103257. * @param scene defines the scene the material belongs to.
  103258. * @param isFrozen defines wether the material is frozen or not.
  103259. */
  103260. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  103261. /**
  103262. * Checks to see if a texture is used in the material.
  103263. * @param texture - Base texture to use.
  103264. * @returns - Boolean specifying if a texture is used in the material.
  103265. */
  103266. hasTexture(texture: BaseTexture): boolean;
  103267. /**
  103268. * Returns an array of the actively used textures.
  103269. * @param activeTextures Array of BaseTextures
  103270. */
  103271. getActiveTextures(activeTextures: BaseTexture[]): void;
  103272. /**
  103273. * Returns the animatable textures.
  103274. * @param animatables Array of animatable textures.
  103275. */
  103276. getAnimatables(animatables: IAnimatable[]): void;
  103277. /**
  103278. * Disposes the resources of the material.
  103279. * @param forceDisposeTextures - Forces the disposal of all textures.
  103280. */
  103281. dispose(forceDisposeTextures?: boolean): void;
  103282. /**
  103283. * Get the current class name of the texture useful for serialization or dynamic coding.
  103284. * @returns "PBRAnisotropicConfiguration"
  103285. */
  103286. getClassName(): string;
  103287. /**
  103288. * Add fallbacks to the effect fallbacks list.
  103289. * @param defines defines the Base texture to use.
  103290. * @param fallbacks defines the current fallback list.
  103291. * @param currentRank defines the current fallback rank.
  103292. * @returns the new fallback rank.
  103293. */
  103294. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103295. /**
  103296. * Add the required uniforms to the current list.
  103297. * @param uniforms defines the current uniform list.
  103298. */
  103299. static AddUniforms(uniforms: string[]): void;
  103300. /**
  103301. * Add the required uniforms to the current buffer.
  103302. * @param uniformBuffer defines the current uniform buffer.
  103303. */
  103304. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103305. /**
  103306. * Add the required samplers to the current list.
  103307. * @param samplers defines the current sampler list.
  103308. */
  103309. static AddSamplers(samplers: string[]): void;
  103310. /**
  103311. * Makes a duplicate of the current configuration into another one.
  103312. * @param anisotropicConfiguration define the config where to copy the info
  103313. */
  103314. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  103315. /**
  103316. * Serializes this anisotropy configuration.
  103317. * @returns - An object with the serialized config.
  103318. */
  103319. serialize(): any;
  103320. /**
  103321. * Parses a anisotropy Configuration from a serialized object.
  103322. * @param source - Serialized object.
  103323. */
  103324. parse(source: any): void;
  103325. }
  103326. }
  103327. declare module BABYLON {
  103328. /**
  103329. * @hidden
  103330. */
  103331. export interface IMaterialBRDFDefines {
  103332. BRDF_V_HEIGHT_CORRELATED: boolean;
  103333. MS_BRDF_ENERGY_CONSERVATION: boolean;
  103334. /** @hidden */
  103335. _areMiscDirty: boolean;
  103336. }
  103337. /**
  103338. * Define the code related to the BRDF parameters of the pbr material.
  103339. */
  103340. export class PBRBRDFConfiguration {
  103341. /**
  103342. * Default value used for the energy conservation.
  103343. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  103344. */
  103345. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  103346. /**
  103347. * Default value used for the Smith Visibility Height Correlated mode.
  103348. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  103349. */
  103350. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  103351. private _useEnergyConservation;
  103352. /**
  103353. * Defines if the material uses energy conservation.
  103354. */
  103355. useEnergyConservation: boolean;
  103356. private _useSmithVisibilityHeightCorrelated;
  103357. /**
  103358. * LEGACY Mode set to false
  103359. * Defines if the material uses height smith correlated visibility term.
  103360. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  103361. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  103362. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  103363. * Not relying on height correlated will also disable energy conservation.
  103364. */
  103365. useSmithVisibilityHeightCorrelated: boolean;
  103366. /** @hidden */
  103367. private _internalMarkAllSubMeshesAsMiscDirty;
  103368. /** @hidden */
  103369. _markAllSubMeshesAsMiscDirty(): void;
  103370. /**
  103371. * Instantiate a new istance of clear coat configuration.
  103372. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  103373. */
  103374. constructor(markAllSubMeshesAsMiscDirty: () => void);
  103375. /**
  103376. * Checks to see if a texture is used in the material.
  103377. * @param defines the list of "defines" to update.
  103378. */
  103379. prepareDefines(defines: IMaterialBRDFDefines): void;
  103380. /**
  103381. * Get the current class name of the texture useful for serialization or dynamic coding.
  103382. * @returns "PBRClearCoatConfiguration"
  103383. */
  103384. getClassName(): string;
  103385. /**
  103386. * Makes a duplicate of the current configuration into another one.
  103387. * @param brdfConfiguration define the config where to copy the info
  103388. */
  103389. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  103390. /**
  103391. * Serializes this BRDF configuration.
  103392. * @returns - An object with the serialized config.
  103393. */
  103394. serialize(): any;
  103395. /**
  103396. * Parses a BRDF Configuration from a serialized object.
  103397. * @param source - Serialized object.
  103398. */
  103399. parse(source: any): void;
  103400. }
  103401. }
  103402. declare module BABYLON {
  103403. /**
  103404. * @hidden
  103405. */
  103406. export interface IMaterialSheenDefines {
  103407. SHEEN: boolean;
  103408. SHEEN_TEXTURE: boolean;
  103409. SHEEN_TEXTUREDIRECTUV: number;
  103410. SHEEN_LINKWITHALBEDO: boolean;
  103411. /** @hidden */
  103412. _areTexturesDirty: boolean;
  103413. }
  103414. /**
  103415. * Define the code related to the Sheen parameters of the pbr material.
  103416. */
  103417. export class PBRSheenConfiguration {
  103418. private _isEnabled;
  103419. /**
  103420. * Defines if the material uses sheen.
  103421. */
  103422. isEnabled: boolean;
  103423. private _linkSheenWithAlbedo;
  103424. /**
  103425. * Defines if the sheen is linked to the sheen color.
  103426. */
  103427. linkSheenWithAlbedo: boolean;
  103428. /**
  103429. * Defines the sheen intensity.
  103430. */
  103431. intensity: number;
  103432. /**
  103433. * Defines the sheen color.
  103434. */
  103435. color: Color3;
  103436. private _texture;
  103437. /**
  103438. * Stores the sheen tint values in a texture.
  103439. * rgb is tint
  103440. * a is a intensity
  103441. */
  103442. texture: Nullable<BaseTexture>;
  103443. /** @hidden */
  103444. private _internalMarkAllSubMeshesAsTexturesDirty;
  103445. /** @hidden */
  103446. _markAllSubMeshesAsTexturesDirty(): void;
  103447. /**
  103448. * Instantiate a new istance of clear coat configuration.
  103449. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103450. */
  103451. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103452. /**
  103453. * Specifies that the submesh is ready to be used.
  103454. * @param defines the list of "defines" to update.
  103455. * @param scene defines the scene the material belongs to.
  103456. * @returns - boolean indicating that the submesh is ready or not.
  103457. */
  103458. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  103459. /**
  103460. * Checks to see if a texture is used in the material.
  103461. * @param defines the list of "defines" to update.
  103462. * @param scene defines the scene the material belongs to.
  103463. */
  103464. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  103465. /**
  103466. * Binds the material data.
  103467. * @param uniformBuffer defines the Uniform buffer to fill in.
  103468. * @param scene defines the scene the material belongs to.
  103469. * @param isFrozen defines wether the material is frozen or not.
  103470. */
  103471. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  103472. /**
  103473. * Checks to see if a texture is used in the material.
  103474. * @param texture - Base texture to use.
  103475. * @returns - Boolean specifying if a texture is used in the material.
  103476. */
  103477. hasTexture(texture: BaseTexture): boolean;
  103478. /**
  103479. * Returns an array of the actively used textures.
  103480. * @param activeTextures Array of BaseTextures
  103481. */
  103482. getActiveTextures(activeTextures: BaseTexture[]): void;
  103483. /**
  103484. * Returns the animatable textures.
  103485. * @param animatables Array of animatable textures.
  103486. */
  103487. getAnimatables(animatables: IAnimatable[]): void;
  103488. /**
  103489. * Disposes the resources of the material.
  103490. * @param forceDisposeTextures - Forces the disposal of all textures.
  103491. */
  103492. dispose(forceDisposeTextures?: boolean): void;
  103493. /**
  103494. * Get the current class name of the texture useful for serialization or dynamic coding.
  103495. * @returns "PBRSheenConfiguration"
  103496. */
  103497. getClassName(): string;
  103498. /**
  103499. * Add fallbacks to the effect fallbacks list.
  103500. * @param defines defines the Base texture to use.
  103501. * @param fallbacks defines the current fallback list.
  103502. * @param currentRank defines the current fallback rank.
  103503. * @returns the new fallback rank.
  103504. */
  103505. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103506. /**
  103507. * Add the required uniforms to the current list.
  103508. * @param uniforms defines the current uniform list.
  103509. */
  103510. static AddUniforms(uniforms: string[]): void;
  103511. /**
  103512. * Add the required uniforms to the current buffer.
  103513. * @param uniformBuffer defines the current uniform buffer.
  103514. */
  103515. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103516. /**
  103517. * Add the required samplers to the current list.
  103518. * @param samplers defines the current sampler list.
  103519. */
  103520. static AddSamplers(samplers: string[]): void;
  103521. /**
  103522. * Makes a duplicate of the current configuration into another one.
  103523. * @param sheenConfiguration define the config where to copy the info
  103524. */
  103525. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  103526. /**
  103527. * Serializes this BRDF configuration.
  103528. * @returns - An object with the serialized config.
  103529. */
  103530. serialize(): any;
  103531. /**
  103532. * Parses a Sheen Configuration from a serialized object.
  103533. * @param source - Serialized object.
  103534. */
  103535. parse(source: any): void;
  103536. }
  103537. }
  103538. declare module BABYLON {
  103539. /**
  103540. * @hidden
  103541. */
  103542. export interface IMaterialSubSurfaceDefines {
  103543. SUBSURFACE: boolean;
  103544. SS_REFRACTION: boolean;
  103545. SS_TRANSLUCENCY: boolean;
  103546. SS_SCATERRING: boolean;
  103547. SS_THICKNESSANDMASK_TEXTURE: boolean;
  103548. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  103549. SS_REFRACTIONMAP_3D: boolean;
  103550. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  103551. SS_LODINREFRACTIONALPHA: boolean;
  103552. SS_GAMMAREFRACTION: boolean;
  103553. SS_RGBDREFRACTION: boolean;
  103554. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  103555. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  103556. /** @hidden */
  103557. _areTexturesDirty: boolean;
  103558. }
  103559. /**
  103560. * Define the code related to the sub surface parameters of the pbr material.
  103561. */
  103562. export class PBRSubSurfaceConfiguration {
  103563. private _isRefractionEnabled;
  103564. /**
  103565. * Defines if the refraction is enabled in the material.
  103566. */
  103567. isRefractionEnabled: boolean;
  103568. private _isTranslucencyEnabled;
  103569. /**
  103570. * Defines if the translucency is enabled in the material.
  103571. */
  103572. isTranslucencyEnabled: boolean;
  103573. private _isScatteringEnabled;
  103574. /**
  103575. * Defines the refraction intensity of the material.
  103576. * The refraction when enabled replaces the Diffuse part of the material.
  103577. * The intensity helps transitionning between diffuse and refraction.
  103578. */
  103579. refractionIntensity: number;
  103580. /**
  103581. * Defines the translucency intensity of the material.
  103582. * When translucency has been enabled, this defines how much of the "translucency"
  103583. * is addded to the diffuse part of the material.
  103584. */
  103585. translucencyIntensity: number;
  103586. /**
  103587. * Defines the scattering intensity of the material.
  103588. * When scattering has been enabled, this defines how much of the "scattered light"
  103589. * is addded to the diffuse part of the material.
  103590. */
  103591. scatteringIntensity: number;
  103592. private _thicknessTexture;
  103593. /**
  103594. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  103595. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  103596. * 0 would mean minimumThickness
  103597. * 1 would mean maximumThickness
  103598. * The other channels might be use as a mask to vary the different effects intensity.
  103599. */
  103600. thicknessTexture: Nullable<BaseTexture>;
  103601. private _refractionTexture;
  103602. /**
  103603. * Defines the texture to use for refraction.
  103604. */
  103605. refractionTexture: Nullable<BaseTexture>;
  103606. private _indexOfRefraction;
  103607. /**
  103608. * Defines the indice of refraction used in the material.
  103609. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  103610. */
  103611. indexOfRefraction: number;
  103612. private _invertRefractionY;
  103613. /**
  103614. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  103615. */
  103616. invertRefractionY: boolean;
  103617. private _linkRefractionWithTransparency;
  103618. /**
  103619. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  103620. * Materials half opaque for instance using refraction could benefit from this control.
  103621. */
  103622. linkRefractionWithTransparency: boolean;
  103623. /**
  103624. * Defines the minimum thickness stored in the thickness map.
  103625. * If no thickness map is defined, this value will be used to simulate thickness.
  103626. */
  103627. minimumThickness: number;
  103628. /**
  103629. * Defines the maximum thickness stored in the thickness map.
  103630. */
  103631. maximumThickness: number;
  103632. /**
  103633. * Defines the volume tint of the material.
  103634. * This is used for both translucency and scattering.
  103635. */
  103636. tintColor: Color3;
  103637. /**
  103638. * Defines the distance at which the tint color should be found in the media.
  103639. * This is used for refraction only.
  103640. */
  103641. tintColorAtDistance: number;
  103642. /**
  103643. * Defines how far each channel transmit through the media.
  103644. * It is defined as a color to simplify it selection.
  103645. */
  103646. diffusionDistance: Color3;
  103647. private _useMaskFromThicknessTexture;
  103648. /**
  103649. * Stores the intensity of the different subsurface effects in the thickness texture.
  103650. * * the green channel is the translucency intensity.
  103651. * * the blue channel is the scattering intensity.
  103652. * * the alpha channel is the refraction intensity.
  103653. */
  103654. useMaskFromThicknessTexture: boolean;
  103655. /** @hidden */
  103656. private _internalMarkAllSubMeshesAsTexturesDirty;
  103657. /** @hidden */
  103658. _markAllSubMeshesAsTexturesDirty(): void;
  103659. /**
  103660. * Instantiate a new istance of sub surface configuration.
  103661. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103662. */
  103663. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103664. /**
  103665. * Gets wehter the submesh is ready to be used or not.
  103666. * @param defines the list of "defines" to update.
  103667. * @param scene defines the scene the material belongs to.
  103668. * @returns - boolean indicating that the submesh is ready or not.
  103669. */
  103670. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  103671. /**
  103672. * Checks to see if a texture is used in the material.
  103673. * @param defines the list of "defines" to update.
  103674. * @param scene defines the scene to the material belongs to.
  103675. */
  103676. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  103677. /**
  103678. * Binds the material data.
  103679. * @param uniformBuffer defines the Uniform buffer to fill in.
  103680. * @param scene defines the scene the material belongs to.
  103681. * @param engine defines the engine the material belongs to.
  103682. * @param isFrozen defines wether the material is frozen or not.
  103683. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  103684. */
  103685. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  103686. /**
  103687. * Unbinds the material from the mesh.
  103688. * @param activeEffect defines the effect that should be unbound from.
  103689. * @returns true if unbound, otherwise false
  103690. */
  103691. unbind(activeEffect: Effect): boolean;
  103692. /**
  103693. * Returns the texture used for refraction or null if none is used.
  103694. * @param scene defines the scene the material belongs to.
  103695. * @returns - Refraction texture if present. If no refraction texture and refraction
  103696. * is linked with transparency, returns environment texture. Otherwise, returns null.
  103697. */
  103698. private _getRefractionTexture;
  103699. /**
  103700. * Returns true if alpha blending should be disabled.
  103701. */
  103702. readonly disableAlphaBlending: boolean;
  103703. /**
  103704. * Fills the list of render target textures.
  103705. * @param renderTargets the list of render targets to update
  103706. */
  103707. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  103708. /**
  103709. * Checks to see if a texture is used in the material.
  103710. * @param texture - Base texture to use.
  103711. * @returns - Boolean specifying if a texture is used in the material.
  103712. */
  103713. hasTexture(texture: BaseTexture): boolean;
  103714. /**
  103715. * Gets a boolean indicating that current material needs to register RTT
  103716. * @returns true if this uses a render target otherwise false.
  103717. */
  103718. hasRenderTargetTextures(): boolean;
  103719. /**
  103720. * Returns an array of the actively used textures.
  103721. * @param activeTextures Array of BaseTextures
  103722. */
  103723. getActiveTextures(activeTextures: BaseTexture[]): void;
  103724. /**
  103725. * Returns the animatable textures.
  103726. * @param animatables Array of animatable textures.
  103727. */
  103728. getAnimatables(animatables: IAnimatable[]): void;
  103729. /**
  103730. * Disposes the resources of the material.
  103731. * @param forceDisposeTextures - Forces the disposal of all textures.
  103732. */
  103733. dispose(forceDisposeTextures?: boolean): void;
  103734. /**
  103735. * Get the current class name of the texture useful for serialization or dynamic coding.
  103736. * @returns "PBRSubSurfaceConfiguration"
  103737. */
  103738. getClassName(): string;
  103739. /**
  103740. * Add fallbacks to the effect fallbacks list.
  103741. * @param defines defines the Base texture to use.
  103742. * @param fallbacks defines the current fallback list.
  103743. * @param currentRank defines the current fallback rank.
  103744. * @returns the new fallback rank.
  103745. */
  103746. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103747. /**
  103748. * Add the required uniforms to the current list.
  103749. * @param uniforms defines the current uniform list.
  103750. */
  103751. static AddUniforms(uniforms: string[]): void;
  103752. /**
  103753. * Add the required samplers to the current list.
  103754. * @param samplers defines the current sampler list.
  103755. */
  103756. static AddSamplers(samplers: string[]): void;
  103757. /**
  103758. * Add the required uniforms to the current buffer.
  103759. * @param uniformBuffer defines the current uniform buffer.
  103760. */
  103761. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103762. /**
  103763. * Makes a duplicate of the current configuration into another one.
  103764. * @param configuration define the config where to copy the info
  103765. */
  103766. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  103767. /**
  103768. * Serializes this Sub Surface configuration.
  103769. * @returns - An object with the serialized config.
  103770. */
  103771. serialize(): any;
  103772. /**
  103773. * Parses a Sub Surface Configuration from a serialized object.
  103774. * @param source - Serialized object.
  103775. */
  103776. parse(source: any): void;
  103777. }
  103778. }
  103779. declare module BABYLON {
  103780. /** @hidden */
  103781. export var pbrFragmentDeclaration: {
  103782. name: string;
  103783. shader: string;
  103784. };
  103785. }
  103786. declare module BABYLON {
  103787. /** @hidden */
  103788. export var pbrUboDeclaration: {
  103789. name: string;
  103790. shader: string;
  103791. };
  103792. }
  103793. declare module BABYLON {
  103794. /** @hidden */
  103795. export var pbrFragmentExtraDeclaration: {
  103796. name: string;
  103797. shader: string;
  103798. };
  103799. }
  103800. declare module BABYLON {
  103801. /** @hidden */
  103802. export var pbrFragmentSamplersDeclaration: {
  103803. name: string;
  103804. shader: string;
  103805. };
  103806. }
  103807. declare module BABYLON {
  103808. /** @hidden */
  103809. export var pbrHelperFunctions: {
  103810. name: string;
  103811. shader: string;
  103812. };
  103813. }
  103814. declare module BABYLON {
  103815. /** @hidden */
  103816. export var harmonicsFunctions: {
  103817. name: string;
  103818. shader: string;
  103819. };
  103820. }
  103821. declare module BABYLON {
  103822. /** @hidden */
  103823. export var pbrDirectLightingSetupFunctions: {
  103824. name: string;
  103825. shader: string;
  103826. };
  103827. }
  103828. declare module BABYLON {
  103829. /** @hidden */
  103830. export var pbrDirectLightingFalloffFunctions: {
  103831. name: string;
  103832. shader: string;
  103833. };
  103834. }
  103835. declare module BABYLON {
  103836. /** @hidden */
  103837. export var pbrBRDFFunctions: {
  103838. name: string;
  103839. shader: string;
  103840. };
  103841. }
  103842. declare module BABYLON {
  103843. /** @hidden */
  103844. export var pbrDirectLightingFunctions: {
  103845. name: string;
  103846. shader: string;
  103847. };
  103848. }
  103849. declare module BABYLON {
  103850. /** @hidden */
  103851. export var pbrIBLFunctions: {
  103852. name: string;
  103853. shader: string;
  103854. };
  103855. }
  103856. declare module BABYLON {
  103857. /** @hidden */
  103858. export var pbrDebug: {
  103859. name: string;
  103860. shader: string;
  103861. };
  103862. }
  103863. declare module BABYLON {
  103864. /** @hidden */
  103865. export var pbrPixelShader: {
  103866. name: string;
  103867. shader: string;
  103868. };
  103869. }
  103870. declare module BABYLON {
  103871. /** @hidden */
  103872. export var pbrVertexDeclaration: {
  103873. name: string;
  103874. shader: string;
  103875. };
  103876. }
  103877. declare module BABYLON {
  103878. /** @hidden */
  103879. export var pbrVertexShader: {
  103880. name: string;
  103881. shader: string;
  103882. };
  103883. }
  103884. declare module BABYLON {
  103885. /**
  103886. * Manages the defines for the PBR Material.
  103887. * @hidden
  103888. */
  103889. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  103890. PBR: boolean;
  103891. MAINUV1: boolean;
  103892. MAINUV2: boolean;
  103893. UV1: boolean;
  103894. UV2: boolean;
  103895. ALBEDO: boolean;
  103896. ALBEDODIRECTUV: number;
  103897. VERTEXCOLOR: boolean;
  103898. AMBIENT: boolean;
  103899. AMBIENTDIRECTUV: number;
  103900. AMBIENTINGRAYSCALE: boolean;
  103901. OPACITY: boolean;
  103902. VERTEXALPHA: boolean;
  103903. OPACITYDIRECTUV: number;
  103904. OPACITYRGB: boolean;
  103905. ALPHATEST: boolean;
  103906. DEPTHPREPASS: boolean;
  103907. ALPHABLEND: boolean;
  103908. ALPHAFROMALBEDO: boolean;
  103909. ALPHATESTVALUE: string;
  103910. SPECULAROVERALPHA: boolean;
  103911. RADIANCEOVERALPHA: boolean;
  103912. ALPHAFRESNEL: boolean;
  103913. LINEARALPHAFRESNEL: boolean;
  103914. PREMULTIPLYALPHA: boolean;
  103915. EMISSIVE: boolean;
  103916. EMISSIVEDIRECTUV: number;
  103917. REFLECTIVITY: boolean;
  103918. REFLECTIVITYDIRECTUV: number;
  103919. SPECULARTERM: boolean;
  103920. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  103921. MICROSURFACEAUTOMATIC: boolean;
  103922. LODBASEDMICROSFURACE: boolean;
  103923. MICROSURFACEMAP: boolean;
  103924. MICROSURFACEMAPDIRECTUV: number;
  103925. METALLICWORKFLOW: boolean;
  103926. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  103927. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  103928. METALLNESSSTOREINMETALMAPBLUE: boolean;
  103929. AOSTOREINMETALMAPRED: boolean;
  103930. ENVIRONMENTBRDF: boolean;
  103931. ENVIRONMENTBRDF_RGBD: boolean;
  103932. NORMAL: boolean;
  103933. TANGENT: boolean;
  103934. BUMP: boolean;
  103935. BUMPDIRECTUV: number;
  103936. OBJECTSPACE_NORMALMAP: boolean;
  103937. PARALLAX: boolean;
  103938. PARALLAXOCCLUSION: boolean;
  103939. NORMALXYSCALE: boolean;
  103940. LIGHTMAP: boolean;
  103941. LIGHTMAPDIRECTUV: number;
  103942. USELIGHTMAPASSHADOWMAP: boolean;
  103943. GAMMALIGHTMAP: boolean;
  103944. REFLECTION: boolean;
  103945. REFLECTIONMAP_3D: boolean;
  103946. REFLECTIONMAP_SPHERICAL: boolean;
  103947. REFLECTIONMAP_PLANAR: boolean;
  103948. REFLECTIONMAP_CUBIC: boolean;
  103949. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  103950. REFLECTIONMAP_PROJECTION: boolean;
  103951. REFLECTIONMAP_SKYBOX: boolean;
  103952. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  103953. REFLECTIONMAP_EXPLICIT: boolean;
  103954. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  103955. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  103956. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  103957. INVERTCUBICMAP: boolean;
  103958. USESPHERICALFROMREFLECTIONMAP: boolean;
  103959. USESPHERICALINVERTEX: boolean;
  103960. REFLECTIONMAP_OPPOSITEZ: boolean;
  103961. LODINREFLECTIONALPHA: boolean;
  103962. GAMMAREFLECTION: boolean;
  103963. RGBDREFLECTION: boolean;
  103964. RADIANCEOCCLUSION: boolean;
  103965. HORIZONOCCLUSION: boolean;
  103966. INSTANCES: boolean;
  103967. NUM_BONE_INFLUENCERS: number;
  103968. BonesPerMesh: number;
  103969. BONETEXTURE: boolean;
  103970. NONUNIFORMSCALING: boolean;
  103971. MORPHTARGETS: boolean;
  103972. MORPHTARGETS_NORMAL: boolean;
  103973. MORPHTARGETS_TANGENT: boolean;
  103974. NUM_MORPH_INFLUENCERS: number;
  103975. IMAGEPROCESSING: boolean;
  103976. VIGNETTE: boolean;
  103977. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103978. VIGNETTEBLENDMODEOPAQUE: boolean;
  103979. TONEMAPPING: boolean;
  103980. TONEMAPPING_ACES: boolean;
  103981. CONTRAST: boolean;
  103982. COLORCURVES: boolean;
  103983. COLORGRADING: boolean;
  103984. COLORGRADING3D: boolean;
  103985. SAMPLER3DGREENDEPTH: boolean;
  103986. SAMPLER3DBGRMAP: boolean;
  103987. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103988. EXPOSURE: boolean;
  103989. MULTIVIEW: boolean;
  103990. USEPHYSICALLIGHTFALLOFF: boolean;
  103991. USEGLTFLIGHTFALLOFF: boolean;
  103992. TWOSIDEDLIGHTING: boolean;
  103993. SHADOWFLOAT: boolean;
  103994. CLIPPLANE: boolean;
  103995. CLIPPLANE2: boolean;
  103996. CLIPPLANE3: boolean;
  103997. CLIPPLANE4: boolean;
  103998. POINTSIZE: boolean;
  103999. FOG: boolean;
  104000. LOGARITHMICDEPTH: boolean;
  104001. FORCENORMALFORWARD: boolean;
  104002. SPECULARAA: boolean;
  104003. CLEARCOAT: boolean;
  104004. CLEARCOAT_DEFAULTIOR: boolean;
  104005. CLEARCOAT_TEXTURE: boolean;
  104006. CLEARCOAT_TEXTUREDIRECTUV: number;
  104007. CLEARCOAT_BUMP: boolean;
  104008. CLEARCOAT_BUMPDIRECTUV: number;
  104009. CLEARCOAT_TINT: boolean;
  104010. CLEARCOAT_TINT_TEXTURE: boolean;
  104011. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  104012. ANISOTROPIC: boolean;
  104013. ANISOTROPIC_TEXTURE: boolean;
  104014. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104015. BRDF_V_HEIGHT_CORRELATED: boolean;
  104016. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104017. SHEEN: boolean;
  104018. SHEEN_TEXTURE: boolean;
  104019. SHEEN_TEXTUREDIRECTUV: number;
  104020. SHEEN_LINKWITHALBEDO: boolean;
  104021. SUBSURFACE: boolean;
  104022. SS_REFRACTION: boolean;
  104023. SS_TRANSLUCENCY: boolean;
  104024. SS_SCATERRING: boolean;
  104025. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104026. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104027. SS_REFRACTIONMAP_3D: boolean;
  104028. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104029. SS_LODINREFRACTIONALPHA: boolean;
  104030. SS_GAMMAREFRACTION: boolean;
  104031. SS_RGBDREFRACTION: boolean;
  104032. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104033. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104034. UNLIT: boolean;
  104035. DEBUGMODE: number;
  104036. /**
  104037. * Initializes the PBR Material defines.
  104038. */
  104039. constructor();
  104040. /**
  104041. * Resets the PBR Material defines.
  104042. */
  104043. reset(): void;
  104044. }
  104045. /**
  104046. * The Physically based material base class of BJS.
  104047. *
  104048. * This offers the main features of a standard PBR material.
  104049. * For more information, please refer to the documentation :
  104050. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104051. */
  104052. export abstract class PBRBaseMaterial extends PushMaterial {
  104053. /**
  104054. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104055. */
  104056. static readonly PBRMATERIAL_OPAQUE: number;
  104057. /**
  104058. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104059. */
  104060. static readonly PBRMATERIAL_ALPHATEST: number;
  104061. /**
  104062. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104063. */
  104064. static readonly PBRMATERIAL_ALPHABLEND: number;
  104065. /**
  104066. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104067. * They are also discarded below the alpha cutoff threshold to improve performances.
  104068. */
  104069. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  104070. /**
  104071. * Defines the default value of how much AO map is occluding the analytical lights
  104072. * (point spot...).
  104073. */
  104074. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  104075. /**
  104076. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  104077. */
  104078. static readonly LIGHTFALLOFF_PHYSICAL: number;
  104079. /**
  104080. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  104081. * to enhance interoperability with other engines.
  104082. */
  104083. static readonly LIGHTFALLOFF_GLTF: number;
  104084. /**
  104085. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  104086. * to enhance interoperability with other materials.
  104087. */
  104088. static readonly LIGHTFALLOFF_STANDARD: number;
  104089. /**
  104090. * Intensity of the direct lights e.g. the four lights available in your scene.
  104091. * This impacts both the direct diffuse and specular highlights.
  104092. */
  104093. protected _directIntensity: number;
  104094. /**
  104095. * Intensity of the emissive part of the material.
  104096. * This helps controlling the emissive effect without modifying the emissive color.
  104097. */
  104098. protected _emissiveIntensity: number;
  104099. /**
  104100. * Intensity of the environment e.g. how much the environment will light the object
  104101. * either through harmonics for rough material or through the refelction for shiny ones.
  104102. */
  104103. protected _environmentIntensity: number;
  104104. /**
  104105. * This is a special control allowing the reduction of the specular highlights coming from the
  104106. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  104107. */
  104108. protected _specularIntensity: number;
  104109. /**
  104110. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  104111. */
  104112. private _lightingInfos;
  104113. /**
  104114. * Debug Control allowing disabling the bump map on this material.
  104115. */
  104116. protected _disableBumpMap: boolean;
  104117. /**
  104118. * AKA Diffuse Texture in standard nomenclature.
  104119. */
  104120. protected _albedoTexture: BaseTexture;
  104121. /**
  104122. * AKA Occlusion Texture in other nomenclature.
  104123. */
  104124. protected _ambientTexture: BaseTexture;
  104125. /**
  104126. * AKA Occlusion Texture Intensity in other nomenclature.
  104127. */
  104128. protected _ambientTextureStrength: number;
  104129. /**
  104130. * Defines how much the AO map is occluding the analytical lights (point spot...).
  104131. * 1 means it completely occludes it
  104132. * 0 mean it has no impact
  104133. */
  104134. protected _ambientTextureImpactOnAnalyticalLights: number;
  104135. /**
  104136. * Stores the alpha values in a texture.
  104137. */
  104138. protected _opacityTexture: BaseTexture;
  104139. /**
  104140. * Stores the reflection values in a texture.
  104141. */
  104142. protected _reflectionTexture: BaseTexture;
  104143. /**
  104144. * Stores the emissive values in a texture.
  104145. */
  104146. protected _emissiveTexture: BaseTexture;
  104147. /**
  104148. * AKA Specular texture in other nomenclature.
  104149. */
  104150. protected _reflectivityTexture: BaseTexture;
  104151. /**
  104152. * Used to switch from specular/glossiness to metallic/roughness workflow.
  104153. */
  104154. protected _metallicTexture: BaseTexture;
  104155. /**
  104156. * Specifies the metallic scalar of the metallic/roughness workflow.
  104157. * Can also be used to scale the metalness values of the metallic texture.
  104158. */
  104159. protected _metallic: Nullable<number>;
  104160. /**
  104161. * Specifies the roughness scalar of the metallic/roughness workflow.
  104162. * Can also be used to scale the roughness values of the metallic texture.
  104163. */
  104164. protected _roughness: Nullable<number>;
  104165. /**
  104166. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  104167. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  104168. */
  104169. protected _microSurfaceTexture: BaseTexture;
  104170. /**
  104171. * Stores surface normal data used to displace a mesh in a texture.
  104172. */
  104173. protected _bumpTexture: BaseTexture;
  104174. /**
  104175. * Stores the pre-calculated light information of a mesh in a texture.
  104176. */
  104177. protected _lightmapTexture: BaseTexture;
  104178. /**
  104179. * The color of a material in ambient lighting.
  104180. */
  104181. protected _ambientColor: Color3;
  104182. /**
  104183. * AKA Diffuse Color in other nomenclature.
  104184. */
  104185. protected _albedoColor: Color3;
  104186. /**
  104187. * AKA Specular Color in other nomenclature.
  104188. */
  104189. protected _reflectivityColor: Color3;
  104190. /**
  104191. * The color applied when light is reflected from a material.
  104192. */
  104193. protected _reflectionColor: Color3;
  104194. /**
  104195. * The color applied when light is emitted from a material.
  104196. */
  104197. protected _emissiveColor: Color3;
  104198. /**
  104199. * AKA Glossiness in other nomenclature.
  104200. */
  104201. protected _microSurface: number;
  104202. /**
  104203. * Specifies that the material will use the light map as a show map.
  104204. */
  104205. protected _useLightmapAsShadowmap: boolean;
  104206. /**
  104207. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  104208. * makes the reflect vector face the model (under horizon).
  104209. */
  104210. protected _useHorizonOcclusion: boolean;
  104211. /**
  104212. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  104213. * too much the area relying on ambient texture to define their ambient occlusion.
  104214. */
  104215. protected _useRadianceOcclusion: boolean;
  104216. /**
  104217. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  104218. */
  104219. protected _useAlphaFromAlbedoTexture: boolean;
  104220. /**
  104221. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  104222. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104223. */
  104224. protected _useSpecularOverAlpha: boolean;
  104225. /**
  104226. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  104227. */
  104228. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  104229. /**
  104230. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  104231. */
  104232. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  104233. /**
  104234. * Specifies if the metallic texture contains the roughness information in its green channel.
  104235. */
  104236. protected _useRoughnessFromMetallicTextureGreen: boolean;
  104237. /**
  104238. * Specifies if the metallic texture contains the metallness information in its blue channel.
  104239. */
  104240. protected _useMetallnessFromMetallicTextureBlue: boolean;
  104241. /**
  104242. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  104243. */
  104244. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  104245. /**
  104246. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  104247. */
  104248. protected _useAmbientInGrayScale: boolean;
  104249. /**
  104250. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  104251. * The material will try to infer what glossiness each pixel should be.
  104252. */
  104253. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  104254. /**
  104255. * Defines the falloff type used in this material.
  104256. * It by default is Physical.
  104257. */
  104258. protected _lightFalloff: number;
  104259. /**
  104260. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104261. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104262. */
  104263. protected _useRadianceOverAlpha: boolean;
  104264. /**
  104265. * Allows using an object space normal map (instead of tangent space).
  104266. */
  104267. protected _useObjectSpaceNormalMap: boolean;
  104268. /**
  104269. * Allows using the bump map in parallax mode.
  104270. */
  104271. protected _useParallax: boolean;
  104272. /**
  104273. * Allows using the bump map in parallax occlusion mode.
  104274. */
  104275. protected _useParallaxOcclusion: boolean;
  104276. /**
  104277. * Controls the scale bias of the parallax mode.
  104278. */
  104279. protected _parallaxScaleBias: number;
  104280. /**
  104281. * If sets to true, disables all the lights affecting the material.
  104282. */
  104283. protected _disableLighting: boolean;
  104284. /**
  104285. * Number of Simultaneous lights allowed on the material.
  104286. */
  104287. protected _maxSimultaneousLights: number;
  104288. /**
  104289. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  104290. */
  104291. protected _invertNormalMapX: boolean;
  104292. /**
  104293. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  104294. */
  104295. protected _invertNormalMapY: boolean;
  104296. /**
  104297. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104298. */
  104299. protected _twoSidedLighting: boolean;
  104300. /**
  104301. * Defines the alpha limits in alpha test mode.
  104302. */
  104303. protected _alphaCutOff: number;
  104304. /**
  104305. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104306. */
  104307. protected _forceAlphaTest: boolean;
  104308. /**
  104309. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104310. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  104311. */
  104312. protected _useAlphaFresnel: boolean;
  104313. /**
  104314. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104315. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  104316. */
  104317. protected _useLinearAlphaFresnel: boolean;
  104318. /**
  104319. * The transparency mode of the material.
  104320. */
  104321. protected _transparencyMode: Nullable<number>;
  104322. /**
  104323. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  104324. * from cos thetav and roughness:
  104325. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  104326. */
  104327. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  104328. /**
  104329. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  104330. */
  104331. protected _forceIrradianceInFragment: boolean;
  104332. /**
  104333. * Force normal to face away from face.
  104334. */
  104335. protected _forceNormalForward: boolean;
  104336. /**
  104337. * Enables specular anti aliasing in the PBR shader.
  104338. * It will both interacts on the Geometry for analytical and IBL lighting.
  104339. * It also prefilter the roughness map based on the bump values.
  104340. */
  104341. protected _enableSpecularAntiAliasing: boolean;
  104342. /**
  104343. * Default configuration related to image processing available in the PBR Material.
  104344. */
  104345. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104346. /**
  104347. * Keep track of the image processing observer to allow dispose and replace.
  104348. */
  104349. private _imageProcessingObserver;
  104350. /**
  104351. * Attaches a new image processing configuration to the PBR Material.
  104352. * @param configuration
  104353. */
  104354. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104355. /**
  104356. * Stores the available render targets.
  104357. */
  104358. private _renderTargets;
  104359. /**
  104360. * Sets the global ambient color for the material used in lighting calculations.
  104361. */
  104362. private _globalAmbientColor;
  104363. /**
  104364. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  104365. */
  104366. private _useLogarithmicDepth;
  104367. /**
  104368. * If set to true, no lighting calculations will be applied.
  104369. */
  104370. private _unlit;
  104371. private _debugMode;
  104372. /**
  104373. * @hidden
  104374. * This is reserved for the inspector.
  104375. * Defines the material debug mode.
  104376. * It helps seeing only some components of the material while troubleshooting.
  104377. */
  104378. debugMode: number;
  104379. /**
  104380. * @hidden
  104381. * This is reserved for the inspector.
  104382. * Specify from where on screen the debug mode should start.
  104383. * The value goes from -1 (full screen) to 1 (not visible)
  104384. * It helps with side by side comparison against the final render
  104385. * This defaults to -1
  104386. */
  104387. private debugLimit;
  104388. /**
  104389. * @hidden
  104390. * This is reserved for the inspector.
  104391. * As the default viewing range might not be enough (if the ambient is really small for instance)
  104392. * You can use the factor to better multiply the final value.
  104393. */
  104394. private debugFactor;
  104395. /**
  104396. * Defines the clear coat layer parameters for the material.
  104397. */
  104398. readonly clearCoat: PBRClearCoatConfiguration;
  104399. /**
  104400. * Defines the anisotropic parameters for the material.
  104401. */
  104402. readonly anisotropy: PBRAnisotropicConfiguration;
  104403. /**
  104404. * Defines the BRDF parameters for the material.
  104405. */
  104406. readonly brdf: PBRBRDFConfiguration;
  104407. /**
  104408. * Defines the Sheen parameters for the material.
  104409. */
  104410. readonly sheen: PBRSheenConfiguration;
  104411. /**
  104412. * Defines the SubSurface parameters for the material.
  104413. */
  104414. readonly subSurface: PBRSubSurfaceConfiguration;
  104415. /**
  104416. * Custom callback helping to override the default shader used in the material.
  104417. */
  104418. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  104419. /**
  104420. * Instantiates a new PBRMaterial instance.
  104421. *
  104422. * @param name The material name
  104423. * @param scene The scene the material will be use in.
  104424. */
  104425. constructor(name: string, scene: Scene);
  104426. /**
  104427. * Gets a boolean indicating that current material needs to register RTT
  104428. */
  104429. readonly hasRenderTargetTextures: boolean;
  104430. /**
  104431. * Gets the name of the material class.
  104432. */
  104433. getClassName(): string;
  104434. /**
  104435. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  104436. */
  104437. /**
  104438. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  104439. */
  104440. useLogarithmicDepth: boolean;
  104441. /**
  104442. * Gets the current transparency mode.
  104443. */
  104444. /**
  104445. * Sets the transparency mode of the material.
  104446. *
  104447. * | Value | Type | Description |
  104448. * | ----- | ----------------------------------- | ----------- |
  104449. * | 0 | OPAQUE | |
  104450. * | 1 | ALPHATEST | |
  104451. * | 2 | ALPHABLEND | |
  104452. * | 3 | ALPHATESTANDBLEND | |
  104453. *
  104454. */
  104455. transparencyMode: Nullable<number>;
  104456. /**
  104457. * Returns true if alpha blending should be disabled.
  104458. */
  104459. private readonly _disableAlphaBlending;
  104460. /**
  104461. * Specifies whether or not this material should be rendered in alpha blend mode.
  104462. */
  104463. needAlphaBlending(): boolean;
  104464. /**
  104465. * Specifies if the mesh will require alpha blending.
  104466. * @param mesh - BJS mesh.
  104467. */
  104468. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  104469. /**
  104470. * Specifies whether or not this material should be rendered in alpha test mode.
  104471. */
  104472. needAlphaTesting(): boolean;
  104473. /**
  104474. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  104475. */
  104476. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  104477. /**
  104478. * Gets the texture used for the alpha test.
  104479. */
  104480. getAlphaTestTexture(): BaseTexture;
  104481. /**
  104482. * Specifies that the submesh is ready to be used.
  104483. * @param mesh - BJS mesh.
  104484. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  104485. * @param useInstances - Specifies that instances should be used.
  104486. * @returns - boolean indicating that the submesh is ready or not.
  104487. */
  104488. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104489. /**
  104490. * Specifies if the material uses metallic roughness workflow.
  104491. * @returns boolean specifiying if the material uses metallic roughness workflow.
  104492. */
  104493. isMetallicWorkflow(): boolean;
  104494. private _prepareEffect;
  104495. private _prepareDefines;
  104496. /**
  104497. * Force shader compilation
  104498. */
  104499. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  104500. clipPlane: boolean;
  104501. }>): void;
  104502. /**
  104503. * Initializes the uniform buffer layout for the shader.
  104504. */
  104505. buildUniformLayout(): void;
  104506. /**
  104507. * Unbinds the material from the mesh
  104508. */
  104509. unbind(): void;
  104510. /**
  104511. * Binds the submesh data.
  104512. * @param world - The world matrix.
  104513. * @param mesh - The BJS mesh.
  104514. * @param subMesh - A submesh of the BJS mesh.
  104515. */
  104516. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104517. /**
  104518. * Returns the animatable textures.
  104519. * @returns - Array of animatable textures.
  104520. */
  104521. getAnimatables(): IAnimatable[];
  104522. /**
  104523. * Returns the texture used for reflections.
  104524. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  104525. */
  104526. private _getReflectionTexture;
  104527. /**
  104528. * Returns an array of the actively used textures.
  104529. * @returns - Array of BaseTextures
  104530. */
  104531. getActiveTextures(): BaseTexture[];
  104532. /**
  104533. * Checks to see if a texture is used in the material.
  104534. * @param texture - Base texture to use.
  104535. * @returns - Boolean specifying if a texture is used in the material.
  104536. */
  104537. hasTexture(texture: BaseTexture): boolean;
  104538. /**
  104539. * Disposes the resources of the material.
  104540. * @param forceDisposeEffect - Forces the disposal of effects.
  104541. * @param forceDisposeTextures - Forces the disposal of all textures.
  104542. */
  104543. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  104544. }
  104545. }
  104546. declare module BABYLON {
  104547. /**
  104548. * The Physically based material of BJS.
  104549. *
  104550. * This offers the main features of a standard PBR material.
  104551. * For more information, please refer to the documentation :
  104552. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104553. */
  104554. export class PBRMaterial extends PBRBaseMaterial {
  104555. /**
  104556. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104557. */
  104558. static readonly PBRMATERIAL_OPAQUE: number;
  104559. /**
  104560. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104561. */
  104562. static readonly PBRMATERIAL_ALPHATEST: number;
  104563. /**
  104564. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104565. */
  104566. static readonly PBRMATERIAL_ALPHABLEND: number;
  104567. /**
  104568. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104569. * They are also discarded below the alpha cutoff threshold to improve performances.
  104570. */
  104571. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  104572. /**
  104573. * Defines the default value of how much AO map is occluding the analytical lights
  104574. * (point spot...).
  104575. */
  104576. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  104577. /**
  104578. * Intensity of the direct lights e.g. the four lights available in your scene.
  104579. * This impacts both the direct diffuse and specular highlights.
  104580. */
  104581. directIntensity: number;
  104582. /**
  104583. * Intensity of the emissive part of the material.
  104584. * This helps controlling the emissive effect without modifying the emissive color.
  104585. */
  104586. emissiveIntensity: number;
  104587. /**
  104588. * Intensity of the environment e.g. how much the environment will light the object
  104589. * either through harmonics for rough material or through the refelction for shiny ones.
  104590. */
  104591. environmentIntensity: number;
  104592. /**
  104593. * This is a special control allowing the reduction of the specular highlights coming from the
  104594. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  104595. */
  104596. specularIntensity: number;
  104597. /**
  104598. * Debug Control allowing disabling the bump map on this material.
  104599. */
  104600. disableBumpMap: boolean;
  104601. /**
  104602. * AKA Diffuse Texture in standard nomenclature.
  104603. */
  104604. albedoTexture: BaseTexture;
  104605. /**
  104606. * AKA Occlusion Texture in other nomenclature.
  104607. */
  104608. ambientTexture: BaseTexture;
  104609. /**
  104610. * AKA Occlusion Texture Intensity in other nomenclature.
  104611. */
  104612. ambientTextureStrength: number;
  104613. /**
  104614. * Defines how much the AO map is occluding the analytical lights (point spot...).
  104615. * 1 means it completely occludes it
  104616. * 0 mean it has no impact
  104617. */
  104618. ambientTextureImpactOnAnalyticalLights: number;
  104619. /**
  104620. * Stores the alpha values in a texture.
  104621. */
  104622. opacityTexture: BaseTexture;
  104623. /**
  104624. * Stores the reflection values in a texture.
  104625. */
  104626. reflectionTexture: Nullable<BaseTexture>;
  104627. /**
  104628. * Stores the emissive values in a texture.
  104629. */
  104630. emissiveTexture: BaseTexture;
  104631. /**
  104632. * AKA Specular texture in other nomenclature.
  104633. */
  104634. reflectivityTexture: BaseTexture;
  104635. /**
  104636. * Used to switch from specular/glossiness to metallic/roughness workflow.
  104637. */
  104638. metallicTexture: BaseTexture;
  104639. /**
  104640. * Specifies the metallic scalar of the metallic/roughness workflow.
  104641. * Can also be used to scale the metalness values of the metallic texture.
  104642. */
  104643. metallic: Nullable<number>;
  104644. /**
  104645. * Specifies the roughness scalar of the metallic/roughness workflow.
  104646. * Can also be used to scale the roughness values of the metallic texture.
  104647. */
  104648. roughness: Nullable<number>;
  104649. /**
  104650. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  104651. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  104652. */
  104653. microSurfaceTexture: BaseTexture;
  104654. /**
  104655. * Stores surface normal data used to displace a mesh in a texture.
  104656. */
  104657. bumpTexture: BaseTexture;
  104658. /**
  104659. * Stores the pre-calculated light information of a mesh in a texture.
  104660. */
  104661. lightmapTexture: BaseTexture;
  104662. /**
  104663. * Stores the refracted light information in a texture.
  104664. */
  104665. refractionTexture: Nullable<BaseTexture>;
  104666. /**
  104667. * The color of a material in ambient lighting.
  104668. */
  104669. ambientColor: Color3;
  104670. /**
  104671. * AKA Diffuse Color in other nomenclature.
  104672. */
  104673. albedoColor: Color3;
  104674. /**
  104675. * AKA Specular Color in other nomenclature.
  104676. */
  104677. reflectivityColor: Color3;
  104678. /**
  104679. * The color reflected from the material.
  104680. */
  104681. reflectionColor: Color3;
  104682. /**
  104683. * The color emitted from the material.
  104684. */
  104685. emissiveColor: Color3;
  104686. /**
  104687. * AKA Glossiness in other nomenclature.
  104688. */
  104689. microSurface: number;
  104690. /**
  104691. * source material index of refraction (IOR)' / 'destination material IOR.
  104692. */
  104693. indexOfRefraction: number;
  104694. /**
  104695. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  104696. */
  104697. invertRefractionY: boolean;
  104698. /**
  104699. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  104700. * Materials half opaque for instance using refraction could benefit from this control.
  104701. */
  104702. linkRefractionWithTransparency: boolean;
  104703. /**
  104704. * If true, the light map contains occlusion information instead of lighting info.
  104705. */
  104706. useLightmapAsShadowmap: boolean;
  104707. /**
  104708. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  104709. */
  104710. useAlphaFromAlbedoTexture: boolean;
  104711. /**
  104712. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104713. */
  104714. forceAlphaTest: boolean;
  104715. /**
  104716. * Defines the alpha limits in alpha test mode.
  104717. */
  104718. alphaCutOff: number;
  104719. /**
  104720. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104721. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104722. */
  104723. useSpecularOverAlpha: boolean;
  104724. /**
  104725. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  104726. */
  104727. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  104728. /**
  104729. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  104730. */
  104731. useRoughnessFromMetallicTextureAlpha: boolean;
  104732. /**
  104733. * Specifies if the metallic texture contains the roughness information in its green channel.
  104734. */
  104735. useRoughnessFromMetallicTextureGreen: boolean;
  104736. /**
  104737. * Specifies if the metallic texture contains the metallness information in its blue channel.
  104738. */
  104739. useMetallnessFromMetallicTextureBlue: boolean;
  104740. /**
  104741. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  104742. */
  104743. useAmbientOcclusionFromMetallicTextureRed: boolean;
  104744. /**
  104745. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  104746. */
  104747. useAmbientInGrayScale: boolean;
  104748. /**
  104749. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  104750. * The material will try to infer what glossiness each pixel should be.
  104751. */
  104752. useAutoMicroSurfaceFromReflectivityMap: boolean;
  104753. /**
  104754. * BJS is using an harcoded light falloff based on a manually sets up range.
  104755. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  104756. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  104757. */
  104758. /**
  104759. * BJS is using an harcoded light falloff based on a manually sets up range.
  104760. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  104761. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  104762. */
  104763. usePhysicalLightFalloff: boolean;
  104764. /**
  104765. * In order to support the falloff compatibility with gltf, a special mode has been added
  104766. * to reproduce the gltf light falloff.
  104767. */
  104768. /**
  104769. * In order to support the falloff compatibility with gltf, a special mode has been added
  104770. * to reproduce the gltf light falloff.
  104771. */
  104772. useGLTFLightFalloff: boolean;
  104773. /**
  104774. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104775. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104776. */
  104777. useRadianceOverAlpha: boolean;
  104778. /**
  104779. * Allows using an object space normal map (instead of tangent space).
  104780. */
  104781. useObjectSpaceNormalMap: boolean;
  104782. /**
  104783. * Allows using the bump map in parallax mode.
  104784. */
  104785. useParallax: boolean;
  104786. /**
  104787. * Allows using the bump map in parallax occlusion mode.
  104788. */
  104789. useParallaxOcclusion: boolean;
  104790. /**
  104791. * Controls the scale bias of the parallax mode.
  104792. */
  104793. parallaxScaleBias: number;
  104794. /**
  104795. * If sets to true, disables all the lights affecting the material.
  104796. */
  104797. disableLighting: boolean;
  104798. /**
  104799. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  104800. */
  104801. forceIrradianceInFragment: boolean;
  104802. /**
  104803. * Number of Simultaneous lights allowed on the material.
  104804. */
  104805. maxSimultaneousLights: number;
  104806. /**
  104807. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104808. */
  104809. invertNormalMapX: boolean;
  104810. /**
  104811. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104812. */
  104813. invertNormalMapY: boolean;
  104814. /**
  104815. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104816. */
  104817. twoSidedLighting: boolean;
  104818. /**
  104819. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104820. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  104821. */
  104822. useAlphaFresnel: boolean;
  104823. /**
  104824. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104825. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  104826. */
  104827. useLinearAlphaFresnel: boolean;
  104828. /**
  104829. * Let user defines the brdf lookup texture used for IBL.
  104830. * A default 8bit version is embedded but you could point at :
  104831. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  104832. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  104833. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  104834. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  104835. */
  104836. environmentBRDFTexture: Nullable<BaseTexture>;
  104837. /**
  104838. * Force normal to face away from face.
  104839. */
  104840. forceNormalForward: boolean;
  104841. /**
  104842. * Enables specular anti aliasing in the PBR shader.
  104843. * It will both interacts on the Geometry for analytical and IBL lighting.
  104844. * It also prefilter the roughness map based on the bump values.
  104845. */
  104846. enableSpecularAntiAliasing: boolean;
  104847. /**
  104848. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  104849. * makes the reflect vector face the model (under horizon).
  104850. */
  104851. useHorizonOcclusion: boolean;
  104852. /**
  104853. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  104854. * too much the area relying on ambient texture to define their ambient occlusion.
  104855. */
  104856. useRadianceOcclusion: boolean;
  104857. /**
  104858. * If set to true, no lighting calculations will be applied.
  104859. */
  104860. unlit: boolean;
  104861. /**
  104862. * Gets the image processing configuration used either in this material.
  104863. */
  104864. /**
  104865. * Sets the Default image processing configuration used either in the this material.
  104866. *
  104867. * If sets to null, the scene one is in use.
  104868. */
  104869. imageProcessingConfiguration: ImageProcessingConfiguration;
  104870. /**
  104871. * Gets wether the color curves effect is enabled.
  104872. */
  104873. /**
  104874. * Sets wether the color curves effect is enabled.
  104875. */
  104876. cameraColorCurvesEnabled: boolean;
  104877. /**
  104878. * Gets wether the color grading effect is enabled.
  104879. */
  104880. /**
  104881. * Gets wether the color grading effect is enabled.
  104882. */
  104883. cameraColorGradingEnabled: boolean;
  104884. /**
  104885. * Gets wether tonemapping is enabled or not.
  104886. */
  104887. /**
  104888. * Sets wether tonemapping is enabled or not
  104889. */
  104890. cameraToneMappingEnabled: boolean;
  104891. /**
  104892. * The camera exposure used on this material.
  104893. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104894. * This corresponds to a photographic exposure.
  104895. */
  104896. /**
  104897. * The camera exposure used on this material.
  104898. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104899. * This corresponds to a photographic exposure.
  104900. */
  104901. cameraExposure: number;
  104902. /**
  104903. * Gets The camera contrast used on this material.
  104904. */
  104905. /**
  104906. * Sets The camera contrast used on this material.
  104907. */
  104908. cameraContrast: number;
  104909. /**
  104910. * Gets the Color Grading 2D Lookup Texture.
  104911. */
  104912. /**
  104913. * Sets the Color Grading 2D Lookup Texture.
  104914. */
  104915. cameraColorGradingTexture: Nullable<BaseTexture>;
  104916. /**
  104917. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104918. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104919. * 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;
  104920. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104921. */
  104922. /**
  104923. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104924. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104925. * 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;
  104926. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104927. */
  104928. cameraColorCurves: Nullable<ColorCurves>;
  104929. /**
  104930. * Instantiates a new PBRMaterial instance.
  104931. *
  104932. * @param name The material name
  104933. * @param scene The scene the material will be use in.
  104934. */
  104935. constructor(name: string, scene: Scene);
  104936. /**
  104937. * Returns the name of this material class.
  104938. */
  104939. getClassName(): string;
  104940. /**
  104941. * Makes a duplicate of the current material.
  104942. * @param name - name to use for the new material.
  104943. */
  104944. clone(name: string): PBRMaterial;
  104945. /**
  104946. * Serializes this PBR Material.
  104947. * @returns - An object with the serialized material.
  104948. */
  104949. serialize(): any;
  104950. /**
  104951. * Parses a PBR Material from a serialized object.
  104952. * @param source - Serialized object.
  104953. * @param scene - BJS scene instance.
  104954. * @param rootUrl - url for the scene object
  104955. * @returns - PBRMaterial
  104956. */
  104957. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  104958. }
  104959. }
  104960. declare module BABYLON {
  104961. /**
  104962. * Direct draw surface info
  104963. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  104964. */
  104965. export interface DDSInfo {
  104966. /**
  104967. * Width of the texture
  104968. */
  104969. width: number;
  104970. /**
  104971. * Width of the texture
  104972. */
  104973. height: number;
  104974. /**
  104975. * Number of Mipmaps for the texture
  104976. * @see https://en.wikipedia.org/wiki/Mipmap
  104977. */
  104978. mipmapCount: number;
  104979. /**
  104980. * If the textures format is a known fourCC format
  104981. * @see https://www.fourcc.org/
  104982. */
  104983. isFourCC: boolean;
  104984. /**
  104985. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  104986. */
  104987. isRGB: boolean;
  104988. /**
  104989. * If the texture is a lumincance format
  104990. */
  104991. isLuminance: boolean;
  104992. /**
  104993. * If this is a cube texture
  104994. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  104995. */
  104996. isCube: boolean;
  104997. /**
  104998. * If the texture is a compressed format eg. FOURCC_DXT1
  104999. */
  105000. isCompressed: boolean;
  105001. /**
  105002. * The dxgiFormat of the texture
  105003. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  105004. */
  105005. dxgiFormat: number;
  105006. /**
  105007. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  105008. */
  105009. textureType: number;
  105010. /**
  105011. * Sphericle polynomial created for the dds texture
  105012. */
  105013. sphericalPolynomial?: SphericalPolynomial;
  105014. }
  105015. /**
  105016. * Class used to provide DDS decompression tools
  105017. */
  105018. export class DDSTools {
  105019. /**
  105020. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  105021. */
  105022. static StoreLODInAlphaChannel: boolean;
  105023. /**
  105024. * Gets DDS information from an array buffer
  105025. * @param arrayBuffer defines the array buffer to read data from
  105026. * @returns the DDS information
  105027. */
  105028. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  105029. private static _FloatView;
  105030. private static _Int32View;
  105031. private static _ToHalfFloat;
  105032. private static _FromHalfFloat;
  105033. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  105034. private static _GetHalfFloatRGBAArrayBuffer;
  105035. private static _GetFloatRGBAArrayBuffer;
  105036. private static _GetFloatAsUIntRGBAArrayBuffer;
  105037. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  105038. private static _GetRGBAArrayBuffer;
  105039. private static _ExtractLongWordOrder;
  105040. private static _GetRGBArrayBuffer;
  105041. private static _GetLuminanceArrayBuffer;
  105042. /**
  105043. * Uploads DDS Levels to a Babylon Texture
  105044. * @hidden
  105045. */
  105046. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  105047. }
  105048. interface Engine {
  105049. /**
  105050. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  105051. * @param rootUrl defines the url where the file to load is located
  105052. * @param scene defines the current scene
  105053. * @param lodScale defines scale to apply to the mip map selection
  105054. * @param lodOffset defines offset to apply to the mip map selection
  105055. * @param onLoad defines an optional callback raised when the texture is loaded
  105056. * @param onError defines an optional callback raised if there is an issue to load the texture
  105057. * @param format defines the format of the data
  105058. * @param forcedExtension defines the extension to use to pick the right loader
  105059. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  105060. * @returns the cube texture as an InternalTexture
  105061. */
  105062. 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;
  105063. }
  105064. }
  105065. declare module BABYLON {
  105066. /**
  105067. * Implementation of the DDS Texture Loader.
  105068. * @hidden
  105069. */
  105070. export class _DDSTextureLoader implements IInternalTextureLoader {
  105071. /**
  105072. * Defines wether the loader supports cascade loading the different faces.
  105073. */
  105074. readonly supportCascades: boolean;
  105075. /**
  105076. * This returns if the loader support the current file information.
  105077. * @param extension defines the file extension of the file being loaded
  105078. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105079. * @param fallback defines the fallback internal texture if any
  105080. * @param isBase64 defines whether the texture is encoded as a base64
  105081. * @param isBuffer defines whether the texture data are stored as a buffer
  105082. * @returns true if the loader can load the specified file
  105083. */
  105084. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105085. /**
  105086. * Transform the url before loading if required.
  105087. * @param rootUrl the url of the texture
  105088. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105089. * @returns the transformed texture
  105090. */
  105091. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105092. /**
  105093. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105094. * @param rootUrl the url of the texture
  105095. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105096. * @returns the fallback texture
  105097. */
  105098. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105099. /**
  105100. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105101. * @param data contains the texture data
  105102. * @param texture defines the BabylonJS internal texture
  105103. * @param createPolynomials will be true if polynomials have been requested
  105104. * @param onLoad defines the callback to trigger once the texture is ready
  105105. * @param onError defines the callback to trigger in case of error
  105106. */
  105107. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105108. /**
  105109. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105110. * @param data contains the texture data
  105111. * @param texture defines the BabylonJS internal texture
  105112. * @param callback defines the method to call once ready to upload
  105113. */
  105114. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  105115. }
  105116. }
  105117. declare module BABYLON {
  105118. /** @hidden */
  105119. export var rgbdEncodePixelShader: {
  105120. name: string;
  105121. shader: string;
  105122. };
  105123. }
  105124. declare module BABYLON {
  105125. /**
  105126. * Raw texture data and descriptor sufficient for WebGL texture upload
  105127. */
  105128. export interface EnvironmentTextureInfo {
  105129. /**
  105130. * Version of the environment map
  105131. */
  105132. version: number;
  105133. /**
  105134. * Width of image
  105135. */
  105136. width: number;
  105137. /**
  105138. * Irradiance information stored in the file.
  105139. */
  105140. irradiance: any;
  105141. /**
  105142. * Specular information stored in the file.
  105143. */
  105144. specular: any;
  105145. }
  105146. /**
  105147. * Sets of helpers addressing the serialization and deserialization of environment texture
  105148. * stored in a BabylonJS env file.
  105149. * Those files are usually stored as .env files.
  105150. */
  105151. export class EnvironmentTextureTools {
  105152. /**
  105153. * Magic number identifying the env file.
  105154. */
  105155. private static _MagicBytes;
  105156. /**
  105157. * Gets the environment info from an env file.
  105158. * @param data The array buffer containing the .env bytes.
  105159. * @returns the environment file info (the json header) if successfully parsed.
  105160. */
  105161. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  105162. /**
  105163. * Creates an environment texture from a loaded cube texture.
  105164. * @param texture defines the cube texture to convert in env file
  105165. * @return a promise containing the environment data if succesfull.
  105166. */
  105167. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  105168. /**
  105169. * Creates a JSON representation of the spherical data.
  105170. * @param texture defines the texture containing the polynomials
  105171. * @return the JSON representation of the spherical info
  105172. */
  105173. private static _CreateEnvTextureIrradiance;
  105174. /**
  105175. * Uploads the texture info contained in the env file to the GPU.
  105176. * @param texture defines the internal texture to upload to
  105177. * @param arrayBuffer defines the buffer cotaining the data to load
  105178. * @param info defines the texture info retrieved through the GetEnvInfo method
  105179. * @returns a promise
  105180. */
  105181. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  105182. /**
  105183. * Uploads the levels of image data to the GPU.
  105184. * @param texture defines the internal texture to upload to
  105185. * @param imageData defines the array buffer views of image data [mipmap][face]
  105186. * @returns a promise
  105187. */
  105188. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  105189. /**
  105190. * Uploads spherical polynomials information to the texture.
  105191. * @param texture defines the texture we are trying to upload the information to
  105192. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  105193. */
  105194. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  105195. /** @hidden */
  105196. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  105197. }
  105198. }
  105199. declare module BABYLON {
  105200. /**
  105201. * Implementation of the ENV Texture Loader.
  105202. * @hidden
  105203. */
  105204. export class _ENVTextureLoader implements IInternalTextureLoader {
  105205. /**
  105206. * Defines wether the loader supports cascade loading the different faces.
  105207. */
  105208. readonly supportCascades: boolean;
  105209. /**
  105210. * This returns if the loader support the current file information.
  105211. * @param extension defines the file extension of the file being loaded
  105212. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105213. * @param fallback defines the fallback internal texture if any
  105214. * @param isBase64 defines whether the texture is encoded as a base64
  105215. * @param isBuffer defines whether the texture data are stored as a buffer
  105216. * @returns true if the loader can load the specified file
  105217. */
  105218. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105219. /**
  105220. * Transform the url before loading if required.
  105221. * @param rootUrl the url of the texture
  105222. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105223. * @returns the transformed texture
  105224. */
  105225. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105226. /**
  105227. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105228. * @param rootUrl the url of the texture
  105229. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105230. * @returns the fallback texture
  105231. */
  105232. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105233. /**
  105234. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105235. * @param data contains the texture data
  105236. * @param texture defines the BabylonJS internal texture
  105237. * @param createPolynomials will be true if polynomials have been requested
  105238. * @param onLoad defines the callback to trigger once the texture is ready
  105239. * @param onError defines the callback to trigger in case of error
  105240. */
  105241. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105242. /**
  105243. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105244. * @param data contains the texture data
  105245. * @param texture defines the BabylonJS internal texture
  105246. * @param callback defines the method to call once ready to upload
  105247. */
  105248. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  105249. }
  105250. }
  105251. declare module BABYLON {
  105252. /**
  105253. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  105254. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  105255. */
  105256. export class KhronosTextureContainer {
  105257. /** contents of the KTX container file */
  105258. arrayBuffer: any;
  105259. private static HEADER_LEN;
  105260. private static COMPRESSED_2D;
  105261. private static COMPRESSED_3D;
  105262. private static TEX_2D;
  105263. private static TEX_3D;
  105264. /**
  105265. * Gets the openGL type
  105266. */
  105267. glType: number;
  105268. /**
  105269. * Gets the openGL type size
  105270. */
  105271. glTypeSize: number;
  105272. /**
  105273. * Gets the openGL format
  105274. */
  105275. glFormat: number;
  105276. /**
  105277. * Gets the openGL internal format
  105278. */
  105279. glInternalFormat: number;
  105280. /**
  105281. * Gets the base internal format
  105282. */
  105283. glBaseInternalFormat: number;
  105284. /**
  105285. * Gets image width in pixel
  105286. */
  105287. pixelWidth: number;
  105288. /**
  105289. * Gets image height in pixel
  105290. */
  105291. pixelHeight: number;
  105292. /**
  105293. * Gets image depth in pixels
  105294. */
  105295. pixelDepth: number;
  105296. /**
  105297. * Gets the number of array elements
  105298. */
  105299. numberOfArrayElements: number;
  105300. /**
  105301. * Gets the number of faces
  105302. */
  105303. numberOfFaces: number;
  105304. /**
  105305. * Gets the number of mipmap levels
  105306. */
  105307. numberOfMipmapLevels: number;
  105308. /**
  105309. * Gets the bytes of key value data
  105310. */
  105311. bytesOfKeyValueData: number;
  105312. /**
  105313. * Gets the load type
  105314. */
  105315. loadType: number;
  105316. /**
  105317. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  105318. */
  105319. isInvalid: boolean;
  105320. /**
  105321. * Creates a new KhronosTextureContainer
  105322. * @param arrayBuffer contents of the KTX container file
  105323. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  105324. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  105325. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  105326. */
  105327. constructor(
  105328. /** contents of the KTX container file */
  105329. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  105330. /**
  105331. * Uploads KTX content to a Babylon Texture.
  105332. * It is assumed that the texture has already been created & is currently bound
  105333. * @hidden
  105334. */
  105335. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  105336. private _upload2DCompressedLevels;
  105337. }
  105338. }
  105339. declare module BABYLON {
  105340. /**
  105341. * Implementation of the KTX Texture Loader.
  105342. * @hidden
  105343. */
  105344. export class _KTXTextureLoader implements IInternalTextureLoader {
  105345. /**
  105346. * Defines wether the loader supports cascade loading the different faces.
  105347. */
  105348. readonly supportCascades: boolean;
  105349. /**
  105350. * This returns if the loader support the current file information.
  105351. * @param extension defines the file extension of the file being loaded
  105352. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105353. * @param fallback defines the fallback internal texture if any
  105354. * @param isBase64 defines whether the texture is encoded as a base64
  105355. * @param isBuffer defines whether the texture data are stored as a buffer
  105356. * @returns true if the loader can load the specified file
  105357. */
  105358. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105359. /**
  105360. * Transform the url before loading if required.
  105361. * @param rootUrl the url of the texture
  105362. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105363. * @returns the transformed texture
  105364. */
  105365. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105366. /**
  105367. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105368. * @param rootUrl the url of the texture
  105369. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105370. * @returns the fallback texture
  105371. */
  105372. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105373. /**
  105374. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105375. * @param data contains the texture data
  105376. * @param texture defines the BabylonJS internal texture
  105377. * @param createPolynomials will be true if polynomials have been requested
  105378. * @param onLoad defines the callback to trigger once the texture is ready
  105379. * @param onError defines the callback to trigger in case of error
  105380. */
  105381. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105382. /**
  105383. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105384. * @param data contains the texture data
  105385. * @param texture defines the BabylonJS internal texture
  105386. * @param callback defines the method to call once ready to upload
  105387. */
  105388. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  105389. }
  105390. }
  105391. declare module BABYLON {
  105392. /** @hidden */
  105393. export var _forceSceneHelpersToBundle: boolean;
  105394. interface Scene {
  105395. /**
  105396. * Creates a default light for the scene.
  105397. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  105398. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  105399. */
  105400. createDefaultLight(replace?: boolean): void;
  105401. /**
  105402. * Creates a default camera for the scene.
  105403. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  105404. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  105405. * @param replace has default false, when true replaces the active camera in the scene
  105406. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  105407. */
  105408. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  105409. /**
  105410. * Creates a default camera and a default light.
  105411. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  105412. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  105413. * @param replace has the default false, when true replaces the active camera/light in the scene
  105414. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  105415. */
  105416. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  105417. /**
  105418. * Creates a new sky box
  105419. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  105420. * @param environmentTexture defines the texture to use as environment texture
  105421. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  105422. * @param scale defines the overall scale of the skybox
  105423. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  105424. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  105425. * @returns a new mesh holding the sky box
  105426. */
  105427. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  105428. /**
  105429. * Creates a new environment
  105430. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  105431. * @param options defines the options you can use to configure the environment
  105432. * @returns the new EnvironmentHelper
  105433. */
  105434. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  105435. /**
  105436. * Creates a new VREXperienceHelper
  105437. * @see http://doc.babylonjs.com/how_to/webvr_helper
  105438. * @param webVROptions defines the options used to create the new VREXperienceHelper
  105439. * @returns a new VREXperienceHelper
  105440. */
  105441. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  105442. /**
  105443. * Creates a new XREXperienceHelper
  105444. * @see http://doc.babylonjs.com/how_to/webxr
  105445. * @returns a promise for a new XREXperienceHelper
  105446. */
  105447. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  105448. }
  105449. }
  105450. declare module BABYLON {
  105451. /**
  105452. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  105453. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  105454. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  105455. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  105456. */
  105457. export class VideoDome extends TransformNode {
  105458. /**
  105459. * Define the video source as a Monoscopic panoramic 360 video.
  105460. */
  105461. static readonly MODE_MONOSCOPIC: number;
  105462. /**
  105463. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  105464. */
  105465. static readonly MODE_TOPBOTTOM: number;
  105466. /**
  105467. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  105468. */
  105469. static readonly MODE_SIDEBYSIDE: number;
  105470. private _useDirectMapping;
  105471. /**
  105472. * The video texture being displayed on the sphere
  105473. */
  105474. protected _videoTexture: VideoTexture;
  105475. /**
  105476. * Gets the video texture being displayed on the sphere
  105477. */
  105478. readonly videoTexture: VideoTexture;
  105479. /**
  105480. * The skybox material
  105481. */
  105482. protected _material: BackgroundMaterial;
  105483. /**
  105484. * The surface used for the skybox
  105485. */
  105486. protected _mesh: Mesh;
  105487. /**
  105488. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  105489. * Also see the options.resolution property.
  105490. */
  105491. fovMultiplier: number;
  105492. private _videoMode;
  105493. /**
  105494. * Gets or set the current video mode for the video. It can be:
  105495. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  105496. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  105497. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  105498. */
  105499. videoMode: number;
  105500. /**
  105501. * Oberserver used in Stereoscopic VR Mode.
  105502. */
  105503. private _onBeforeCameraRenderObserver;
  105504. /**
  105505. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  105506. * @param name Element's name, child elements will append suffixes for their own names.
  105507. * @param urlsOrVideo defines the url(s) or the video element to use
  105508. * @param options An object containing optional or exposed sub element properties
  105509. */
  105510. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  105511. resolution?: number;
  105512. clickToPlay?: boolean;
  105513. autoPlay?: boolean;
  105514. loop?: boolean;
  105515. size?: number;
  105516. poster?: string;
  105517. faceForward?: boolean;
  105518. useDirectMapping?: boolean;
  105519. }, scene: Scene);
  105520. private _changeVideoMode;
  105521. /**
  105522. * Releases resources associated with this node.
  105523. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105524. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105525. */
  105526. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105527. }
  105528. }
  105529. declare module BABYLON {
  105530. /**
  105531. * This class can be used to get instrumentation data from a Babylon engine
  105532. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  105533. */
  105534. export class EngineInstrumentation implements IDisposable {
  105535. /**
  105536. * Define the instrumented engine.
  105537. */
  105538. engine: Engine;
  105539. private _captureGPUFrameTime;
  105540. private _gpuFrameTimeToken;
  105541. private _gpuFrameTime;
  105542. private _captureShaderCompilationTime;
  105543. private _shaderCompilationTime;
  105544. private _onBeginFrameObserver;
  105545. private _onEndFrameObserver;
  105546. private _onBeforeShaderCompilationObserver;
  105547. private _onAfterShaderCompilationObserver;
  105548. /**
  105549. * Gets the perf counter used for GPU frame time
  105550. */
  105551. readonly gpuFrameTimeCounter: PerfCounter;
  105552. /**
  105553. * Gets the GPU frame time capture status
  105554. */
  105555. /**
  105556. * Enable or disable the GPU frame time capture
  105557. */
  105558. captureGPUFrameTime: boolean;
  105559. /**
  105560. * Gets the perf counter used for shader compilation time
  105561. */
  105562. readonly shaderCompilationTimeCounter: PerfCounter;
  105563. /**
  105564. * Gets the shader compilation time capture status
  105565. */
  105566. /**
  105567. * Enable or disable the shader compilation time capture
  105568. */
  105569. captureShaderCompilationTime: boolean;
  105570. /**
  105571. * Instantiates a new engine instrumentation.
  105572. * This class can be used to get instrumentation data from a Babylon engine
  105573. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  105574. * @param engine Defines the engine to instrument
  105575. */
  105576. constructor(
  105577. /**
  105578. * Define the instrumented engine.
  105579. */
  105580. engine: Engine);
  105581. /**
  105582. * Dispose and release associated resources.
  105583. */
  105584. dispose(): void;
  105585. }
  105586. }
  105587. declare module BABYLON {
  105588. /**
  105589. * This class can be used to get instrumentation data from a Babylon engine
  105590. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  105591. */
  105592. export class SceneInstrumentation implements IDisposable {
  105593. /**
  105594. * Defines the scene to instrument
  105595. */
  105596. scene: Scene;
  105597. private _captureActiveMeshesEvaluationTime;
  105598. private _activeMeshesEvaluationTime;
  105599. private _captureRenderTargetsRenderTime;
  105600. private _renderTargetsRenderTime;
  105601. private _captureFrameTime;
  105602. private _frameTime;
  105603. private _captureRenderTime;
  105604. private _renderTime;
  105605. private _captureInterFrameTime;
  105606. private _interFrameTime;
  105607. private _captureParticlesRenderTime;
  105608. private _particlesRenderTime;
  105609. private _captureSpritesRenderTime;
  105610. private _spritesRenderTime;
  105611. private _capturePhysicsTime;
  105612. private _physicsTime;
  105613. private _captureAnimationsTime;
  105614. private _animationsTime;
  105615. private _captureCameraRenderTime;
  105616. private _cameraRenderTime;
  105617. private _onBeforeActiveMeshesEvaluationObserver;
  105618. private _onAfterActiveMeshesEvaluationObserver;
  105619. private _onBeforeRenderTargetsRenderObserver;
  105620. private _onAfterRenderTargetsRenderObserver;
  105621. private _onAfterRenderObserver;
  105622. private _onBeforeDrawPhaseObserver;
  105623. private _onAfterDrawPhaseObserver;
  105624. private _onBeforeAnimationsObserver;
  105625. private _onBeforeParticlesRenderingObserver;
  105626. private _onAfterParticlesRenderingObserver;
  105627. private _onBeforeSpritesRenderingObserver;
  105628. private _onAfterSpritesRenderingObserver;
  105629. private _onBeforePhysicsObserver;
  105630. private _onAfterPhysicsObserver;
  105631. private _onAfterAnimationsObserver;
  105632. private _onBeforeCameraRenderObserver;
  105633. private _onAfterCameraRenderObserver;
  105634. /**
  105635. * Gets the perf counter used for active meshes evaluation time
  105636. */
  105637. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  105638. /**
  105639. * Gets the active meshes evaluation time capture status
  105640. */
  105641. /**
  105642. * Enable or disable the active meshes evaluation time capture
  105643. */
  105644. captureActiveMeshesEvaluationTime: boolean;
  105645. /**
  105646. * Gets the perf counter used for render targets render time
  105647. */
  105648. readonly renderTargetsRenderTimeCounter: PerfCounter;
  105649. /**
  105650. * Gets the render targets render time capture status
  105651. */
  105652. /**
  105653. * Enable or disable the render targets render time capture
  105654. */
  105655. captureRenderTargetsRenderTime: boolean;
  105656. /**
  105657. * Gets the perf counter used for particles render time
  105658. */
  105659. readonly particlesRenderTimeCounter: PerfCounter;
  105660. /**
  105661. * Gets the particles render time capture status
  105662. */
  105663. /**
  105664. * Enable or disable the particles render time capture
  105665. */
  105666. captureParticlesRenderTime: boolean;
  105667. /**
  105668. * Gets the perf counter used for sprites render time
  105669. */
  105670. readonly spritesRenderTimeCounter: PerfCounter;
  105671. /**
  105672. * Gets the sprites render time capture status
  105673. */
  105674. /**
  105675. * Enable or disable the sprites render time capture
  105676. */
  105677. captureSpritesRenderTime: boolean;
  105678. /**
  105679. * Gets the perf counter used for physics time
  105680. */
  105681. readonly physicsTimeCounter: PerfCounter;
  105682. /**
  105683. * Gets the physics time capture status
  105684. */
  105685. /**
  105686. * Enable or disable the physics time capture
  105687. */
  105688. capturePhysicsTime: boolean;
  105689. /**
  105690. * Gets the perf counter used for animations time
  105691. */
  105692. readonly animationsTimeCounter: PerfCounter;
  105693. /**
  105694. * Gets the animations time capture status
  105695. */
  105696. /**
  105697. * Enable or disable the animations time capture
  105698. */
  105699. captureAnimationsTime: boolean;
  105700. /**
  105701. * Gets the perf counter used for frame time capture
  105702. */
  105703. readonly frameTimeCounter: PerfCounter;
  105704. /**
  105705. * Gets the frame time capture status
  105706. */
  105707. /**
  105708. * Enable or disable the frame time capture
  105709. */
  105710. captureFrameTime: boolean;
  105711. /**
  105712. * Gets the perf counter used for inter-frames time capture
  105713. */
  105714. readonly interFrameTimeCounter: PerfCounter;
  105715. /**
  105716. * Gets the inter-frames time capture status
  105717. */
  105718. /**
  105719. * Enable or disable the inter-frames time capture
  105720. */
  105721. captureInterFrameTime: boolean;
  105722. /**
  105723. * Gets the perf counter used for render time capture
  105724. */
  105725. readonly renderTimeCounter: PerfCounter;
  105726. /**
  105727. * Gets the render time capture status
  105728. */
  105729. /**
  105730. * Enable or disable the render time capture
  105731. */
  105732. captureRenderTime: boolean;
  105733. /**
  105734. * Gets the perf counter used for camera render time capture
  105735. */
  105736. readonly cameraRenderTimeCounter: PerfCounter;
  105737. /**
  105738. * Gets the camera render time capture status
  105739. */
  105740. /**
  105741. * Enable or disable the camera render time capture
  105742. */
  105743. captureCameraRenderTime: boolean;
  105744. /**
  105745. * Gets the perf counter used for draw calls
  105746. */
  105747. readonly drawCallsCounter: PerfCounter;
  105748. /**
  105749. * Instantiates a new scene instrumentation.
  105750. * This class can be used to get instrumentation data from a Babylon engine
  105751. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  105752. * @param scene Defines the scene to instrument
  105753. */
  105754. constructor(
  105755. /**
  105756. * Defines the scene to instrument
  105757. */
  105758. scene: Scene);
  105759. /**
  105760. * Dispose and release associated resources.
  105761. */
  105762. dispose(): void;
  105763. }
  105764. }
  105765. declare module BABYLON {
  105766. /** @hidden */
  105767. export var glowMapGenerationPixelShader: {
  105768. name: string;
  105769. shader: string;
  105770. };
  105771. }
  105772. declare module BABYLON {
  105773. /** @hidden */
  105774. export var glowMapGenerationVertexShader: {
  105775. name: string;
  105776. shader: string;
  105777. };
  105778. }
  105779. declare module BABYLON {
  105780. /**
  105781. * Effect layer options. This helps customizing the behaviour
  105782. * of the effect layer.
  105783. */
  105784. export interface IEffectLayerOptions {
  105785. /**
  105786. * Multiplication factor apply to the canvas size to compute the render target size
  105787. * used to generated the objects (the smaller the faster).
  105788. */
  105789. mainTextureRatio: number;
  105790. /**
  105791. * Enforces a fixed size texture to ensure effect stability across devices.
  105792. */
  105793. mainTextureFixedSize?: number;
  105794. /**
  105795. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  105796. */
  105797. alphaBlendingMode: number;
  105798. /**
  105799. * The camera attached to the layer.
  105800. */
  105801. camera: Nullable<Camera>;
  105802. /**
  105803. * The rendering group to draw the layer in.
  105804. */
  105805. renderingGroupId: number;
  105806. }
  105807. /**
  105808. * The effect layer Helps adding post process effect blended with the main pass.
  105809. *
  105810. * This can be for instance use to generate glow or higlight effects on the scene.
  105811. *
  105812. * The effect layer class can not be used directly and is intented to inherited from to be
  105813. * customized per effects.
  105814. */
  105815. export abstract class EffectLayer {
  105816. private _vertexBuffers;
  105817. private _indexBuffer;
  105818. private _cachedDefines;
  105819. private _effectLayerMapGenerationEffect;
  105820. private _effectLayerOptions;
  105821. private _mergeEffect;
  105822. protected _scene: Scene;
  105823. protected _engine: Engine;
  105824. protected _maxSize: number;
  105825. protected _mainTextureDesiredSize: ISize;
  105826. protected _mainTexture: RenderTargetTexture;
  105827. protected _shouldRender: boolean;
  105828. protected _postProcesses: PostProcess[];
  105829. protected _textures: BaseTexture[];
  105830. protected _emissiveTextureAndColor: {
  105831. texture: Nullable<BaseTexture>;
  105832. color: Color4;
  105833. };
  105834. /**
  105835. * The name of the layer
  105836. */
  105837. name: string;
  105838. /**
  105839. * The clear color of the texture used to generate the glow map.
  105840. */
  105841. neutralColor: Color4;
  105842. /**
  105843. * Specifies wether the highlight layer is enabled or not.
  105844. */
  105845. isEnabled: boolean;
  105846. /**
  105847. * Gets the camera attached to the layer.
  105848. */
  105849. readonly camera: Nullable<Camera>;
  105850. /**
  105851. * Gets the rendering group id the layer should render in.
  105852. */
  105853. readonly renderingGroupId: number;
  105854. /**
  105855. * An event triggered when the effect layer has been disposed.
  105856. */
  105857. onDisposeObservable: Observable<EffectLayer>;
  105858. /**
  105859. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  105860. */
  105861. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  105862. /**
  105863. * An event triggered when the generated texture is being merged in the scene.
  105864. */
  105865. onBeforeComposeObservable: Observable<EffectLayer>;
  105866. /**
  105867. * An event triggered when the generated texture has been merged in the scene.
  105868. */
  105869. onAfterComposeObservable: Observable<EffectLayer>;
  105870. /**
  105871. * An event triggered when the efffect layer changes its size.
  105872. */
  105873. onSizeChangedObservable: Observable<EffectLayer>;
  105874. /** @hidden */
  105875. static _SceneComponentInitialization: (scene: Scene) => void;
  105876. /**
  105877. * Instantiates a new effect Layer and references it in the scene.
  105878. * @param name The name of the layer
  105879. * @param scene The scene to use the layer in
  105880. */
  105881. constructor(
  105882. /** The Friendly of the effect in the scene */
  105883. name: string, scene: Scene);
  105884. /**
  105885. * Get the effect name of the layer.
  105886. * @return The effect name
  105887. */
  105888. abstract getEffectName(): string;
  105889. /**
  105890. * Checks for the readiness of the element composing the layer.
  105891. * @param subMesh the mesh to check for
  105892. * @param useInstances specify wether or not to use instances to render the mesh
  105893. * @return true if ready otherwise, false
  105894. */
  105895. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  105896. /**
  105897. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  105898. * @returns true if the effect requires stencil during the main canvas render pass.
  105899. */
  105900. abstract needStencil(): boolean;
  105901. /**
  105902. * Create the merge effect. This is the shader use to blit the information back
  105903. * to the main canvas at the end of the scene rendering.
  105904. * @returns The effect containing the shader used to merge the effect on the main canvas
  105905. */
  105906. protected abstract _createMergeEffect(): Effect;
  105907. /**
  105908. * Creates the render target textures and post processes used in the effect layer.
  105909. */
  105910. protected abstract _createTextureAndPostProcesses(): void;
  105911. /**
  105912. * Implementation specific of rendering the generating effect on the main canvas.
  105913. * @param effect The effect used to render through
  105914. */
  105915. protected abstract _internalRender(effect: Effect): void;
  105916. /**
  105917. * Sets the required values for both the emissive texture and and the main color.
  105918. */
  105919. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  105920. /**
  105921. * Free any resources and references associated to a mesh.
  105922. * Internal use
  105923. * @param mesh The mesh to free.
  105924. */
  105925. abstract _disposeMesh(mesh: Mesh): void;
  105926. /**
  105927. * Serializes this layer (Glow or Highlight for example)
  105928. * @returns a serialized layer object
  105929. */
  105930. abstract serialize?(): any;
  105931. /**
  105932. * Initializes the effect layer with the required options.
  105933. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  105934. */
  105935. protected _init(options: Partial<IEffectLayerOptions>): void;
  105936. /**
  105937. * Generates the index buffer of the full screen quad blending to the main canvas.
  105938. */
  105939. private _generateIndexBuffer;
  105940. /**
  105941. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  105942. */
  105943. private _genrateVertexBuffer;
  105944. /**
  105945. * Sets the main texture desired size which is the closest power of two
  105946. * of the engine canvas size.
  105947. */
  105948. private _setMainTextureSize;
  105949. /**
  105950. * Creates the main texture for the effect layer.
  105951. */
  105952. protected _createMainTexture(): void;
  105953. /**
  105954. * Adds specific effects defines.
  105955. * @param defines The defines to add specifics to.
  105956. */
  105957. protected _addCustomEffectDefines(defines: string[]): void;
  105958. /**
  105959. * Checks for the readiness of the element composing the layer.
  105960. * @param subMesh the mesh to check for
  105961. * @param useInstances specify wether or not to use instances to render the mesh
  105962. * @param emissiveTexture the associated emissive texture used to generate the glow
  105963. * @return true if ready otherwise, false
  105964. */
  105965. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  105966. /**
  105967. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  105968. */
  105969. render(): void;
  105970. /**
  105971. * Determine if a given mesh will be used in the current effect.
  105972. * @param mesh mesh to test
  105973. * @returns true if the mesh will be used
  105974. */
  105975. hasMesh(mesh: AbstractMesh): boolean;
  105976. /**
  105977. * Returns true if the layer contains information to display, otherwise false.
  105978. * @returns true if the glow layer should be rendered
  105979. */
  105980. shouldRender(): boolean;
  105981. /**
  105982. * Returns true if the mesh should render, otherwise false.
  105983. * @param mesh The mesh to render
  105984. * @returns true if it should render otherwise false
  105985. */
  105986. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  105987. /**
  105988. * Returns true if the mesh can be rendered, otherwise false.
  105989. * @param mesh The mesh to render
  105990. * @param material The material used on the mesh
  105991. * @returns true if it can be rendered otherwise false
  105992. */
  105993. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  105994. /**
  105995. * Returns true if the mesh should render, otherwise false.
  105996. * @param mesh The mesh to render
  105997. * @returns true if it should render otherwise false
  105998. */
  105999. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  106000. /**
  106001. * Renders the submesh passed in parameter to the generation map.
  106002. */
  106003. protected _renderSubMesh(subMesh: SubMesh): void;
  106004. /**
  106005. * Rebuild the required buffers.
  106006. * @hidden Internal use only.
  106007. */
  106008. _rebuild(): void;
  106009. /**
  106010. * Dispose only the render target textures and post process.
  106011. */
  106012. private _disposeTextureAndPostProcesses;
  106013. /**
  106014. * Dispose the highlight layer and free resources.
  106015. */
  106016. dispose(): void;
  106017. /**
  106018. * Gets the class name of the effect layer
  106019. * @returns the string with the class name of the effect layer
  106020. */
  106021. getClassName(): string;
  106022. /**
  106023. * Creates an effect layer from parsed effect layer data
  106024. * @param parsedEffectLayer defines effect layer data
  106025. * @param scene defines the current scene
  106026. * @param rootUrl defines the root URL containing the effect layer information
  106027. * @returns a parsed effect Layer
  106028. */
  106029. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  106030. }
  106031. }
  106032. declare module BABYLON {
  106033. interface AbstractScene {
  106034. /**
  106035. * The list of effect layers (highlights/glow) added to the scene
  106036. * @see http://doc.babylonjs.com/how_to/highlight_layer
  106037. * @see http://doc.babylonjs.com/how_to/glow_layer
  106038. */
  106039. effectLayers: Array<EffectLayer>;
  106040. /**
  106041. * Removes the given effect layer from this scene.
  106042. * @param toRemove defines the effect layer to remove
  106043. * @returns the index of the removed effect layer
  106044. */
  106045. removeEffectLayer(toRemove: EffectLayer): number;
  106046. /**
  106047. * Adds the given effect layer to this scene
  106048. * @param newEffectLayer defines the effect layer to add
  106049. */
  106050. addEffectLayer(newEffectLayer: EffectLayer): void;
  106051. }
  106052. /**
  106053. * Defines the layer scene component responsible to manage any effect layers
  106054. * in a given scene.
  106055. */
  106056. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  106057. /**
  106058. * The component name helpfull to identify the component in the list of scene components.
  106059. */
  106060. readonly name: string;
  106061. /**
  106062. * The scene the component belongs to.
  106063. */
  106064. scene: Scene;
  106065. private _engine;
  106066. private _renderEffects;
  106067. private _needStencil;
  106068. private _previousStencilState;
  106069. /**
  106070. * Creates a new instance of the component for the given scene
  106071. * @param scene Defines the scene to register the component in
  106072. */
  106073. constructor(scene: Scene);
  106074. /**
  106075. * Registers the component in a given scene
  106076. */
  106077. register(): void;
  106078. /**
  106079. * Rebuilds the elements related to this component in case of
  106080. * context lost for instance.
  106081. */
  106082. rebuild(): void;
  106083. /**
  106084. * Serializes the component data to the specified json object
  106085. * @param serializationObject The object to serialize to
  106086. */
  106087. serialize(serializationObject: any): void;
  106088. /**
  106089. * Adds all the element from the container to the scene
  106090. * @param container the container holding the elements
  106091. */
  106092. addFromContainer(container: AbstractScene): void;
  106093. /**
  106094. * Removes all the elements in the container from the scene
  106095. * @param container contains the elements to remove
  106096. * @param dispose if the removed element should be disposed (default: false)
  106097. */
  106098. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106099. /**
  106100. * Disposes the component and the associated ressources.
  106101. */
  106102. dispose(): void;
  106103. private _isReadyForMesh;
  106104. private _renderMainTexture;
  106105. private _setStencil;
  106106. private _setStencilBack;
  106107. private _draw;
  106108. private _drawCamera;
  106109. private _drawRenderingGroup;
  106110. }
  106111. }
  106112. declare module BABYLON {
  106113. /** @hidden */
  106114. export var glowMapMergePixelShader: {
  106115. name: string;
  106116. shader: string;
  106117. };
  106118. }
  106119. declare module BABYLON {
  106120. /** @hidden */
  106121. export var glowMapMergeVertexShader: {
  106122. name: string;
  106123. shader: string;
  106124. };
  106125. }
  106126. declare module BABYLON {
  106127. interface AbstractScene {
  106128. /**
  106129. * Return a the first highlight layer of the scene with a given name.
  106130. * @param name The name of the highlight layer to look for.
  106131. * @return The highlight layer if found otherwise null.
  106132. */
  106133. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  106134. }
  106135. /**
  106136. * Glow layer options. This helps customizing the behaviour
  106137. * of the glow layer.
  106138. */
  106139. export interface IGlowLayerOptions {
  106140. /**
  106141. * Multiplication factor apply to the canvas size to compute the render target size
  106142. * used to generated the glowing objects (the smaller the faster).
  106143. */
  106144. mainTextureRatio: number;
  106145. /**
  106146. * Enforces a fixed size texture to ensure resize independant blur.
  106147. */
  106148. mainTextureFixedSize?: number;
  106149. /**
  106150. * How big is the kernel of the blur texture.
  106151. */
  106152. blurKernelSize: number;
  106153. /**
  106154. * The camera attached to the layer.
  106155. */
  106156. camera: Nullable<Camera>;
  106157. /**
  106158. * Enable MSAA by chosing the number of samples.
  106159. */
  106160. mainTextureSamples?: number;
  106161. /**
  106162. * The rendering group to draw the layer in.
  106163. */
  106164. renderingGroupId: number;
  106165. }
  106166. /**
  106167. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  106168. *
  106169. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  106170. * glowy meshes to your scene.
  106171. *
  106172. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  106173. */
  106174. export class GlowLayer extends EffectLayer {
  106175. /**
  106176. * Effect Name of the layer.
  106177. */
  106178. static readonly EffectName: string;
  106179. /**
  106180. * The default blur kernel size used for the glow.
  106181. */
  106182. static DefaultBlurKernelSize: number;
  106183. /**
  106184. * The default texture size ratio used for the glow.
  106185. */
  106186. static DefaultTextureRatio: number;
  106187. /**
  106188. * Sets the kernel size of the blur.
  106189. */
  106190. /**
  106191. * Gets the kernel size of the blur.
  106192. */
  106193. blurKernelSize: number;
  106194. /**
  106195. * Sets the glow intensity.
  106196. */
  106197. /**
  106198. * Gets the glow intensity.
  106199. */
  106200. intensity: number;
  106201. private _options;
  106202. private _intensity;
  106203. private _horizontalBlurPostprocess1;
  106204. private _verticalBlurPostprocess1;
  106205. private _horizontalBlurPostprocess2;
  106206. private _verticalBlurPostprocess2;
  106207. private _blurTexture1;
  106208. private _blurTexture2;
  106209. private _postProcesses1;
  106210. private _postProcesses2;
  106211. private _includedOnlyMeshes;
  106212. private _excludedMeshes;
  106213. /**
  106214. * Callback used to let the user override the color selection on a per mesh basis
  106215. */
  106216. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  106217. /**
  106218. * Callback used to let the user override the texture selection on a per mesh basis
  106219. */
  106220. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  106221. /**
  106222. * Instantiates a new glow Layer and references it to the scene.
  106223. * @param name The name of the layer
  106224. * @param scene The scene to use the layer in
  106225. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  106226. */
  106227. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  106228. /**
  106229. * Get the effect name of the layer.
  106230. * @return The effect name
  106231. */
  106232. getEffectName(): string;
  106233. /**
  106234. * Create the merge effect. This is the shader use to blit the information back
  106235. * to the main canvas at the end of the scene rendering.
  106236. */
  106237. protected _createMergeEffect(): Effect;
  106238. /**
  106239. * Creates the render target textures and post processes used in the glow layer.
  106240. */
  106241. protected _createTextureAndPostProcesses(): void;
  106242. /**
  106243. * Checks for the readiness of the element composing the layer.
  106244. * @param subMesh the mesh to check for
  106245. * @param useInstances specify wether or not to use instances to render the mesh
  106246. * @param emissiveTexture the associated emissive texture used to generate the glow
  106247. * @return true if ready otherwise, false
  106248. */
  106249. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106250. /**
  106251. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106252. */
  106253. needStencil(): boolean;
  106254. /**
  106255. * Returns true if the mesh can be rendered, otherwise false.
  106256. * @param mesh The mesh to render
  106257. * @param material The material used on the mesh
  106258. * @returns true if it can be rendered otherwise false
  106259. */
  106260. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  106261. /**
  106262. * Implementation specific of rendering the generating effect on the main canvas.
  106263. * @param effect The effect used to render through
  106264. */
  106265. protected _internalRender(effect: Effect): void;
  106266. /**
  106267. * Sets the required values for both the emissive texture and and the main color.
  106268. */
  106269. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106270. /**
  106271. * Returns true if the mesh should render, otherwise false.
  106272. * @param mesh The mesh to render
  106273. * @returns true if it should render otherwise false
  106274. */
  106275. protected _shouldRenderMesh(mesh: Mesh): boolean;
  106276. /**
  106277. * Adds specific effects defines.
  106278. * @param defines The defines to add specifics to.
  106279. */
  106280. protected _addCustomEffectDefines(defines: string[]): void;
  106281. /**
  106282. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  106283. * @param mesh The mesh to exclude from the glow layer
  106284. */
  106285. addExcludedMesh(mesh: Mesh): void;
  106286. /**
  106287. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  106288. * @param mesh The mesh to remove
  106289. */
  106290. removeExcludedMesh(mesh: Mesh): void;
  106291. /**
  106292. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  106293. * @param mesh The mesh to include in the glow layer
  106294. */
  106295. addIncludedOnlyMesh(mesh: Mesh): void;
  106296. /**
  106297. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  106298. * @param mesh The mesh to remove
  106299. */
  106300. removeIncludedOnlyMesh(mesh: Mesh): void;
  106301. /**
  106302. * Determine if a given mesh will be used in the glow layer
  106303. * @param mesh The mesh to test
  106304. * @returns true if the mesh will be highlighted by the current glow layer
  106305. */
  106306. hasMesh(mesh: AbstractMesh): boolean;
  106307. /**
  106308. * Free any resources and references associated to a mesh.
  106309. * Internal use
  106310. * @param mesh The mesh to free.
  106311. * @hidden
  106312. */
  106313. _disposeMesh(mesh: Mesh): void;
  106314. /**
  106315. * Gets the class name of the effect layer
  106316. * @returns the string with the class name of the effect layer
  106317. */
  106318. getClassName(): string;
  106319. /**
  106320. * Serializes this glow layer
  106321. * @returns a serialized glow layer object
  106322. */
  106323. serialize(): any;
  106324. /**
  106325. * Creates a Glow Layer from parsed glow layer data
  106326. * @param parsedGlowLayer defines glow layer data
  106327. * @param scene defines the current scene
  106328. * @param rootUrl defines the root URL containing the glow layer information
  106329. * @returns a parsed Glow Layer
  106330. */
  106331. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  106332. }
  106333. }
  106334. declare module BABYLON {
  106335. /** @hidden */
  106336. export var glowBlurPostProcessPixelShader: {
  106337. name: string;
  106338. shader: string;
  106339. };
  106340. }
  106341. declare module BABYLON {
  106342. interface AbstractScene {
  106343. /**
  106344. * Return a the first highlight layer of the scene with a given name.
  106345. * @param name The name of the highlight layer to look for.
  106346. * @return The highlight layer if found otherwise null.
  106347. */
  106348. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  106349. }
  106350. /**
  106351. * Highlight layer options. This helps customizing the behaviour
  106352. * of the highlight layer.
  106353. */
  106354. export interface IHighlightLayerOptions {
  106355. /**
  106356. * Multiplication factor apply to the canvas size to compute the render target size
  106357. * used to generated the glowing objects (the smaller the faster).
  106358. */
  106359. mainTextureRatio: number;
  106360. /**
  106361. * Enforces a fixed size texture to ensure resize independant blur.
  106362. */
  106363. mainTextureFixedSize?: number;
  106364. /**
  106365. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  106366. * of the picture to blur (the smaller the faster).
  106367. */
  106368. blurTextureSizeRatio: number;
  106369. /**
  106370. * How big in texel of the blur texture is the vertical blur.
  106371. */
  106372. blurVerticalSize: number;
  106373. /**
  106374. * How big in texel of the blur texture is the horizontal blur.
  106375. */
  106376. blurHorizontalSize: number;
  106377. /**
  106378. * Alpha blending mode used to apply the blur. Default is combine.
  106379. */
  106380. alphaBlendingMode: number;
  106381. /**
  106382. * The camera attached to the layer.
  106383. */
  106384. camera: Nullable<Camera>;
  106385. /**
  106386. * Should we display highlight as a solid stroke?
  106387. */
  106388. isStroke?: boolean;
  106389. /**
  106390. * The rendering group to draw the layer in.
  106391. */
  106392. renderingGroupId: number;
  106393. }
  106394. /**
  106395. * The highlight layer Helps adding a glow effect around a mesh.
  106396. *
  106397. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  106398. * glowy meshes to your scene.
  106399. *
  106400. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  106401. */
  106402. export class HighlightLayer extends EffectLayer {
  106403. name: string;
  106404. /**
  106405. * Effect Name of the highlight layer.
  106406. */
  106407. static readonly EffectName: string;
  106408. /**
  106409. * The neutral color used during the preparation of the glow effect.
  106410. * This is black by default as the blend operation is a blend operation.
  106411. */
  106412. static NeutralColor: Color4;
  106413. /**
  106414. * Stencil value used for glowing meshes.
  106415. */
  106416. static GlowingMeshStencilReference: number;
  106417. /**
  106418. * Stencil value used for the other meshes in the scene.
  106419. */
  106420. static NormalMeshStencilReference: number;
  106421. /**
  106422. * Specifies whether or not the inner glow is ACTIVE in the layer.
  106423. */
  106424. innerGlow: boolean;
  106425. /**
  106426. * Specifies whether or not the outer glow is ACTIVE in the layer.
  106427. */
  106428. outerGlow: boolean;
  106429. /**
  106430. * Specifies the horizontal size of the blur.
  106431. */
  106432. /**
  106433. * Gets the horizontal size of the blur.
  106434. */
  106435. blurHorizontalSize: number;
  106436. /**
  106437. * Specifies the vertical size of the blur.
  106438. */
  106439. /**
  106440. * Gets the vertical size of the blur.
  106441. */
  106442. blurVerticalSize: number;
  106443. /**
  106444. * An event triggered when the highlight layer is being blurred.
  106445. */
  106446. onBeforeBlurObservable: Observable<HighlightLayer>;
  106447. /**
  106448. * An event triggered when the highlight layer has been blurred.
  106449. */
  106450. onAfterBlurObservable: Observable<HighlightLayer>;
  106451. private _instanceGlowingMeshStencilReference;
  106452. private _options;
  106453. private _downSamplePostprocess;
  106454. private _horizontalBlurPostprocess;
  106455. private _verticalBlurPostprocess;
  106456. private _blurTexture;
  106457. private _meshes;
  106458. private _excludedMeshes;
  106459. /**
  106460. * Instantiates a new highlight Layer and references it to the scene..
  106461. * @param name The name of the layer
  106462. * @param scene The scene to use the layer in
  106463. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  106464. */
  106465. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  106466. /**
  106467. * Get the effect name of the layer.
  106468. * @return The effect name
  106469. */
  106470. getEffectName(): string;
  106471. /**
  106472. * Create the merge effect. This is the shader use to blit the information back
  106473. * to the main canvas at the end of the scene rendering.
  106474. */
  106475. protected _createMergeEffect(): Effect;
  106476. /**
  106477. * Creates the render target textures and post processes used in the highlight layer.
  106478. */
  106479. protected _createTextureAndPostProcesses(): void;
  106480. /**
  106481. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106482. */
  106483. needStencil(): boolean;
  106484. /**
  106485. * Checks for the readiness of the element composing the layer.
  106486. * @param subMesh the mesh to check for
  106487. * @param useInstances specify wether or not to use instances to render the mesh
  106488. * @param emissiveTexture the associated emissive texture used to generate the glow
  106489. * @return true if ready otherwise, false
  106490. */
  106491. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106492. /**
  106493. * Implementation specific of rendering the generating effect on the main canvas.
  106494. * @param effect The effect used to render through
  106495. */
  106496. protected _internalRender(effect: Effect): void;
  106497. /**
  106498. * Returns true if the layer contains information to display, otherwise false.
  106499. */
  106500. shouldRender(): boolean;
  106501. /**
  106502. * Returns true if the mesh should render, otherwise false.
  106503. * @param mesh The mesh to render
  106504. * @returns true if it should render otherwise false
  106505. */
  106506. protected _shouldRenderMesh(mesh: Mesh): boolean;
  106507. /**
  106508. * Sets the required values for both the emissive texture and and the main color.
  106509. */
  106510. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106511. /**
  106512. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  106513. * @param mesh The mesh to exclude from the highlight layer
  106514. */
  106515. addExcludedMesh(mesh: Mesh): void;
  106516. /**
  106517. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  106518. * @param mesh The mesh to highlight
  106519. */
  106520. removeExcludedMesh(mesh: Mesh): void;
  106521. /**
  106522. * Determine if a given mesh will be highlighted by the current HighlightLayer
  106523. * @param mesh mesh to test
  106524. * @returns true if the mesh will be highlighted by the current HighlightLayer
  106525. */
  106526. hasMesh(mesh: AbstractMesh): boolean;
  106527. /**
  106528. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  106529. * @param mesh The mesh to highlight
  106530. * @param color The color of the highlight
  106531. * @param glowEmissiveOnly Extract the glow from the emissive texture
  106532. */
  106533. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  106534. /**
  106535. * Remove a mesh from the highlight layer in order to make it stop glowing.
  106536. * @param mesh The mesh to highlight
  106537. */
  106538. removeMesh(mesh: Mesh): void;
  106539. /**
  106540. * Force the stencil to the normal expected value for none glowing parts
  106541. */
  106542. private _defaultStencilReference;
  106543. /**
  106544. * Free any resources and references associated to a mesh.
  106545. * Internal use
  106546. * @param mesh The mesh to free.
  106547. * @hidden
  106548. */
  106549. _disposeMesh(mesh: Mesh): void;
  106550. /**
  106551. * Dispose the highlight layer and free resources.
  106552. */
  106553. dispose(): void;
  106554. /**
  106555. * Gets the class name of the effect layer
  106556. * @returns the string with the class name of the effect layer
  106557. */
  106558. getClassName(): string;
  106559. /**
  106560. * Serializes this Highlight layer
  106561. * @returns a serialized Highlight layer object
  106562. */
  106563. serialize(): any;
  106564. /**
  106565. * Creates a Highlight layer from parsed Highlight layer data
  106566. * @param parsedHightlightLayer defines the Highlight layer data
  106567. * @param scene defines the current scene
  106568. * @param rootUrl defines the root URL containing the Highlight layer information
  106569. * @returns a parsed Highlight layer
  106570. */
  106571. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  106572. }
  106573. }
  106574. declare module BABYLON {
  106575. /** @hidden */
  106576. export var lensFlarePixelShader: {
  106577. name: string;
  106578. shader: string;
  106579. };
  106580. }
  106581. declare module BABYLON {
  106582. /** @hidden */
  106583. export var lensFlareVertexShader: {
  106584. name: string;
  106585. shader: string;
  106586. };
  106587. }
  106588. declare module BABYLON {
  106589. /**
  106590. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  106591. * It is usually composed of several `lensFlare`.
  106592. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106593. */
  106594. export class LensFlareSystem {
  106595. /**
  106596. * Define the name of the lens flare system
  106597. */
  106598. name: string;
  106599. /**
  106600. * List of lens flares used in this system.
  106601. */
  106602. lensFlares: LensFlare[];
  106603. /**
  106604. * Define a limit from the border the lens flare can be visible.
  106605. */
  106606. borderLimit: number;
  106607. /**
  106608. * Define a viewport border we do not want to see the lens flare in.
  106609. */
  106610. viewportBorder: number;
  106611. /**
  106612. * Define a predicate which could limit the list of meshes able to occlude the effect.
  106613. */
  106614. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  106615. /**
  106616. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  106617. */
  106618. layerMask: number;
  106619. /**
  106620. * Define the id of the lens flare system in the scene.
  106621. * (equal to name by default)
  106622. */
  106623. id: string;
  106624. private _scene;
  106625. private _emitter;
  106626. private _vertexBuffers;
  106627. private _indexBuffer;
  106628. private _effect;
  106629. private _positionX;
  106630. private _positionY;
  106631. private _isEnabled;
  106632. /** @hidden */
  106633. static _SceneComponentInitialization: (scene: Scene) => void;
  106634. /**
  106635. * Instantiates a lens flare system.
  106636. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  106637. * It is usually composed of several `lensFlare`.
  106638. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106639. * @param name Define the name of the lens flare system in the scene
  106640. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  106641. * @param scene Define the scene the lens flare system belongs to
  106642. */
  106643. constructor(
  106644. /**
  106645. * Define the name of the lens flare system
  106646. */
  106647. name: string, emitter: any, scene: Scene);
  106648. /**
  106649. * Define if the lens flare system is enabled.
  106650. */
  106651. isEnabled: boolean;
  106652. /**
  106653. * Get the scene the effects belongs to.
  106654. * @returns the scene holding the lens flare system
  106655. */
  106656. getScene(): Scene;
  106657. /**
  106658. * Get the emitter of the lens flare system.
  106659. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  106660. * @returns the emitter of the lens flare system
  106661. */
  106662. getEmitter(): any;
  106663. /**
  106664. * Set the emitter of the lens flare system.
  106665. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  106666. * @param newEmitter Define the new emitter of the system
  106667. */
  106668. setEmitter(newEmitter: any): void;
  106669. /**
  106670. * Get the lens flare system emitter position.
  106671. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  106672. * @returns the position
  106673. */
  106674. getEmitterPosition(): Vector3;
  106675. /**
  106676. * @hidden
  106677. */
  106678. computeEffectivePosition(globalViewport: Viewport): boolean;
  106679. /** @hidden */
  106680. _isVisible(): boolean;
  106681. /**
  106682. * @hidden
  106683. */
  106684. render(): boolean;
  106685. /**
  106686. * Dispose and release the lens flare with its associated resources.
  106687. */
  106688. dispose(): void;
  106689. /**
  106690. * Parse a lens flare system from a JSON repressentation
  106691. * @param parsedLensFlareSystem Define the JSON to parse
  106692. * @param scene Define the scene the parsed system should be instantiated in
  106693. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  106694. * @returns the parsed system
  106695. */
  106696. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  106697. /**
  106698. * Serialize the current Lens Flare System into a JSON representation.
  106699. * @returns the serialized JSON
  106700. */
  106701. serialize(): any;
  106702. }
  106703. }
  106704. declare module BABYLON {
  106705. /**
  106706. * This represents one of the lens effect in a `lensFlareSystem`.
  106707. * It controls one of the indiviual texture used in the effect.
  106708. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106709. */
  106710. export class LensFlare {
  106711. /**
  106712. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  106713. */
  106714. size: number;
  106715. /**
  106716. * 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.
  106717. */
  106718. position: number;
  106719. /**
  106720. * Define the lens color.
  106721. */
  106722. color: Color3;
  106723. /**
  106724. * Define the lens texture.
  106725. */
  106726. texture: Nullable<Texture>;
  106727. /**
  106728. * Define the alpha mode to render this particular lens.
  106729. */
  106730. alphaMode: number;
  106731. private _system;
  106732. /**
  106733. * Creates a new Lens Flare.
  106734. * This represents one of the lens effect in a `lensFlareSystem`.
  106735. * It controls one of the indiviual texture used in the effect.
  106736. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106737. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  106738. * @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.
  106739. * @param color Define the lens color
  106740. * @param imgUrl Define the lens texture url
  106741. * @param system Define the `lensFlareSystem` this flare is part of
  106742. * @returns The newly created Lens Flare
  106743. */
  106744. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  106745. /**
  106746. * Instantiates a new Lens Flare.
  106747. * This represents one of the lens effect in a `lensFlareSystem`.
  106748. * It controls one of the indiviual texture used in the effect.
  106749. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106750. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  106751. * @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.
  106752. * @param color Define the lens color
  106753. * @param imgUrl Define the lens texture url
  106754. * @param system Define the `lensFlareSystem` this flare is part of
  106755. */
  106756. constructor(
  106757. /**
  106758. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  106759. */
  106760. size: number,
  106761. /**
  106762. * 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.
  106763. */
  106764. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  106765. /**
  106766. * Dispose and release the lens flare with its associated resources.
  106767. */
  106768. dispose(): void;
  106769. }
  106770. }
  106771. declare module BABYLON {
  106772. interface AbstractScene {
  106773. /**
  106774. * The list of lens flare system added to the scene
  106775. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106776. */
  106777. lensFlareSystems: Array<LensFlareSystem>;
  106778. /**
  106779. * Removes the given lens flare system from this scene.
  106780. * @param toRemove The lens flare system to remove
  106781. * @returns The index of the removed lens flare system
  106782. */
  106783. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  106784. /**
  106785. * Adds the given lens flare system to this scene
  106786. * @param newLensFlareSystem The lens flare system to add
  106787. */
  106788. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  106789. /**
  106790. * Gets a lens flare system using its name
  106791. * @param name defines the name to look for
  106792. * @returns the lens flare system or null if not found
  106793. */
  106794. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  106795. /**
  106796. * Gets a lens flare system using its id
  106797. * @param id defines the id to look for
  106798. * @returns the lens flare system or null if not found
  106799. */
  106800. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  106801. }
  106802. /**
  106803. * Defines the lens flare scene component responsible to manage any lens flares
  106804. * in a given scene.
  106805. */
  106806. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  106807. /**
  106808. * The component name helpfull to identify the component in the list of scene components.
  106809. */
  106810. readonly name: string;
  106811. /**
  106812. * The scene the component belongs to.
  106813. */
  106814. scene: Scene;
  106815. /**
  106816. * Creates a new instance of the component for the given scene
  106817. * @param scene Defines the scene to register the component in
  106818. */
  106819. constructor(scene: Scene);
  106820. /**
  106821. * Registers the component in a given scene
  106822. */
  106823. register(): void;
  106824. /**
  106825. * Rebuilds the elements related to this component in case of
  106826. * context lost for instance.
  106827. */
  106828. rebuild(): void;
  106829. /**
  106830. * Adds all the element from the container to the scene
  106831. * @param container the container holding the elements
  106832. */
  106833. addFromContainer(container: AbstractScene): void;
  106834. /**
  106835. * Removes all the elements in the container from the scene
  106836. * @param container contains the elements to remove
  106837. * @param dispose if the removed element should be disposed (default: false)
  106838. */
  106839. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106840. /**
  106841. * Serializes the component data to the specified json object
  106842. * @param serializationObject The object to serialize to
  106843. */
  106844. serialize(serializationObject: any): void;
  106845. /**
  106846. * Disposes the component and the associated ressources.
  106847. */
  106848. dispose(): void;
  106849. private _draw;
  106850. }
  106851. }
  106852. declare module BABYLON {
  106853. /**
  106854. * Defines the shadow generator component responsible to manage any shadow generators
  106855. * in a given scene.
  106856. */
  106857. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  106858. /**
  106859. * The component name helpfull to identify the component in the list of scene components.
  106860. */
  106861. readonly name: string;
  106862. /**
  106863. * The scene the component belongs to.
  106864. */
  106865. scene: Scene;
  106866. /**
  106867. * Creates a new instance of the component for the given scene
  106868. * @param scene Defines the scene to register the component in
  106869. */
  106870. constructor(scene: Scene);
  106871. /**
  106872. * Registers the component in a given scene
  106873. */
  106874. register(): void;
  106875. /**
  106876. * Rebuilds the elements related to this component in case of
  106877. * context lost for instance.
  106878. */
  106879. rebuild(): void;
  106880. /**
  106881. * Serializes the component data to the specified json object
  106882. * @param serializationObject The object to serialize to
  106883. */
  106884. serialize(serializationObject: any): void;
  106885. /**
  106886. * Adds all the element from the container to the scene
  106887. * @param container the container holding the elements
  106888. */
  106889. addFromContainer(container: AbstractScene): void;
  106890. /**
  106891. * Removes all the elements in the container from the scene
  106892. * @param container contains the elements to remove
  106893. * @param dispose if the removed element should be disposed (default: false)
  106894. */
  106895. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106896. /**
  106897. * Rebuilds the elements related to this component in case of
  106898. * context lost for instance.
  106899. */
  106900. dispose(): void;
  106901. private _gatherRenderTargets;
  106902. }
  106903. }
  106904. declare module BABYLON {
  106905. /**
  106906. * A point light is a light defined by an unique point in world space.
  106907. * The light is emitted in every direction from this point.
  106908. * A good example of a point light is a standard light bulb.
  106909. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106910. */
  106911. export class PointLight extends ShadowLight {
  106912. private _shadowAngle;
  106913. /**
  106914. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106915. * This specifies what angle the shadow will use to be created.
  106916. *
  106917. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  106918. */
  106919. /**
  106920. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106921. * This specifies what angle the shadow will use to be created.
  106922. *
  106923. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  106924. */
  106925. shadowAngle: number;
  106926. /**
  106927. * Gets the direction if it has been set.
  106928. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106929. */
  106930. /**
  106931. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106932. */
  106933. direction: Vector3;
  106934. /**
  106935. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  106936. * A PointLight emits the light in every direction.
  106937. * It can cast shadows.
  106938. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  106939. * ```javascript
  106940. * var pointLight = new PointLight("pl", camera.position, scene);
  106941. * ```
  106942. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106943. * @param name The light friendly name
  106944. * @param position The position of the point light in the scene
  106945. * @param scene The scene the lights belongs to
  106946. */
  106947. constructor(name: string, position: Vector3, scene: Scene);
  106948. /**
  106949. * Returns the string "PointLight"
  106950. * @returns the class name
  106951. */
  106952. getClassName(): string;
  106953. /**
  106954. * Returns the integer 0.
  106955. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106956. */
  106957. getTypeID(): number;
  106958. /**
  106959. * Specifies wether or not the shadowmap should be a cube texture.
  106960. * @returns true if the shadowmap needs to be a cube texture.
  106961. */
  106962. needCube(): boolean;
  106963. /**
  106964. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  106965. * @param faceIndex The index of the face we are computed the direction to generate shadow
  106966. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  106967. */
  106968. getShadowDirection(faceIndex?: number): Vector3;
  106969. /**
  106970. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  106971. * - fov = PI / 2
  106972. * - aspect ratio : 1.0
  106973. * - z-near and far equal to the active camera minZ and maxZ.
  106974. * Returns the PointLight.
  106975. */
  106976. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106977. protected _buildUniformLayout(): void;
  106978. /**
  106979. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  106980. * @param effect The effect to update
  106981. * @param lightIndex The index of the light in the effect to update
  106982. * @returns The point light
  106983. */
  106984. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  106985. /**
  106986. * Prepares the list of defines specific to the light type.
  106987. * @param defines the list of defines
  106988. * @param lightIndex defines the index of the light for the effect
  106989. */
  106990. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106991. }
  106992. }
  106993. declare module BABYLON {
  106994. /**
  106995. * Header information of HDR texture files.
  106996. */
  106997. export interface HDRInfo {
  106998. /**
  106999. * The height of the texture in pixels.
  107000. */
  107001. height: number;
  107002. /**
  107003. * The width of the texture in pixels.
  107004. */
  107005. width: number;
  107006. /**
  107007. * The index of the beginning of the data in the binary file.
  107008. */
  107009. dataPosition: number;
  107010. }
  107011. /**
  107012. * This groups tools to convert HDR texture to native colors array.
  107013. */
  107014. export class HDRTools {
  107015. private static Ldexp;
  107016. private static Rgbe2float;
  107017. private static readStringLine;
  107018. /**
  107019. * Reads header information from an RGBE texture stored in a native array.
  107020. * More information on this format are available here:
  107021. * https://en.wikipedia.org/wiki/RGBE_image_format
  107022. *
  107023. * @param uint8array The binary file stored in native array.
  107024. * @return The header information.
  107025. */
  107026. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  107027. /**
  107028. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  107029. * This RGBE texture needs to store the information as a panorama.
  107030. *
  107031. * More information on this format are available here:
  107032. * https://en.wikipedia.org/wiki/RGBE_image_format
  107033. *
  107034. * @param buffer The binary file stored in an array buffer.
  107035. * @param size The expected size of the extracted cubemap.
  107036. * @return The Cube Map information.
  107037. */
  107038. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  107039. /**
  107040. * Returns the pixels data extracted from an RGBE texture.
  107041. * This pixels will be stored left to right up to down in the R G B order in one array.
  107042. *
  107043. * More information on this format are available here:
  107044. * https://en.wikipedia.org/wiki/RGBE_image_format
  107045. *
  107046. * @param uint8array The binary file stored in an array buffer.
  107047. * @param hdrInfo The header information of the file.
  107048. * @return The pixels data in RGB right to left up to down order.
  107049. */
  107050. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  107051. private static RGBE_ReadPixels_RLE;
  107052. }
  107053. }
  107054. declare module BABYLON {
  107055. /**
  107056. * This represents a texture coming from an HDR input.
  107057. *
  107058. * The only supported format is currently panorama picture stored in RGBE format.
  107059. * Example of such files can be found on HDRLib: http://hdrlib.com/
  107060. */
  107061. export class HDRCubeTexture extends BaseTexture {
  107062. private static _facesMapping;
  107063. private _generateHarmonics;
  107064. private _noMipmap;
  107065. private _textureMatrix;
  107066. private _size;
  107067. private _onLoad;
  107068. private _onError;
  107069. /**
  107070. * The texture URL.
  107071. */
  107072. url: string;
  107073. /**
  107074. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  107075. */
  107076. coordinatesMode: number;
  107077. protected _isBlocking: boolean;
  107078. /**
  107079. * Sets wether or not the texture is blocking during loading.
  107080. */
  107081. /**
  107082. * Gets wether or not the texture is blocking during loading.
  107083. */
  107084. isBlocking: boolean;
  107085. protected _rotationY: number;
  107086. /**
  107087. * Sets texture matrix rotation angle around Y axis in radians.
  107088. */
  107089. /**
  107090. * Gets texture matrix rotation angle around Y axis radians.
  107091. */
  107092. rotationY: number;
  107093. /**
  107094. * Gets or sets the center of the bounding box associated with the cube texture
  107095. * It must define where the camera used to render the texture was set
  107096. */
  107097. boundingBoxPosition: Vector3;
  107098. private _boundingBoxSize;
  107099. /**
  107100. * Gets or sets the size of the bounding box associated with the cube texture
  107101. * When defined, the cubemap will switch to local mode
  107102. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  107103. * @example https://www.babylonjs-playground.com/#RNASML
  107104. */
  107105. boundingBoxSize: Vector3;
  107106. /**
  107107. * Instantiates an HDRTexture from the following parameters.
  107108. *
  107109. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  107110. * @param scene The scene the texture will be used in
  107111. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  107112. * @param noMipmap Forces to not generate the mipmap if true
  107113. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  107114. * @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)
  107115. * @param reserved Reserved flag for internal use.
  107116. */
  107117. 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>);
  107118. /**
  107119. * Get the current class name of the texture useful for serialization or dynamic coding.
  107120. * @returns "HDRCubeTexture"
  107121. */
  107122. getClassName(): string;
  107123. /**
  107124. * Occurs when the file is raw .hdr file.
  107125. */
  107126. private loadTexture;
  107127. clone(): HDRCubeTexture;
  107128. delayLoad(): void;
  107129. /**
  107130. * Get the texture reflection matrix used to rotate/transform the reflection.
  107131. * @returns the reflection matrix
  107132. */
  107133. getReflectionTextureMatrix(): Matrix;
  107134. /**
  107135. * Set the texture reflection matrix used to rotate/transform the reflection.
  107136. * @param value Define the reflection matrix to set
  107137. */
  107138. setReflectionTextureMatrix(value: Matrix): void;
  107139. /**
  107140. * Parses a JSON representation of an HDR Texture in order to create the texture
  107141. * @param parsedTexture Define the JSON representation
  107142. * @param scene Define the scene the texture should be created in
  107143. * @param rootUrl Define the root url in case we need to load relative dependencies
  107144. * @returns the newly created texture after parsing
  107145. */
  107146. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  107147. serialize(): any;
  107148. }
  107149. }
  107150. declare module BABYLON {
  107151. /**
  107152. * Class used to control physics engine
  107153. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  107154. */
  107155. export class PhysicsEngine implements IPhysicsEngine {
  107156. private _physicsPlugin;
  107157. /**
  107158. * Global value used to control the smallest number supported by the simulation
  107159. */
  107160. static Epsilon: number;
  107161. private _impostors;
  107162. private _joints;
  107163. /**
  107164. * Gets the gravity vector used by the simulation
  107165. */
  107166. gravity: Vector3;
  107167. /**
  107168. * Factory used to create the default physics plugin.
  107169. * @returns The default physics plugin
  107170. */
  107171. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  107172. /**
  107173. * Creates a new Physics Engine
  107174. * @param gravity defines the gravity vector used by the simulation
  107175. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  107176. */
  107177. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  107178. /**
  107179. * Sets the gravity vector used by the simulation
  107180. * @param gravity defines the gravity vector to use
  107181. */
  107182. setGravity(gravity: Vector3): void;
  107183. /**
  107184. * Set the time step of the physics engine.
  107185. * Default is 1/60.
  107186. * To slow it down, enter 1/600 for example.
  107187. * To speed it up, 1/30
  107188. * @param newTimeStep defines the new timestep to apply to this world.
  107189. */
  107190. setTimeStep(newTimeStep?: number): void;
  107191. /**
  107192. * Get the time step of the physics engine.
  107193. * @returns the current time step
  107194. */
  107195. getTimeStep(): number;
  107196. /**
  107197. * Release all resources
  107198. */
  107199. dispose(): void;
  107200. /**
  107201. * Gets the name of the current physics plugin
  107202. * @returns the name of the plugin
  107203. */
  107204. getPhysicsPluginName(): string;
  107205. /**
  107206. * Adding a new impostor for the impostor tracking.
  107207. * This will be done by the impostor itself.
  107208. * @param impostor the impostor to add
  107209. */
  107210. addImpostor(impostor: PhysicsImpostor): void;
  107211. /**
  107212. * Remove an impostor from the engine.
  107213. * This impostor and its mesh will not longer be updated by the physics engine.
  107214. * @param impostor the impostor to remove
  107215. */
  107216. removeImpostor(impostor: PhysicsImpostor): void;
  107217. /**
  107218. * Add a joint to the physics engine
  107219. * @param mainImpostor defines the main impostor to which the joint is added.
  107220. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  107221. * @param joint defines the joint that will connect both impostors.
  107222. */
  107223. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107224. /**
  107225. * Removes a joint from the simulation
  107226. * @param mainImpostor defines the impostor used with the joint
  107227. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  107228. * @param joint defines the joint to remove
  107229. */
  107230. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107231. /**
  107232. * Called by the scene. No need to call it.
  107233. * @param delta defines the timespam between frames
  107234. */
  107235. _step(delta: number): void;
  107236. /**
  107237. * Gets the current plugin used to run the simulation
  107238. * @returns current plugin
  107239. */
  107240. getPhysicsPlugin(): IPhysicsEnginePlugin;
  107241. /**
  107242. * Gets the list of physic impostors
  107243. * @returns an array of PhysicsImpostor
  107244. */
  107245. getImpostors(): Array<PhysicsImpostor>;
  107246. /**
  107247. * Gets the impostor for a physics enabled object
  107248. * @param object defines the object impersonated by the impostor
  107249. * @returns the PhysicsImpostor or null if not found
  107250. */
  107251. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107252. /**
  107253. * Gets the impostor for a physics body object
  107254. * @param body defines physics body used by the impostor
  107255. * @returns the PhysicsImpostor or null if not found
  107256. */
  107257. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  107258. /**
  107259. * Does a raycast in the physics world
  107260. * @param from when should the ray start?
  107261. * @param to when should the ray end?
  107262. * @returns PhysicsRaycastResult
  107263. */
  107264. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107265. }
  107266. }
  107267. declare module BABYLON {
  107268. /** @hidden */
  107269. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  107270. private _useDeltaForWorldStep;
  107271. world: any;
  107272. name: string;
  107273. private _physicsMaterials;
  107274. private _fixedTimeStep;
  107275. private _cannonRaycastResult;
  107276. private _raycastResult;
  107277. private _removeAfterStep;
  107278. BJSCANNON: any;
  107279. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  107280. setGravity(gravity: Vector3): void;
  107281. setTimeStep(timeStep: number): void;
  107282. getTimeStep(): number;
  107283. executeStep(delta: number): void;
  107284. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107285. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107286. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107287. private _processChildMeshes;
  107288. removePhysicsBody(impostor: PhysicsImpostor): void;
  107289. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107290. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107291. private _addMaterial;
  107292. private _checkWithEpsilon;
  107293. private _createShape;
  107294. private _createHeightmap;
  107295. private _minus90X;
  107296. private _plus90X;
  107297. private _tmpPosition;
  107298. private _tmpDeltaPosition;
  107299. private _tmpUnityRotation;
  107300. private _updatePhysicsBodyTransformation;
  107301. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107302. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107303. isSupported(): boolean;
  107304. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107305. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107306. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107307. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107308. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107309. getBodyMass(impostor: PhysicsImpostor): number;
  107310. getBodyFriction(impostor: PhysicsImpostor): number;
  107311. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107312. getBodyRestitution(impostor: PhysicsImpostor): number;
  107313. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107314. sleepBody(impostor: PhysicsImpostor): void;
  107315. wakeUpBody(impostor: PhysicsImpostor): void;
  107316. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  107317. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107318. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107319. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107320. getRadius(impostor: PhysicsImpostor): number;
  107321. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107322. dispose(): void;
  107323. private _extendNamespace;
  107324. /**
  107325. * Does a raycast in the physics world
  107326. * @param from when should the ray start?
  107327. * @param to when should the ray end?
  107328. * @returns PhysicsRaycastResult
  107329. */
  107330. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107331. }
  107332. }
  107333. declare module BABYLON {
  107334. /** @hidden */
  107335. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  107336. world: any;
  107337. name: string;
  107338. BJSOIMO: any;
  107339. private _raycastResult;
  107340. constructor(iterations?: number, oimoInjection?: any);
  107341. setGravity(gravity: Vector3): void;
  107342. setTimeStep(timeStep: number): void;
  107343. getTimeStep(): number;
  107344. private _tmpImpostorsArray;
  107345. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107346. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107347. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107348. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107349. private _tmpPositionVector;
  107350. removePhysicsBody(impostor: PhysicsImpostor): void;
  107351. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107352. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107353. isSupported(): boolean;
  107354. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107355. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107356. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107357. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107358. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107359. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107360. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107361. getBodyMass(impostor: PhysicsImpostor): number;
  107362. getBodyFriction(impostor: PhysicsImpostor): number;
  107363. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107364. getBodyRestitution(impostor: PhysicsImpostor): number;
  107365. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107366. sleepBody(impostor: PhysicsImpostor): void;
  107367. wakeUpBody(impostor: PhysicsImpostor): void;
  107368. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107369. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  107370. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107371. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107372. getRadius(impostor: PhysicsImpostor): number;
  107373. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107374. dispose(): void;
  107375. /**
  107376. * Does a raycast in the physics world
  107377. * @param from when should the ray start?
  107378. * @param to when should the ray end?
  107379. * @returns PhysicsRaycastResult
  107380. */
  107381. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107382. }
  107383. }
  107384. declare module BABYLON {
  107385. /**
  107386. * Class containing static functions to help procedurally build meshes
  107387. */
  107388. export class RibbonBuilder {
  107389. /**
  107390. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107391. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  107392. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  107393. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  107394. * * 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
  107395. * * 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
  107396. * * 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
  107397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107398. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107399. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107400. * * 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
  107401. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  107402. * * 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
  107403. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  107404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107405. * @param name defines the name of the mesh
  107406. * @param options defines the options used to create the mesh
  107407. * @param scene defines the hosting scene
  107408. * @returns the ribbon mesh
  107409. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  107410. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107411. */
  107412. static CreateRibbon(name: string, options: {
  107413. pathArray: Vector3[][];
  107414. closeArray?: boolean;
  107415. closePath?: boolean;
  107416. offset?: number;
  107417. updatable?: boolean;
  107418. sideOrientation?: number;
  107419. frontUVs?: Vector4;
  107420. backUVs?: Vector4;
  107421. instance?: Mesh;
  107422. invertUV?: boolean;
  107423. uvs?: Vector2[];
  107424. colors?: Color4[];
  107425. }, scene?: Nullable<Scene>): Mesh;
  107426. }
  107427. }
  107428. declare module BABYLON {
  107429. /**
  107430. * Class containing static functions to help procedurally build meshes
  107431. */
  107432. export class ShapeBuilder {
  107433. /**
  107434. * 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.
  107435. * * 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.
  107436. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107437. * * 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.
  107438. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  107439. * * 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
  107440. * * 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
  107441. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  107442. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107443. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107444. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  107445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107446. * @param name defines the name of the mesh
  107447. * @param options defines the options used to create the mesh
  107448. * @param scene defines the hosting scene
  107449. * @returns the extruded shape mesh
  107450. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107451. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107452. */
  107453. static ExtrudeShape(name: string, options: {
  107454. shape: Vector3[];
  107455. path: Vector3[];
  107456. scale?: number;
  107457. rotation?: number;
  107458. cap?: number;
  107459. updatable?: boolean;
  107460. sideOrientation?: number;
  107461. frontUVs?: Vector4;
  107462. backUVs?: Vector4;
  107463. instance?: Mesh;
  107464. invertUV?: boolean;
  107465. }, scene?: Nullable<Scene>): Mesh;
  107466. /**
  107467. * Creates an custom extruded shape mesh.
  107468. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  107469. * * 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.
  107470. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107471. * * 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
  107472. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  107473. * * 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
  107474. * * It must returns a float value that will be the scale value applied to the shape on each path point
  107475. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107476. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  107477. * * 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
  107478. * * 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
  107479. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  107480. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107481. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107482. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107484. * @param name defines the name of the mesh
  107485. * @param options defines the options used to create the mesh
  107486. * @param scene defines the hosting scene
  107487. * @returns the custom extruded shape mesh
  107488. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  107489. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107490. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107491. */
  107492. static ExtrudeShapeCustom(name: string, options: {
  107493. shape: Vector3[];
  107494. path: Vector3[];
  107495. scaleFunction?: any;
  107496. rotationFunction?: any;
  107497. ribbonCloseArray?: boolean;
  107498. ribbonClosePath?: boolean;
  107499. cap?: number;
  107500. updatable?: boolean;
  107501. sideOrientation?: number;
  107502. frontUVs?: Vector4;
  107503. backUVs?: Vector4;
  107504. instance?: Mesh;
  107505. invertUV?: boolean;
  107506. }, scene?: Nullable<Scene>): Mesh;
  107507. private static _ExtrudeShapeGeneric;
  107508. }
  107509. }
  107510. declare module BABYLON {
  107511. /**
  107512. * AmmoJS Physics plugin
  107513. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107514. * @see https://github.com/kripken/ammo.js/
  107515. */
  107516. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  107517. private _useDeltaForWorldStep;
  107518. /**
  107519. * Reference to the Ammo library
  107520. */
  107521. bjsAMMO: any;
  107522. /**
  107523. * Created ammoJS world which physics bodies are added to
  107524. */
  107525. world: any;
  107526. /**
  107527. * Name of the plugin
  107528. */
  107529. name: string;
  107530. private _timeStep;
  107531. private _fixedTimeStep;
  107532. private _maxSteps;
  107533. private _tmpQuaternion;
  107534. private _tmpAmmoTransform;
  107535. private _tmpAmmoQuaternion;
  107536. private _tmpAmmoConcreteContactResultCallback;
  107537. private _collisionConfiguration;
  107538. private _dispatcher;
  107539. private _overlappingPairCache;
  107540. private _solver;
  107541. private _softBodySolver;
  107542. private _tmpAmmoVectorA;
  107543. private _tmpAmmoVectorB;
  107544. private _tmpAmmoVectorC;
  107545. private _tmpAmmoVectorD;
  107546. private _tmpContactCallbackResult;
  107547. private _tmpAmmoVectorRCA;
  107548. private _tmpAmmoVectorRCB;
  107549. private _raycastResult;
  107550. private static readonly DISABLE_COLLISION_FLAG;
  107551. private static readonly KINEMATIC_FLAG;
  107552. private static readonly DISABLE_DEACTIVATION_FLAG;
  107553. /**
  107554. * Initializes the ammoJS plugin
  107555. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107556. * @param ammoInjection can be used to inject your own ammo reference
  107557. */
  107558. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  107559. /**
  107560. * Sets the gravity of the physics world (m/(s^2))
  107561. * @param gravity Gravity to set
  107562. */
  107563. setGravity(gravity: Vector3): void;
  107564. /**
  107565. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  107566. * @param timeStep timestep to use in seconds
  107567. */
  107568. setTimeStep(timeStep: number): void;
  107569. /**
  107570. * 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)
  107571. * @param fixedTimeStep fixedTimeStep to use in seconds
  107572. */
  107573. setFixedTimeStep(fixedTimeStep: number): void;
  107574. /**
  107575. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  107576. * @param maxSteps the maximum number of steps by the physics engine per frame
  107577. */
  107578. setMaxSteps(maxSteps: number): void;
  107579. /**
  107580. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  107581. * @returns the current timestep in seconds
  107582. */
  107583. getTimeStep(): number;
  107584. private _isImpostorInContact;
  107585. private _isImpostorPairInContact;
  107586. private _stepSimulation;
  107587. /**
  107588. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  107589. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  107590. * After the step the babylon meshes are set to the position of the physics imposters
  107591. * @param delta amount of time to step forward
  107592. * @param impostors array of imposters to update before/after the step
  107593. */
  107594. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107595. /**
  107596. * Update babylon mesh to match physics world object
  107597. * @param impostor imposter to match
  107598. */
  107599. private _afterSoftStep;
  107600. /**
  107601. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  107602. * @param impostor imposter to match
  107603. */
  107604. private _ropeStep;
  107605. /**
  107606. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  107607. * @param impostor imposter to match
  107608. */
  107609. private _softbodyOrClothStep;
  107610. private _tmpVector;
  107611. private _tmpMatrix;
  107612. /**
  107613. * Applies an impulse on the imposter
  107614. * @param impostor imposter to apply impulse to
  107615. * @param force amount of force to be applied to the imposter
  107616. * @param contactPoint the location to apply the impulse on the imposter
  107617. */
  107618. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107619. /**
  107620. * Applies a force on the imposter
  107621. * @param impostor imposter to apply force
  107622. * @param force amount of force to be applied to the imposter
  107623. * @param contactPoint the location to apply the force on the imposter
  107624. */
  107625. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107626. /**
  107627. * Creates a physics body using the plugin
  107628. * @param impostor the imposter to create the physics body on
  107629. */
  107630. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107631. /**
  107632. * Removes the physics body from the imposter and disposes of the body's memory
  107633. * @param impostor imposter to remove the physics body from
  107634. */
  107635. removePhysicsBody(impostor: PhysicsImpostor): void;
  107636. /**
  107637. * Generates a joint
  107638. * @param impostorJoint the imposter joint to create the joint with
  107639. */
  107640. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107641. /**
  107642. * Removes a joint
  107643. * @param impostorJoint the imposter joint to remove the joint from
  107644. */
  107645. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107646. private _addMeshVerts;
  107647. /**
  107648. * Initialise the soft body vertices to match its object's (mesh) vertices
  107649. * Softbody vertices (nodes) are in world space and to match this
  107650. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  107651. * @param impostor to create the softbody for
  107652. */
  107653. private _softVertexData;
  107654. /**
  107655. * Create an impostor's soft body
  107656. * @param impostor to create the softbody for
  107657. */
  107658. private _createSoftbody;
  107659. /**
  107660. * Create cloth for an impostor
  107661. * @param impostor to create the softbody for
  107662. */
  107663. private _createCloth;
  107664. /**
  107665. * Create rope for an impostor
  107666. * @param impostor to create the softbody for
  107667. */
  107668. private _createRope;
  107669. private _addHullVerts;
  107670. private _createShape;
  107671. /**
  107672. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  107673. * @param impostor imposter containing the physics body and babylon object
  107674. */
  107675. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107676. /**
  107677. * Sets the babylon object's position/rotation from the physics body's position/rotation
  107678. * @param impostor imposter containing the physics body and babylon object
  107679. * @param newPosition new position
  107680. * @param newRotation new rotation
  107681. */
  107682. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107683. /**
  107684. * If this plugin is supported
  107685. * @returns true if its supported
  107686. */
  107687. isSupported(): boolean;
  107688. /**
  107689. * Sets the linear velocity of the physics body
  107690. * @param impostor imposter to set the velocity on
  107691. * @param velocity velocity to set
  107692. */
  107693. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107694. /**
  107695. * Sets the angular velocity of the physics body
  107696. * @param impostor imposter to set the velocity on
  107697. * @param velocity velocity to set
  107698. */
  107699. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107700. /**
  107701. * gets the linear velocity
  107702. * @param impostor imposter to get linear velocity from
  107703. * @returns linear velocity
  107704. */
  107705. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107706. /**
  107707. * gets the angular velocity
  107708. * @param impostor imposter to get angular velocity from
  107709. * @returns angular velocity
  107710. */
  107711. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107712. /**
  107713. * Sets the mass of physics body
  107714. * @param impostor imposter to set the mass on
  107715. * @param mass mass to set
  107716. */
  107717. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107718. /**
  107719. * Gets the mass of the physics body
  107720. * @param impostor imposter to get the mass from
  107721. * @returns mass
  107722. */
  107723. getBodyMass(impostor: PhysicsImpostor): number;
  107724. /**
  107725. * Gets friction of the impostor
  107726. * @param impostor impostor to get friction from
  107727. * @returns friction value
  107728. */
  107729. getBodyFriction(impostor: PhysicsImpostor): number;
  107730. /**
  107731. * Sets friction of the impostor
  107732. * @param impostor impostor to set friction on
  107733. * @param friction friction value
  107734. */
  107735. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107736. /**
  107737. * Gets restitution of the impostor
  107738. * @param impostor impostor to get restitution from
  107739. * @returns restitution value
  107740. */
  107741. getBodyRestitution(impostor: PhysicsImpostor): number;
  107742. /**
  107743. * Sets resitution of the impostor
  107744. * @param impostor impostor to set resitution on
  107745. * @param restitution resitution value
  107746. */
  107747. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107748. /**
  107749. * Gets pressure inside the impostor
  107750. * @param impostor impostor to get pressure from
  107751. * @returns pressure value
  107752. */
  107753. getBodyPressure(impostor: PhysicsImpostor): number;
  107754. /**
  107755. * Sets pressure inside a soft body impostor
  107756. * Cloth and rope must remain 0 pressure
  107757. * @param impostor impostor to set pressure on
  107758. * @param pressure pressure value
  107759. */
  107760. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  107761. /**
  107762. * Gets stiffness of the impostor
  107763. * @param impostor impostor to get stiffness from
  107764. * @returns pressure value
  107765. */
  107766. getBodyStiffness(impostor: PhysicsImpostor): number;
  107767. /**
  107768. * Sets stiffness of the impostor
  107769. * @param impostor impostor to set stiffness on
  107770. * @param stiffness stiffness value from 0 to 1
  107771. */
  107772. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  107773. /**
  107774. * Gets velocityIterations of the impostor
  107775. * @param impostor impostor to get velocity iterations from
  107776. * @returns velocityIterations value
  107777. */
  107778. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  107779. /**
  107780. * Sets velocityIterations of the impostor
  107781. * @param impostor impostor to set velocity iterations on
  107782. * @param velocityIterations velocityIterations value
  107783. */
  107784. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  107785. /**
  107786. * Gets positionIterations of the impostor
  107787. * @param impostor impostor to get position iterations from
  107788. * @returns positionIterations value
  107789. */
  107790. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  107791. /**
  107792. * Sets positionIterations of the impostor
  107793. * @param impostor impostor to set position on
  107794. * @param positionIterations positionIterations value
  107795. */
  107796. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  107797. /**
  107798. * Append an anchor to a cloth object
  107799. * @param impostor is the cloth impostor to add anchor to
  107800. * @param otherImpostor is the rigid impostor to anchor to
  107801. * @param width ratio across width from 0 to 1
  107802. * @param height ratio up height from 0 to 1
  107803. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  107804. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107805. */
  107806. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  107807. /**
  107808. * Append an hook to a rope object
  107809. * @param impostor is the rope impostor to add hook to
  107810. * @param otherImpostor is the rigid impostor to hook to
  107811. * @param length ratio along the rope from 0 to 1
  107812. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  107813. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107814. */
  107815. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  107816. /**
  107817. * Sleeps the physics body and stops it from being active
  107818. * @param impostor impostor to sleep
  107819. */
  107820. sleepBody(impostor: PhysicsImpostor): void;
  107821. /**
  107822. * Activates the physics body
  107823. * @param impostor impostor to activate
  107824. */
  107825. wakeUpBody(impostor: PhysicsImpostor): void;
  107826. /**
  107827. * Updates the distance parameters of the joint
  107828. * @param joint joint to update
  107829. * @param maxDistance maximum distance of the joint
  107830. * @param minDistance minimum distance of the joint
  107831. */
  107832. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107833. /**
  107834. * Sets a motor on the joint
  107835. * @param joint joint to set motor on
  107836. * @param speed speed of the motor
  107837. * @param maxForce maximum force of the motor
  107838. * @param motorIndex index of the motor
  107839. */
  107840. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107841. /**
  107842. * Sets the motors limit
  107843. * @param joint joint to set limit on
  107844. * @param upperLimit upper limit
  107845. * @param lowerLimit lower limit
  107846. */
  107847. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107848. /**
  107849. * Syncs the position and rotation of a mesh with the impostor
  107850. * @param mesh mesh to sync
  107851. * @param impostor impostor to update the mesh with
  107852. */
  107853. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107854. /**
  107855. * Gets the radius of the impostor
  107856. * @param impostor impostor to get radius from
  107857. * @returns the radius
  107858. */
  107859. getRadius(impostor: PhysicsImpostor): number;
  107860. /**
  107861. * Gets the box size of the impostor
  107862. * @param impostor impostor to get box size from
  107863. * @param result the resulting box size
  107864. */
  107865. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107866. /**
  107867. * Disposes of the impostor
  107868. */
  107869. dispose(): void;
  107870. /**
  107871. * Does a raycast in the physics world
  107872. * @param from when should the ray start?
  107873. * @param to when should the ray end?
  107874. * @returns PhysicsRaycastResult
  107875. */
  107876. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107877. }
  107878. }
  107879. declare module BABYLON {
  107880. interface AbstractScene {
  107881. /**
  107882. * The list of reflection probes added to the scene
  107883. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  107884. */
  107885. reflectionProbes: Array<ReflectionProbe>;
  107886. /**
  107887. * Removes the given reflection probe from this scene.
  107888. * @param toRemove The reflection probe to remove
  107889. * @returns The index of the removed reflection probe
  107890. */
  107891. removeReflectionProbe(toRemove: ReflectionProbe): number;
  107892. /**
  107893. * Adds the given reflection probe to this scene.
  107894. * @param newReflectionProbe The reflection probe to add
  107895. */
  107896. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  107897. }
  107898. /**
  107899. * Class used to generate realtime reflection / refraction cube textures
  107900. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  107901. */
  107902. export class ReflectionProbe {
  107903. /** defines the name of the probe */
  107904. name: string;
  107905. private _scene;
  107906. private _renderTargetTexture;
  107907. private _projectionMatrix;
  107908. private _viewMatrix;
  107909. private _target;
  107910. private _add;
  107911. private _attachedMesh;
  107912. private _invertYAxis;
  107913. /** Gets or sets probe position (center of the cube map) */
  107914. position: Vector3;
  107915. /**
  107916. * Creates a new reflection probe
  107917. * @param name defines the name of the probe
  107918. * @param size defines the texture resolution (for each face)
  107919. * @param scene defines the hosting scene
  107920. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  107921. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  107922. */
  107923. constructor(
  107924. /** defines the name of the probe */
  107925. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  107926. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  107927. samples: number;
  107928. /** Gets or sets the refresh rate to use (on every frame by default) */
  107929. refreshRate: number;
  107930. /**
  107931. * Gets the hosting scene
  107932. * @returns a Scene
  107933. */
  107934. getScene(): Scene;
  107935. /** Gets the internal CubeTexture used to render to */
  107936. readonly cubeTexture: RenderTargetTexture;
  107937. /** Gets the list of meshes to render */
  107938. readonly renderList: Nullable<AbstractMesh[]>;
  107939. /**
  107940. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  107941. * @param mesh defines the mesh to attach to
  107942. */
  107943. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  107944. /**
  107945. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  107946. * @param renderingGroupId The rendering group id corresponding to its index
  107947. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  107948. */
  107949. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  107950. /**
  107951. * Clean all associated resources
  107952. */
  107953. dispose(): void;
  107954. /**
  107955. * Converts the reflection probe information to a readable string for debug purpose.
  107956. * @param fullDetails Supports for multiple levels of logging within scene loading
  107957. * @returns the human readable reflection probe info
  107958. */
  107959. toString(fullDetails?: boolean): string;
  107960. /**
  107961. * Get the class name of the relfection probe.
  107962. * @returns "ReflectionProbe"
  107963. */
  107964. getClassName(): string;
  107965. /**
  107966. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  107967. * @returns The JSON representation of the texture
  107968. */
  107969. serialize(): any;
  107970. /**
  107971. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  107972. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  107973. * @param scene Define the scene the parsed reflection probe should be instantiated in
  107974. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  107975. * @returns The parsed reflection probe if successful
  107976. */
  107977. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  107978. }
  107979. }
  107980. declare module BABYLON {
  107981. /** @hidden */
  107982. export var _BabylonLoaderRegistered: boolean;
  107983. }
  107984. declare module BABYLON {
  107985. /**
  107986. * The Physically based simple base material of BJS.
  107987. *
  107988. * This enables better naming and convention enforcements on top of the pbrMaterial.
  107989. * It is used as the base class for both the specGloss and metalRough conventions.
  107990. */
  107991. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  107992. /**
  107993. * Number of Simultaneous lights allowed on the material.
  107994. */
  107995. maxSimultaneousLights: number;
  107996. /**
  107997. * If sets to true, disables all the lights affecting the material.
  107998. */
  107999. disableLighting: boolean;
  108000. /**
  108001. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  108002. */
  108003. environmentTexture: BaseTexture;
  108004. /**
  108005. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108006. */
  108007. invertNormalMapX: boolean;
  108008. /**
  108009. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108010. */
  108011. invertNormalMapY: boolean;
  108012. /**
  108013. * Normal map used in the model.
  108014. */
  108015. normalTexture: BaseTexture;
  108016. /**
  108017. * Emissivie color used to self-illuminate the model.
  108018. */
  108019. emissiveColor: Color3;
  108020. /**
  108021. * Emissivie texture used to self-illuminate the model.
  108022. */
  108023. emissiveTexture: BaseTexture;
  108024. /**
  108025. * Occlusion Channel Strenght.
  108026. */
  108027. occlusionStrength: number;
  108028. /**
  108029. * Occlusion Texture of the material (adding extra occlusion effects).
  108030. */
  108031. occlusionTexture: BaseTexture;
  108032. /**
  108033. * Defines the alpha limits in alpha test mode.
  108034. */
  108035. alphaCutOff: number;
  108036. /**
  108037. * Gets the current double sided mode.
  108038. */
  108039. /**
  108040. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108041. */
  108042. doubleSided: boolean;
  108043. /**
  108044. * Stores the pre-calculated light information of a mesh in a texture.
  108045. */
  108046. lightmapTexture: BaseTexture;
  108047. /**
  108048. * If true, the light map contains occlusion information instead of lighting info.
  108049. */
  108050. useLightmapAsShadowmap: boolean;
  108051. /**
  108052. * Instantiates a new PBRMaterial instance.
  108053. *
  108054. * @param name The material name
  108055. * @param scene The scene the material will be use in.
  108056. */
  108057. constructor(name: string, scene: Scene);
  108058. getClassName(): string;
  108059. }
  108060. }
  108061. declare module BABYLON {
  108062. /**
  108063. * The PBR material of BJS following the metal roughness convention.
  108064. *
  108065. * This fits to the PBR convention in the GLTF definition:
  108066. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  108067. */
  108068. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  108069. /**
  108070. * The base color has two different interpretations depending on the value of metalness.
  108071. * When the material is a metal, the base color is the specific measured reflectance value
  108072. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  108073. * of the material.
  108074. */
  108075. baseColor: Color3;
  108076. /**
  108077. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  108078. * well as opacity information in the alpha channel.
  108079. */
  108080. baseTexture: BaseTexture;
  108081. /**
  108082. * Specifies the metallic scalar value of the material.
  108083. * Can also be used to scale the metalness values of the metallic texture.
  108084. */
  108085. metallic: number;
  108086. /**
  108087. * Specifies the roughness scalar value of the material.
  108088. * Can also be used to scale the roughness values of the metallic texture.
  108089. */
  108090. roughness: number;
  108091. /**
  108092. * Texture containing both the metallic value in the B channel and the
  108093. * roughness value in the G channel to keep better precision.
  108094. */
  108095. metallicRoughnessTexture: BaseTexture;
  108096. /**
  108097. * Instantiates a new PBRMetalRoughnessMaterial instance.
  108098. *
  108099. * @param name The material name
  108100. * @param scene The scene the material will be use in.
  108101. */
  108102. constructor(name: string, scene: Scene);
  108103. /**
  108104. * Return the currrent class name of the material.
  108105. */
  108106. getClassName(): string;
  108107. /**
  108108. * Makes a duplicate of the current material.
  108109. * @param name - name to use for the new material.
  108110. */
  108111. clone(name: string): PBRMetallicRoughnessMaterial;
  108112. /**
  108113. * Serialize the material to a parsable JSON object.
  108114. */
  108115. serialize(): any;
  108116. /**
  108117. * Parses a JSON object correponding to the serialize function.
  108118. */
  108119. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  108120. }
  108121. }
  108122. declare module BABYLON {
  108123. /**
  108124. * The PBR material of BJS following the specular glossiness convention.
  108125. *
  108126. * This fits to the PBR convention in the GLTF definition:
  108127. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  108128. */
  108129. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  108130. /**
  108131. * Specifies the diffuse color of the material.
  108132. */
  108133. diffuseColor: Color3;
  108134. /**
  108135. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  108136. * channel.
  108137. */
  108138. diffuseTexture: BaseTexture;
  108139. /**
  108140. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  108141. */
  108142. specularColor: Color3;
  108143. /**
  108144. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  108145. */
  108146. glossiness: number;
  108147. /**
  108148. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  108149. */
  108150. specularGlossinessTexture: BaseTexture;
  108151. /**
  108152. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  108153. *
  108154. * @param name The material name
  108155. * @param scene The scene the material will be use in.
  108156. */
  108157. constructor(name: string, scene: Scene);
  108158. /**
  108159. * Return the currrent class name of the material.
  108160. */
  108161. getClassName(): string;
  108162. /**
  108163. * Makes a duplicate of the current material.
  108164. * @param name - name to use for the new material.
  108165. */
  108166. clone(name: string): PBRSpecularGlossinessMaterial;
  108167. /**
  108168. * Serialize the material to a parsable JSON object.
  108169. */
  108170. serialize(): any;
  108171. /**
  108172. * Parses a JSON object correponding to the serialize function.
  108173. */
  108174. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  108175. }
  108176. }
  108177. declare module BABYLON {
  108178. /**
  108179. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  108180. * It can help converting any input color in a desired output one. This can then be used to create effects
  108181. * from sepia, black and white to sixties or futuristic rendering...
  108182. *
  108183. * The only supported format is currently 3dl.
  108184. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  108185. */
  108186. export class ColorGradingTexture extends BaseTexture {
  108187. /**
  108188. * The current texture matrix. (will always be identity in color grading texture)
  108189. */
  108190. private _textureMatrix;
  108191. /**
  108192. * The texture URL.
  108193. */
  108194. url: string;
  108195. /**
  108196. * Empty line regex stored for GC.
  108197. */
  108198. private static _noneEmptyLineRegex;
  108199. private _engine;
  108200. /**
  108201. * Instantiates a ColorGradingTexture from the following parameters.
  108202. *
  108203. * @param url The location of the color gradind data (currently only supporting 3dl)
  108204. * @param scene The scene the texture will be used in
  108205. */
  108206. constructor(url: string, scene: Scene);
  108207. /**
  108208. * Returns the texture matrix used in most of the material.
  108209. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  108210. */
  108211. getTextureMatrix(): Matrix;
  108212. /**
  108213. * Occurs when the file being loaded is a .3dl LUT file.
  108214. */
  108215. private load3dlTexture;
  108216. /**
  108217. * Starts the loading process of the texture.
  108218. */
  108219. private loadTexture;
  108220. /**
  108221. * Clones the color gradind texture.
  108222. */
  108223. clone(): ColorGradingTexture;
  108224. /**
  108225. * Called during delayed load for textures.
  108226. */
  108227. delayLoad(): void;
  108228. /**
  108229. * Parses a color grading texture serialized by Babylon.
  108230. * @param parsedTexture The texture information being parsedTexture
  108231. * @param scene The scene to load the texture in
  108232. * @param rootUrl The root url of the data assets to load
  108233. * @return A color gradind texture
  108234. */
  108235. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  108236. /**
  108237. * Serializes the LUT texture to json format.
  108238. */
  108239. serialize(): any;
  108240. }
  108241. }
  108242. declare module BABYLON {
  108243. /**
  108244. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  108245. */
  108246. export class EquiRectangularCubeTexture extends BaseTexture {
  108247. /** The six faces of the cube. */
  108248. private static _FacesMapping;
  108249. private _noMipmap;
  108250. private _onLoad;
  108251. private _onError;
  108252. /** The size of the cubemap. */
  108253. private _size;
  108254. /** The buffer of the image. */
  108255. private _buffer;
  108256. /** The width of the input image. */
  108257. private _width;
  108258. /** The height of the input image. */
  108259. private _height;
  108260. /** The URL to the image. */
  108261. url: string;
  108262. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  108263. coordinatesMode: number;
  108264. /**
  108265. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  108266. * @param url The location of the image
  108267. * @param scene The scene the texture will be used in
  108268. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  108269. * @param noMipmap Forces to not generate the mipmap if true
  108270. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  108271. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  108272. * @param onLoad — defines a callback called when texture is loaded
  108273. * @param onError — defines a callback called if there is an error
  108274. */
  108275. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  108276. /**
  108277. * Load the image data, by putting the image on a canvas and extracting its buffer.
  108278. */
  108279. private loadImage;
  108280. /**
  108281. * Convert the image buffer into a cubemap and create a CubeTexture.
  108282. */
  108283. private loadTexture;
  108284. /**
  108285. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  108286. * @param buffer The ArrayBuffer that should be converted.
  108287. * @returns The buffer as Float32Array.
  108288. */
  108289. private getFloat32ArrayFromArrayBuffer;
  108290. /**
  108291. * Get the current class name of the texture useful for serialization or dynamic coding.
  108292. * @returns "EquiRectangularCubeTexture"
  108293. */
  108294. getClassName(): string;
  108295. /**
  108296. * Create a clone of the current EquiRectangularCubeTexture and return it.
  108297. * @returns A clone of the current EquiRectangularCubeTexture.
  108298. */
  108299. clone(): EquiRectangularCubeTexture;
  108300. }
  108301. }
  108302. declare module BABYLON {
  108303. /**
  108304. * Based on jsTGALoader - Javascript loader for TGA file
  108305. * By Vincent Thibault
  108306. * @see http://blog.robrowser.com/javascript-tga-loader.html
  108307. */
  108308. export class TGATools {
  108309. private static _TYPE_INDEXED;
  108310. private static _TYPE_RGB;
  108311. private static _TYPE_GREY;
  108312. private static _TYPE_RLE_INDEXED;
  108313. private static _TYPE_RLE_RGB;
  108314. private static _TYPE_RLE_GREY;
  108315. private static _ORIGIN_MASK;
  108316. private static _ORIGIN_SHIFT;
  108317. private static _ORIGIN_BL;
  108318. private static _ORIGIN_BR;
  108319. private static _ORIGIN_UL;
  108320. private static _ORIGIN_UR;
  108321. /**
  108322. * Gets the header of a TGA file
  108323. * @param data defines the TGA data
  108324. * @returns the header
  108325. */
  108326. static GetTGAHeader(data: Uint8Array): any;
  108327. /**
  108328. * Uploads TGA content to a Babylon Texture
  108329. * @hidden
  108330. */
  108331. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  108332. /** @hidden */
  108333. 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;
  108334. /** @hidden */
  108335. 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;
  108336. /** @hidden */
  108337. 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;
  108338. /** @hidden */
  108339. 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;
  108340. /** @hidden */
  108341. 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;
  108342. /** @hidden */
  108343. 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;
  108344. }
  108345. }
  108346. declare module BABYLON {
  108347. /**
  108348. * Implementation of the TGA Texture Loader.
  108349. * @hidden
  108350. */
  108351. export class _TGATextureLoader implements IInternalTextureLoader {
  108352. /**
  108353. * Defines wether the loader supports cascade loading the different faces.
  108354. */
  108355. readonly supportCascades: boolean;
  108356. /**
  108357. * This returns if the loader support the current file information.
  108358. * @param extension defines the file extension of the file being loaded
  108359. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108360. * @param fallback defines the fallback internal texture if any
  108361. * @param isBase64 defines whether the texture is encoded as a base64
  108362. * @param isBuffer defines whether the texture data are stored as a buffer
  108363. * @returns true if the loader can load the specified file
  108364. */
  108365. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  108366. /**
  108367. * Transform the url before loading if required.
  108368. * @param rootUrl the url of the texture
  108369. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108370. * @returns the transformed texture
  108371. */
  108372. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  108373. /**
  108374. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  108375. * @param rootUrl the url of the texture
  108376. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108377. * @returns the fallback texture
  108378. */
  108379. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  108380. /**
  108381. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  108382. * @param data contains the texture data
  108383. * @param texture defines the BabylonJS internal texture
  108384. * @param createPolynomials will be true if polynomials have been requested
  108385. * @param onLoad defines the callback to trigger once the texture is ready
  108386. * @param onError defines the callback to trigger in case of error
  108387. */
  108388. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  108389. /**
  108390. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  108391. * @param data contains the texture data
  108392. * @param texture defines the BabylonJS internal texture
  108393. * @param callback defines the method to call once ready to upload
  108394. */
  108395. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  108396. }
  108397. }
  108398. declare module BABYLON {
  108399. /**
  108400. * 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.
  108401. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  108402. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  108403. */
  108404. export class CustomProceduralTexture extends ProceduralTexture {
  108405. private _animate;
  108406. private _time;
  108407. private _config;
  108408. private _texturePath;
  108409. /**
  108410. * Instantiates a new Custom Procedural Texture.
  108411. * 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.
  108412. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  108413. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  108414. * @param name Define the name of the texture
  108415. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  108416. * @param size Define the size of the texture to create
  108417. * @param scene Define the scene the texture belongs to
  108418. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  108419. * @param generateMipMaps Define if the texture should creates mip maps or not
  108420. */
  108421. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  108422. private _loadJson;
  108423. /**
  108424. * Is the texture ready to be used ? (rendered at least once)
  108425. * @returns true if ready, otherwise, false.
  108426. */
  108427. isReady(): boolean;
  108428. /**
  108429. * Render the texture to its associated render target.
  108430. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  108431. */
  108432. render(useCameraPostProcess?: boolean): void;
  108433. /**
  108434. * Update the list of dependant textures samplers in the shader.
  108435. */
  108436. updateTextures(): void;
  108437. /**
  108438. * Update the uniform values of the procedural texture in the shader.
  108439. */
  108440. updateShaderUniforms(): void;
  108441. /**
  108442. * Define if the texture animates or not.
  108443. */
  108444. animate: boolean;
  108445. }
  108446. }
  108447. declare module BABYLON {
  108448. /** @hidden */
  108449. export var noisePixelShader: {
  108450. name: string;
  108451. shader: string;
  108452. };
  108453. }
  108454. declare module BABYLON {
  108455. /**
  108456. * Class used to generate noise procedural textures
  108457. */
  108458. export class NoiseProceduralTexture extends ProceduralTexture {
  108459. private _time;
  108460. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  108461. brightness: number;
  108462. /** Defines the number of octaves to process */
  108463. octaves: number;
  108464. /** Defines the level of persistence (0.8 by default) */
  108465. persistence: number;
  108466. /** Gets or sets animation speed factor (default is 1) */
  108467. animationSpeedFactor: number;
  108468. /**
  108469. * Creates a new NoiseProceduralTexture
  108470. * @param name defines the name fo the texture
  108471. * @param size defines the size of the texture (default is 256)
  108472. * @param scene defines the hosting scene
  108473. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  108474. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  108475. */
  108476. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  108477. private _updateShaderUniforms;
  108478. protected _getDefines(): string;
  108479. /** Generate the current state of the procedural texture */
  108480. render(useCameraPostProcess?: boolean): void;
  108481. /**
  108482. * Serializes this noise procedural texture
  108483. * @returns a serialized noise procedural texture object
  108484. */
  108485. serialize(): any;
  108486. /**
  108487. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  108488. * @param parsedTexture defines parsed texture data
  108489. * @param scene defines the current scene
  108490. * @param rootUrl defines the root URL containing noise procedural texture information
  108491. * @returns a parsed NoiseProceduralTexture
  108492. */
  108493. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  108494. }
  108495. }
  108496. declare module BABYLON {
  108497. /**
  108498. * Raw cube texture where the raw buffers are passed in
  108499. */
  108500. export class RawCubeTexture extends CubeTexture {
  108501. /**
  108502. * Creates a cube texture where the raw buffers are passed in.
  108503. * @param scene defines the scene the texture is attached to
  108504. * @param data defines the array of data to use to create each face
  108505. * @param size defines the size of the textures
  108506. * @param format defines the format of the data
  108507. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  108508. * @param generateMipMaps defines if the engine should generate the mip levels
  108509. * @param invertY defines if data must be stored with Y axis inverted
  108510. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  108511. * @param compression defines the compression used (null by default)
  108512. */
  108513. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  108514. /**
  108515. * Updates the raw cube texture.
  108516. * @param data defines the data to store
  108517. * @param format defines the data format
  108518. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  108519. * @param invertY defines if data must be stored with Y axis inverted
  108520. * @param compression defines the compression used (null by default)
  108521. * @param level defines which level of the texture to update
  108522. */
  108523. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  108524. /**
  108525. * Updates a raw cube texture with RGBD encoded data.
  108526. * @param data defines the array of data [mipmap][face] to use to create each face
  108527. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  108528. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  108529. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  108530. * @returns a promsie that resolves when the operation is complete
  108531. */
  108532. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  108533. /**
  108534. * Clones the raw cube texture.
  108535. * @return a new cube texture
  108536. */
  108537. clone(): CubeTexture;
  108538. /** @hidden */
  108539. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  108540. }
  108541. }
  108542. declare module BABYLON {
  108543. /**
  108544. * Class used to store 3D textures containing user data
  108545. */
  108546. export class RawTexture3D extends Texture {
  108547. /** Gets or sets the texture format to use */
  108548. format: number;
  108549. private _engine;
  108550. /**
  108551. * Create a new RawTexture3D
  108552. * @param data defines the data of the texture
  108553. * @param width defines the width of the texture
  108554. * @param height defines the height of the texture
  108555. * @param depth defines the depth of the texture
  108556. * @param format defines the texture format to use
  108557. * @param scene defines the hosting scene
  108558. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  108559. * @param invertY defines if texture must be stored with Y axis inverted
  108560. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  108561. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  108562. */
  108563. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  108564. /** Gets or sets the texture format to use */
  108565. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  108566. /**
  108567. * Update the texture with new data
  108568. * @param data defines the data to store in the texture
  108569. */
  108570. update(data: ArrayBufferView): void;
  108571. }
  108572. }
  108573. declare module BABYLON {
  108574. /**
  108575. * Creates a refraction texture used by refraction channel of the standard material.
  108576. * It is like a mirror but to see through a material.
  108577. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108578. */
  108579. export class RefractionTexture extends RenderTargetTexture {
  108580. /**
  108581. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  108582. * 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.
  108583. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108584. */
  108585. refractionPlane: Plane;
  108586. /**
  108587. * Define how deep under the surface we should see.
  108588. */
  108589. depth: number;
  108590. /**
  108591. * Creates a refraction texture used by refraction channel of the standard material.
  108592. * It is like a mirror but to see through a material.
  108593. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108594. * @param name Define the texture name
  108595. * @param size Define the size of the underlying texture
  108596. * @param scene Define the scene the refraction belongs to
  108597. * @param generateMipMaps Define if we need to generate mips level for the refraction
  108598. */
  108599. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  108600. /**
  108601. * Clone the refraction texture.
  108602. * @returns the cloned texture
  108603. */
  108604. clone(): RefractionTexture;
  108605. /**
  108606. * Serialize the texture to a JSON representation you could use in Parse later on
  108607. * @returns the serialized JSON representation
  108608. */
  108609. serialize(): any;
  108610. }
  108611. }
  108612. declare module BABYLON {
  108613. /**
  108614. * Helper class to push actions to a pool of workers.
  108615. */
  108616. export class WorkerPool implements IDisposable {
  108617. private _workerInfos;
  108618. private _pendingActions;
  108619. /**
  108620. * Constructor
  108621. * @param workers Array of workers to use for actions
  108622. */
  108623. constructor(workers: Array<Worker>);
  108624. /**
  108625. * Terminates all workers and clears any pending actions.
  108626. */
  108627. dispose(): void;
  108628. /**
  108629. * Pushes an action to the worker pool. If all the workers are active, the action will be
  108630. * pended until a worker has completed its action.
  108631. * @param action The action to perform. Call onComplete when the action is complete.
  108632. */
  108633. push(action: (worker: Worker, onComplete: () => void) => void): void;
  108634. private _execute;
  108635. }
  108636. }
  108637. declare module BABYLON {
  108638. /**
  108639. * Configuration for Draco compression
  108640. */
  108641. export interface IDracoCompressionConfiguration {
  108642. /**
  108643. * Configuration for the decoder.
  108644. */
  108645. decoder?: {
  108646. /**
  108647. * The url to the WebAssembly module.
  108648. */
  108649. wasmUrl?: string;
  108650. /**
  108651. * The url to the WebAssembly binary.
  108652. */
  108653. wasmBinaryUrl?: string;
  108654. /**
  108655. * The url to the fallback JavaScript module.
  108656. */
  108657. fallbackUrl?: string;
  108658. };
  108659. }
  108660. /**
  108661. * Draco compression (https://google.github.io/draco/)
  108662. *
  108663. * This class wraps the Draco module.
  108664. *
  108665. * **Encoder**
  108666. *
  108667. * The encoder is not currently implemented.
  108668. *
  108669. * **Decoder**
  108670. *
  108671. * 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.
  108672. *
  108673. * To update the configuration, use the following code:
  108674. * ```javascript
  108675. * DracoCompression.Configuration = {
  108676. * decoder: {
  108677. * wasmUrl: "<url to the WebAssembly library>",
  108678. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  108679. * fallbackUrl: "<url to the fallback JavaScript library>",
  108680. * }
  108681. * };
  108682. * ```
  108683. *
  108684. * 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.
  108685. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  108686. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  108687. *
  108688. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  108689. * ```javascript
  108690. * var dracoCompression = new DracoCompression();
  108691. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  108692. * [VertexBuffer.PositionKind]: 0
  108693. * });
  108694. * ```
  108695. *
  108696. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  108697. */
  108698. export class DracoCompression implements IDisposable {
  108699. private _workerPoolPromise;
  108700. /**
  108701. * The configuration. Defaults to the following urls:
  108702. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  108703. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  108704. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  108705. */
  108706. static Configuration: IDracoCompressionConfiguration;
  108707. /**
  108708. * Returns true if the decoder is available.
  108709. */
  108710. static readonly DecoderAvailable: boolean;
  108711. /**
  108712. * Default number of workers to create when creating the draco compression object.
  108713. */
  108714. static DefaultNumWorkers: number;
  108715. private static GetDefaultNumWorkers;
  108716. /**
  108717. * Constructor
  108718. * @param numWorkers The number of workers for async operations
  108719. */
  108720. constructor(numWorkers?: number);
  108721. /**
  108722. * Stop all async operations and release resources.
  108723. */
  108724. dispose(): void;
  108725. /**
  108726. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  108727. * @returns a promise that resolves when ready
  108728. */
  108729. whenReadyAsync(): Promise<void>;
  108730. /**
  108731. * Decode Draco compressed mesh data to vertex data.
  108732. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  108733. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  108734. * @returns A promise that resolves with the decoded vertex data
  108735. */
  108736. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  108737. [kind: string]: number;
  108738. }): Promise<VertexData>;
  108739. /**
  108740. * The worker function that gets converted to a blob url to pass into a worker.
  108741. */
  108742. private static _Worker;
  108743. private _loadDecoderWasmBinaryAsync;
  108744. }
  108745. }
  108746. declare module BABYLON {
  108747. /**
  108748. * Class for building Constructive Solid Geometry
  108749. */
  108750. export class CSG {
  108751. private polygons;
  108752. /**
  108753. * The world matrix
  108754. */
  108755. matrix: Matrix;
  108756. /**
  108757. * Stores the position
  108758. */
  108759. position: Vector3;
  108760. /**
  108761. * Stores the rotation
  108762. */
  108763. rotation: Vector3;
  108764. /**
  108765. * Stores the rotation quaternion
  108766. */
  108767. rotationQuaternion: Nullable<Quaternion>;
  108768. /**
  108769. * Stores the scaling vector
  108770. */
  108771. scaling: Vector3;
  108772. /**
  108773. * Convert the Mesh to CSG
  108774. * @param mesh The Mesh to convert to CSG
  108775. * @returns A new CSG from the Mesh
  108776. */
  108777. static FromMesh(mesh: Mesh): CSG;
  108778. /**
  108779. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  108780. * @param polygons Polygons used to construct a CSG solid
  108781. */
  108782. private static FromPolygons;
  108783. /**
  108784. * Clones, or makes a deep copy, of the CSG
  108785. * @returns A new CSG
  108786. */
  108787. clone(): CSG;
  108788. /**
  108789. * Unions this CSG with another CSG
  108790. * @param csg The CSG to union against this CSG
  108791. * @returns The unioned CSG
  108792. */
  108793. union(csg: CSG): CSG;
  108794. /**
  108795. * Unions this CSG with another CSG in place
  108796. * @param csg The CSG to union against this CSG
  108797. */
  108798. unionInPlace(csg: CSG): void;
  108799. /**
  108800. * Subtracts this CSG with another CSG
  108801. * @param csg The CSG to subtract against this CSG
  108802. * @returns A new CSG
  108803. */
  108804. subtract(csg: CSG): CSG;
  108805. /**
  108806. * Subtracts this CSG with another CSG in place
  108807. * @param csg The CSG to subtact against this CSG
  108808. */
  108809. subtractInPlace(csg: CSG): void;
  108810. /**
  108811. * Intersect this CSG with another CSG
  108812. * @param csg The CSG to intersect against this CSG
  108813. * @returns A new CSG
  108814. */
  108815. intersect(csg: CSG): CSG;
  108816. /**
  108817. * Intersects this CSG with another CSG in place
  108818. * @param csg The CSG to intersect against this CSG
  108819. */
  108820. intersectInPlace(csg: CSG): void;
  108821. /**
  108822. * Return a new CSG solid with solid and empty space switched. This solid is
  108823. * not modified.
  108824. * @returns A new CSG solid with solid and empty space switched
  108825. */
  108826. inverse(): CSG;
  108827. /**
  108828. * Inverses the CSG in place
  108829. */
  108830. inverseInPlace(): void;
  108831. /**
  108832. * This is used to keep meshes transformations so they can be restored
  108833. * when we build back a Babylon Mesh
  108834. * NB : All CSG operations are performed in world coordinates
  108835. * @param csg The CSG to copy the transform attributes from
  108836. * @returns This CSG
  108837. */
  108838. copyTransformAttributes(csg: CSG): CSG;
  108839. /**
  108840. * Build Raw mesh from CSG
  108841. * Coordinates here are in world space
  108842. * @param name The name of the mesh geometry
  108843. * @param scene The Scene
  108844. * @param keepSubMeshes Specifies if the submeshes should be kept
  108845. * @returns A new Mesh
  108846. */
  108847. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  108848. /**
  108849. * Build Mesh from CSG taking material and transforms into account
  108850. * @param name The name of the Mesh
  108851. * @param material The material of the Mesh
  108852. * @param scene The Scene
  108853. * @param keepSubMeshes Specifies if submeshes should be kept
  108854. * @returns The new Mesh
  108855. */
  108856. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  108857. }
  108858. }
  108859. declare module BABYLON {
  108860. /**
  108861. * Class used to create a trail following a mesh
  108862. */
  108863. export class TrailMesh extends Mesh {
  108864. private _generator;
  108865. private _autoStart;
  108866. private _running;
  108867. private _diameter;
  108868. private _length;
  108869. private _sectionPolygonPointsCount;
  108870. private _sectionVectors;
  108871. private _sectionNormalVectors;
  108872. private _beforeRenderObserver;
  108873. /**
  108874. * @constructor
  108875. * @param name The value used by scene.getMeshByName() to do a lookup.
  108876. * @param generator The mesh to generate a trail.
  108877. * @param scene The scene to add this mesh to.
  108878. * @param diameter Diameter of trailing mesh. Default is 1.
  108879. * @param length Length of trailing mesh. Default is 60.
  108880. * @param autoStart Automatically start trailing mesh. Default true.
  108881. */
  108882. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  108883. /**
  108884. * "TrailMesh"
  108885. * @returns "TrailMesh"
  108886. */
  108887. getClassName(): string;
  108888. private _createMesh;
  108889. /**
  108890. * Start trailing mesh.
  108891. */
  108892. start(): void;
  108893. /**
  108894. * Stop trailing mesh.
  108895. */
  108896. stop(): void;
  108897. /**
  108898. * Update trailing mesh geometry.
  108899. */
  108900. update(): void;
  108901. /**
  108902. * Returns a new TrailMesh object.
  108903. * @param name is a string, the name given to the new mesh
  108904. * @param newGenerator use new generator object for cloned trail mesh
  108905. * @returns a new mesh
  108906. */
  108907. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  108908. /**
  108909. * Serializes this trail mesh
  108910. * @param serializationObject object to write serialization to
  108911. */
  108912. serialize(serializationObject: any): void;
  108913. /**
  108914. * Parses a serialized trail mesh
  108915. * @param parsedMesh the serialized mesh
  108916. * @param scene the scene to create the trail mesh in
  108917. * @returns the created trail mesh
  108918. */
  108919. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  108920. }
  108921. }
  108922. declare module BABYLON {
  108923. /**
  108924. * Class containing static functions to help procedurally build meshes
  108925. */
  108926. export class TorusKnotBuilder {
  108927. /**
  108928. * Creates a torus knot mesh
  108929. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  108930. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  108931. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  108932. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  108933. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108934. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108936. * @param name defines the name of the mesh
  108937. * @param options defines the options used to create the mesh
  108938. * @param scene defines the hosting scene
  108939. * @returns the torus knot mesh
  108940. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  108941. */
  108942. static CreateTorusKnot(name: string, options: {
  108943. radius?: number;
  108944. tube?: number;
  108945. radialSegments?: number;
  108946. tubularSegments?: number;
  108947. p?: number;
  108948. q?: number;
  108949. updatable?: boolean;
  108950. sideOrientation?: number;
  108951. frontUVs?: Vector4;
  108952. backUVs?: Vector4;
  108953. }, scene: any): Mesh;
  108954. }
  108955. }
  108956. declare module BABYLON {
  108957. /**
  108958. * Polygon
  108959. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  108960. */
  108961. export class Polygon {
  108962. /**
  108963. * Creates a rectangle
  108964. * @param xmin bottom X coord
  108965. * @param ymin bottom Y coord
  108966. * @param xmax top X coord
  108967. * @param ymax top Y coord
  108968. * @returns points that make the resulting rectation
  108969. */
  108970. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  108971. /**
  108972. * Creates a circle
  108973. * @param radius radius of circle
  108974. * @param cx scale in x
  108975. * @param cy scale in y
  108976. * @param numberOfSides number of sides that make up the circle
  108977. * @returns points that make the resulting circle
  108978. */
  108979. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  108980. /**
  108981. * Creates a polygon from input string
  108982. * @param input Input polygon data
  108983. * @returns the parsed points
  108984. */
  108985. static Parse(input: string): Vector2[];
  108986. /**
  108987. * Starts building a polygon from x and y coordinates
  108988. * @param x x coordinate
  108989. * @param y y coordinate
  108990. * @returns the started path2
  108991. */
  108992. static StartingAt(x: number, y: number): Path2;
  108993. }
  108994. /**
  108995. * Builds a polygon
  108996. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  108997. */
  108998. export class PolygonMeshBuilder {
  108999. private _points;
  109000. private _outlinepoints;
  109001. private _holes;
  109002. private _name;
  109003. private _scene;
  109004. private _epoints;
  109005. private _eholes;
  109006. private _addToepoint;
  109007. /**
  109008. * Babylon reference to the earcut plugin.
  109009. */
  109010. bjsEarcut: any;
  109011. /**
  109012. * Creates a PolygonMeshBuilder
  109013. * @param name name of the builder
  109014. * @param contours Path of the polygon
  109015. * @param scene scene to add to when creating the mesh
  109016. * @param earcutInjection can be used to inject your own earcut reference
  109017. */
  109018. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  109019. /**
  109020. * Adds a whole within the polygon
  109021. * @param hole Array of points defining the hole
  109022. * @returns this
  109023. */
  109024. addHole(hole: Vector2[]): PolygonMeshBuilder;
  109025. /**
  109026. * Creates the polygon
  109027. * @param updatable If the mesh should be updatable
  109028. * @param depth The depth of the mesh created
  109029. * @returns the created mesh
  109030. */
  109031. build(updatable?: boolean, depth?: number): Mesh;
  109032. /**
  109033. * Creates the polygon
  109034. * @param depth The depth of the mesh created
  109035. * @returns the created VertexData
  109036. */
  109037. buildVertexData(depth?: number): VertexData;
  109038. /**
  109039. * Adds a side to the polygon
  109040. * @param positions points that make the polygon
  109041. * @param normals normals of the polygon
  109042. * @param uvs uvs of the polygon
  109043. * @param indices indices of the polygon
  109044. * @param bounds bounds of the polygon
  109045. * @param points points of the polygon
  109046. * @param depth depth of the polygon
  109047. * @param flip flip of the polygon
  109048. */
  109049. private addSide;
  109050. }
  109051. }
  109052. declare module BABYLON {
  109053. /**
  109054. * Class containing static functions to help procedurally build meshes
  109055. */
  109056. export class PolygonBuilder {
  109057. /**
  109058. * Creates a polygon mesh
  109059. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  109060. * * 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
  109061. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109063. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  109064. * * Remember you can only change the shape positions, not their number when updating a polygon
  109065. * @param name defines the name of the mesh
  109066. * @param options defines the options used to create the mesh
  109067. * @param scene defines the hosting scene
  109068. * @param earcutInjection can be used to inject your own earcut reference
  109069. * @returns the polygon mesh
  109070. */
  109071. static CreatePolygon(name: string, options: {
  109072. shape: Vector3[];
  109073. holes?: Vector3[][];
  109074. depth?: number;
  109075. faceUV?: Vector4[];
  109076. faceColors?: Color4[];
  109077. updatable?: boolean;
  109078. sideOrientation?: number;
  109079. frontUVs?: Vector4;
  109080. backUVs?: Vector4;
  109081. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109082. /**
  109083. * Creates an extruded polygon mesh, with depth in the Y direction.
  109084. * * 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)
  109085. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109086. * @param name defines the name of the mesh
  109087. * @param options defines the options used to create the mesh
  109088. * @param scene defines the hosting scene
  109089. * @param earcutInjection can be used to inject your own earcut reference
  109090. * @returns the polygon mesh
  109091. */
  109092. static ExtrudePolygon(name: string, options: {
  109093. shape: Vector3[];
  109094. holes?: Vector3[][];
  109095. depth?: number;
  109096. faceUV?: Vector4[];
  109097. faceColors?: Color4[];
  109098. updatable?: boolean;
  109099. sideOrientation?: number;
  109100. frontUVs?: Vector4;
  109101. backUVs?: Vector4;
  109102. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109103. }
  109104. }
  109105. declare module BABYLON {
  109106. /**
  109107. * Class containing static functions to help procedurally build meshes
  109108. */
  109109. export class LatheBuilder {
  109110. /**
  109111. * Creates lathe mesh.
  109112. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  109113. * * 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
  109114. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  109115. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  109116. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  109117. * * 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
  109118. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  109119. * * 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
  109120. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109121. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109122. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109124. * @param name defines the name of the mesh
  109125. * @param options defines the options used to create the mesh
  109126. * @param scene defines the hosting scene
  109127. * @returns the lathe mesh
  109128. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  109129. */
  109130. static CreateLathe(name: string, options: {
  109131. shape: Vector3[];
  109132. radius?: number;
  109133. tessellation?: number;
  109134. clip?: number;
  109135. arc?: number;
  109136. closed?: boolean;
  109137. updatable?: boolean;
  109138. sideOrientation?: number;
  109139. frontUVs?: Vector4;
  109140. backUVs?: Vector4;
  109141. cap?: number;
  109142. invertUV?: boolean;
  109143. }, scene?: Nullable<Scene>): Mesh;
  109144. }
  109145. }
  109146. declare module BABYLON {
  109147. /**
  109148. * Class containing static functions to help procedurally build meshes
  109149. */
  109150. export class TubeBuilder {
  109151. /**
  109152. * Creates a tube mesh.
  109153. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109154. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  109155. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  109156. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  109157. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  109158. * * 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)
  109159. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  109160. * * 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
  109161. * * 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
  109162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109163. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109164. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109166. * @param name defines the name of the mesh
  109167. * @param options defines the options used to create the mesh
  109168. * @param scene defines the hosting scene
  109169. * @returns the tube mesh
  109170. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109171. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  109172. */
  109173. static CreateTube(name: string, options: {
  109174. path: Vector3[];
  109175. radius?: number;
  109176. tessellation?: number;
  109177. radiusFunction?: {
  109178. (i: number, distance: number): number;
  109179. };
  109180. cap?: number;
  109181. arc?: number;
  109182. updatable?: boolean;
  109183. sideOrientation?: number;
  109184. frontUVs?: Vector4;
  109185. backUVs?: Vector4;
  109186. instance?: Mesh;
  109187. invertUV?: boolean;
  109188. }, scene?: Nullable<Scene>): Mesh;
  109189. }
  109190. }
  109191. declare module BABYLON {
  109192. /**
  109193. * Class containing static functions to help procedurally build meshes
  109194. */
  109195. export class IcoSphereBuilder {
  109196. /**
  109197. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109198. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109199. * * 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`)
  109200. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109201. * * 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
  109202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109203. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109205. * @param name defines the name of the mesh
  109206. * @param options defines the options used to create the mesh
  109207. * @param scene defines the hosting scene
  109208. * @returns the icosahedron mesh
  109209. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109210. */
  109211. static CreateIcoSphere(name: string, options: {
  109212. radius?: number;
  109213. radiusX?: number;
  109214. radiusY?: number;
  109215. radiusZ?: number;
  109216. flat?: boolean;
  109217. subdivisions?: number;
  109218. sideOrientation?: number;
  109219. frontUVs?: Vector4;
  109220. backUVs?: Vector4;
  109221. updatable?: boolean;
  109222. }, scene?: Nullable<Scene>): Mesh;
  109223. }
  109224. }
  109225. declare module BABYLON {
  109226. /**
  109227. * Class containing static functions to help procedurally build meshes
  109228. */
  109229. export class DecalBuilder {
  109230. /**
  109231. * Creates a decal mesh.
  109232. * 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
  109233. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  109234. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  109235. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  109236. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  109237. * @param name defines the name of the mesh
  109238. * @param sourceMesh defines the mesh where the decal must be applied
  109239. * @param options defines the options used to create the mesh
  109240. * @param scene defines the hosting scene
  109241. * @returns the decal mesh
  109242. * @see https://doc.babylonjs.com/how_to/decals
  109243. */
  109244. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  109245. position?: Vector3;
  109246. normal?: Vector3;
  109247. size?: Vector3;
  109248. angle?: number;
  109249. }): Mesh;
  109250. }
  109251. }
  109252. declare module BABYLON {
  109253. /**
  109254. * Class containing static functions to help procedurally build meshes
  109255. */
  109256. export class MeshBuilder {
  109257. /**
  109258. * Creates a box mesh
  109259. * * The parameter `size` sets the size (float) of each box side (default 1)
  109260. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  109261. * * 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)
  109262. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109263. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109264. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109266. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  109267. * @param name defines the name of the mesh
  109268. * @param options defines the options used to create the mesh
  109269. * @param scene defines the hosting scene
  109270. * @returns the box mesh
  109271. */
  109272. static CreateBox(name: string, options: {
  109273. size?: number;
  109274. width?: number;
  109275. height?: number;
  109276. depth?: number;
  109277. faceUV?: Vector4[];
  109278. faceColors?: Color4[];
  109279. sideOrientation?: number;
  109280. frontUVs?: Vector4;
  109281. backUVs?: Vector4;
  109282. updatable?: boolean;
  109283. }, scene?: Nullable<Scene>): Mesh;
  109284. /**
  109285. * Creates a sphere mesh
  109286. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  109287. * * 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`)
  109288. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  109289. * * 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
  109290. * * 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)
  109291. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109292. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109294. * @param name defines the name of the mesh
  109295. * @param options defines the options used to create the mesh
  109296. * @param scene defines the hosting scene
  109297. * @returns the sphere mesh
  109298. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  109299. */
  109300. static CreateSphere(name: string, options: {
  109301. segments?: number;
  109302. diameter?: number;
  109303. diameterX?: number;
  109304. diameterY?: number;
  109305. diameterZ?: number;
  109306. arc?: number;
  109307. slice?: number;
  109308. sideOrientation?: number;
  109309. frontUVs?: Vector4;
  109310. backUVs?: Vector4;
  109311. updatable?: boolean;
  109312. }, scene?: Nullable<Scene>): Mesh;
  109313. /**
  109314. * Creates a plane polygonal mesh. By default, this is a disc
  109315. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  109316. * * 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
  109317. * * 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
  109318. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109319. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109321. * @param name defines the name of the mesh
  109322. * @param options defines the options used to create the mesh
  109323. * @param scene defines the hosting scene
  109324. * @returns the plane polygonal mesh
  109325. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  109326. */
  109327. static CreateDisc(name: string, options: {
  109328. radius?: number;
  109329. tessellation?: number;
  109330. arc?: number;
  109331. updatable?: boolean;
  109332. sideOrientation?: number;
  109333. frontUVs?: Vector4;
  109334. backUVs?: Vector4;
  109335. }, scene?: Nullable<Scene>): Mesh;
  109336. /**
  109337. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109338. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109339. * * 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`)
  109340. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109341. * * 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
  109342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109343. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109345. * @param name defines the name of the mesh
  109346. * @param options defines the options used to create the mesh
  109347. * @param scene defines the hosting scene
  109348. * @returns the icosahedron mesh
  109349. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109350. */
  109351. static CreateIcoSphere(name: string, options: {
  109352. radius?: number;
  109353. radiusX?: number;
  109354. radiusY?: number;
  109355. radiusZ?: number;
  109356. flat?: boolean;
  109357. subdivisions?: number;
  109358. sideOrientation?: number;
  109359. frontUVs?: Vector4;
  109360. backUVs?: Vector4;
  109361. updatable?: boolean;
  109362. }, scene?: Nullable<Scene>): Mesh;
  109363. /**
  109364. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109365. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  109366. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  109367. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  109368. * * 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
  109369. * * 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
  109370. * * 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
  109371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109372. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109373. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109374. * * 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
  109375. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  109376. * * 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
  109377. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  109378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109379. * @param name defines the name of the mesh
  109380. * @param options defines the options used to create the mesh
  109381. * @param scene defines the hosting scene
  109382. * @returns the ribbon mesh
  109383. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  109384. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109385. */
  109386. static CreateRibbon(name: string, options: {
  109387. pathArray: Vector3[][];
  109388. closeArray?: boolean;
  109389. closePath?: boolean;
  109390. offset?: number;
  109391. updatable?: boolean;
  109392. sideOrientation?: number;
  109393. frontUVs?: Vector4;
  109394. backUVs?: Vector4;
  109395. instance?: Mesh;
  109396. invertUV?: boolean;
  109397. uvs?: Vector2[];
  109398. colors?: Color4[];
  109399. }, scene?: Nullable<Scene>): Mesh;
  109400. /**
  109401. * Creates a cylinder or a cone mesh
  109402. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  109403. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  109404. * * 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.
  109405. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  109406. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  109407. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  109408. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  109409. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  109410. * * 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).
  109411. * * 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
  109412. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  109413. * * 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
  109414. * * 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.
  109415. * * If `enclose` is false, a ring surface is one element.
  109416. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  109417. * * 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
  109418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109419. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109421. * @param name defines the name of the mesh
  109422. * @param options defines the options used to create the mesh
  109423. * @param scene defines the hosting scene
  109424. * @returns the cylinder mesh
  109425. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  109426. */
  109427. static CreateCylinder(name: string, options: {
  109428. height?: number;
  109429. diameterTop?: number;
  109430. diameterBottom?: number;
  109431. diameter?: number;
  109432. tessellation?: number;
  109433. subdivisions?: number;
  109434. arc?: number;
  109435. faceColors?: Color4[];
  109436. faceUV?: Vector4[];
  109437. updatable?: boolean;
  109438. hasRings?: boolean;
  109439. enclose?: boolean;
  109440. sideOrientation?: number;
  109441. frontUVs?: Vector4;
  109442. backUVs?: Vector4;
  109443. }, scene?: Nullable<Scene>): Mesh;
  109444. /**
  109445. * Creates a torus mesh
  109446. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  109447. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  109448. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  109449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109452. * @param name defines the name of the mesh
  109453. * @param options defines the options used to create the mesh
  109454. * @param scene defines the hosting scene
  109455. * @returns the torus mesh
  109456. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  109457. */
  109458. static CreateTorus(name: string, options: {
  109459. diameter?: number;
  109460. thickness?: number;
  109461. tessellation?: number;
  109462. updatable?: boolean;
  109463. sideOrientation?: number;
  109464. frontUVs?: Vector4;
  109465. backUVs?: Vector4;
  109466. }, scene?: Nullable<Scene>): Mesh;
  109467. /**
  109468. * Creates a torus knot mesh
  109469. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  109470. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  109471. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  109472. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  109473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109474. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109476. * @param name defines the name of the mesh
  109477. * @param options defines the options used to create the mesh
  109478. * @param scene defines the hosting scene
  109479. * @returns the torus knot mesh
  109480. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  109481. */
  109482. static CreateTorusKnot(name: string, options: {
  109483. radius?: number;
  109484. tube?: number;
  109485. radialSegments?: number;
  109486. tubularSegments?: number;
  109487. p?: number;
  109488. q?: number;
  109489. updatable?: boolean;
  109490. sideOrientation?: number;
  109491. frontUVs?: Vector4;
  109492. backUVs?: Vector4;
  109493. }, scene?: Nullable<Scene>): Mesh;
  109494. /**
  109495. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  109496. * * 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
  109497. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  109498. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  109499. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  109500. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  109501. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  109502. * * 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
  109503. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  109504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109505. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  109506. * @param name defines the name of the new line system
  109507. * @param options defines the options used to create the line system
  109508. * @param scene defines the hosting scene
  109509. * @returns a new line system mesh
  109510. */
  109511. static CreateLineSystem(name: string, options: {
  109512. lines: Vector3[][];
  109513. updatable?: boolean;
  109514. instance?: Nullable<LinesMesh>;
  109515. colors?: Nullable<Color4[][]>;
  109516. useVertexAlpha?: boolean;
  109517. }, scene: Nullable<Scene>): LinesMesh;
  109518. /**
  109519. * Creates a line mesh
  109520. * 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
  109521. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109522. * * The parameter `points` is an array successive Vector3
  109523. * * 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
  109524. * * The optional parameter `colors` is an array of successive Color4, one per line point
  109525. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  109526. * * When updating an instance, remember that only point positions can change, not the number of points
  109527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109528. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  109529. * @param name defines the name of the new line system
  109530. * @param options defines the options used to create the line system
  109531. * @param scene defines the hosting scene
  109532. * @returns a new line mesh
  109533. */
  109534. static CreateLines(name: string, options: {
  109535. points: Vector3[];
  109536. updatable?: boolean;
  109537. instance?: Nullable<LinesMesh>;
  109538. colors?: Color4[];
  109539. useVertexAlpha?: boolean;
  109540. }, scene?: Nullable<Scene>): LinesMesh;
  109541. /**
  109542. * Creates a dashed line mesh
  109543. * * 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
  109544. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109545. * * The parameter `points` is an array successive Vector3
  109546. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  109547. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  109548. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109549. * * 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
  109550. * * When updating an instance, remember that only point positions can change, not the number of points
  109551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109552. * @param name defines the name of the mesh
  109553. * @param options defines the options used to create the mesh
  109554. * @param scene defines the hosting scene
  109555. * @returns the dashed line mesh
  109556. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  109557. */
  109558. static CreateDashedLines(name: string, options: {
  109559. points: Vector3[];
  109560. dashSize?: number;
  109561. gapSize?: number;
  109562. dashNb?: number;
  109563. updatable?: boolean;
  109564. instance?: LinesMesh;
  109565. }, scene?: Nullable<Scene>): LinesMesh;
  109566. /**
  109567. * 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.
  109568. * * 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.
  109569. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  109570. * * 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.
  109571. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  109572. * * 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
  109573. * * 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
  109574. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  109575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109576. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109577. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  109578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109579. * @param name defines the name of the mesh
  109580. * @param options defines the options used to create the mesh
  109581. * @param scene defines the hosting scene
  109582. * @returns the extruded shape mesh
  109583. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109584. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109585. */
  109586. static ExtrudeShape(name: string, options: {
  109587. shape: Vector3[];
  109588. path: Vector3[];
  109589. scale?: number;
  109590. rotation?: number;
  109591. cap?: number;
  109592. updatable?: boolean;
  109593. sideOrientation?: number;
  109594. frontUVs?: Vector4;
  109595. backUVs?: Vector4;
  109596. instance?: Mesh;
  109597. invertUV?: boolean;
  109598. }, scene?: Nullable<Scene>): Mesh;
  109599. /**
  109600. * Creates an custom extruded shape mesh.
  109601. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  109602. * * 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.
  109603. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  109604. * * 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
  109605. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  109606. * * 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
  109607. * * It must returns a float value that will be the scale value applied to the shape on each path point
  109608. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  109609. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  109610. * * 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
  109611. * * 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
  109612. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  109613. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109614. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109615. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109617. * @param name defines the name of the mesh
  109618. * @param options defines the options used to create the mesh
  109619. * @param scene defines the hosting scene
  109620. * @returns the custom extruded shape mesh
  109621. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  109622. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109623. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109624. */
  109625. static ExtrudeShapeCustom(name: string, options: {
  109626. shape: Vector3[];
  109627. path: Vector3[];
  109628. scaleFunction?: any;
  109629. rotationFunction?: any;
  109630. ribbonCloseArray?: boolean;
  109631. ribbonClosePath?: boolean;
  109632. cap?: number;
  109633. updatable?: boolean;
  109634. sideOrientation?: number;
  109635. frontUVs?: Vector4;
  109636. backUVs?: Vector4;
  109637. instance?: Mesh;
  109638. invertUV?: boolean;
  109639. }, scene?: Nullable<Scene>): Mesh;
  109640. /**
  109641. * Creates lathe mesh.
  109642. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  109643. * * 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
  109644. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  109645. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  109646. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  109647. * * 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
  109648. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  109649. * * 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
  109650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109651. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109652. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109654. * @param name defines the name of the mesh
  109655. * @param options defines the options used to create the mesh
  109656. * @param scene defines the hosting scene
  109657. * @returns the lathe mesh
  109658. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  109659. */
  109660. static CreateLathe(name: string, options: {
  109661. shape: Vector3[];
  109662. radius?: number;
  109663. tessellation?: number;
  109664. clip?: number;
  109665. arc?: number;
  109666. closed?: boolean;
  109667. updatable?: boolean;
  109668. sideOrientation?: number;
  109669. frontUVs?: Vector4;
  109670. backUVs?: Vector4;
  109671. cap?: number;
  109672. invertUV?: boolean;
  109673. }, scene?: Nullable<Scene>): Mesh;
  109674. /**
  109675. * Creates a plane mesh
  109676. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  109677. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  109678. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  109679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109680. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109682. * @param name defines the name of the mesh
  109683. * @param options defines the options used to create the mesh
  109684. * @param scene defines the hosting scene
  109685. * @returns the plane mesh
  109686. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  109687. */
  109688. static CreatePlane(name: string, options: {
  109689. size?: number;
  109690. width?: number;
  109691. height?: number;
  109692. sideOrientation?: number;
  109693. frontUVs?: Vector4;
  109694. backUVs?: Vector4;
  109695. updatable?: boolean;
  109696. sourcePlane?: Plane;
  109697. }, scene?: Nullable<Scene>): Mesh;
  109698. /**
  109699. * Creates a ground mesh
  109700. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  109701. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  109702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109703. * @param name defines the name of the mesh
  109704. * @param options defines the options used to create the mesh
  109705. * @param scene defines the hosting scene
  109706. * @returns the ground mesh
  109707. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  109708. */
  109709. static CreateGround(name: string, options: {
  109710. width?: number;
  109711. height?: number;
  109712. subdivisions?: number;
  109713. subdivisionsX?: number;
  109714. subdivisionsY?: number;
  109715. updatable?: boolean;
  109716. }, scene?: Nullable<Scene>): Mesh;
  109717. /**
  109718. * Creates a tiled ground mesh
  109719. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  109720. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  109721. * * 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
  109722. * * 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
  109723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109724. * @param name defines the name of the mesh
  109725. * @param options defines the options used to create the mesh
  109726. * @param scene defines the hosting scene
  109727. * @returns the tiled ground mesh
  109728. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  109729. */
  109730. static CreateTiledGround(name: string, options: {
  109731. xmin: number;
  109732. zmin: number;
  109733. xmax: number;
  109734. zmax: number;
  109735. subdivisions?: {
  109736. w: number;
  109737. h: number;
  109738. };
  109739. precision?: {
  109740. w: number;
  109741. h: number;
  109742. };
  109743. updatable?: boolean;
  109744. }, scene?: Nullable<Scene>): Mesh;
  109745. /**
  109746. * Creates a ground mesh from a height map
  109747. * * The parameter `url` sets the URL of the height map image resource.
  109748. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  109749. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  109750. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  109751. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  109752. * * 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.
  109753. * * 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).
  109754. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109756. * @param name defines the name of the mesh
  109757. * @param url defines the url to the height map
  109758. * @param options defines the options used to create the mesh
  109759. * @param scene defines the hosting scene
  109760. * @returns the ground mesh
  109761. * @see https://doc.babylonjs.com/babylon101/height_map
  109762. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  109763. */
  109764. static CreateGroundFromHeightMap(name: string, url: string, options: {
  109765. width?: number;
  109766. height?: number;
  109767. subdivisions?: number;
  109768. minHeight?: number;
  109769. maxHeight?: number;
  109770. colorFilter?: Color3;
  109771. alphaFilter?: number;
  109772. updatable?: boolean;
  109773. onReady?: (mesh: GroundMesh) => void;
  109774. }, scene?: Nullable<Scene>): GroundMesh;
  109775. /**
  109776. * Creates a polygon mesh
  109777. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  109778. * * 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
  109779. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109781. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  109782. * * Remember you can only change the shape positions, not their number when updating a polygon
  109783. * @param name defines the name of the mesh
  109784. * @param options defines the options used to create the mesh
  109785. * @param scene defines the hosting scene
  109786. * @param earcutInjection can be used to inject your own earcut reference
  109787. * @returns the polygon mesh
  109788. */
  109789. static CreatePolygon(name: string, options: {
  109790. shape: Vector3[];
  109791. holes?: Vector3[][];
  109792. depth?: number;
  109793. faceUV?: Vector4[];
  109794. faceColors?: Color4[];
  109795. updatable?: boolean;
  109796. sideOrientation?: number;
  109797. frontUVs?: Vector4;
  109798. backUVs?: Vector4;
  109799. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109800. /**
  109801. * Creates an extruded polygon mesh, with depth in the Y direction.
  109802. * * 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)
  109803. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109804. * @param name defines the name of the mesh
  109805. * @param options defines the options used to create the mesh
  109806. * @param scene defines the hosting scene
  109807. * @param earcutInjection can be used to inject your own earcut reference
  109808. * @returns the polygon mesh
  109809. */
  109810. static ExtrudePolygon(name: string, options: {
  109811. shape: Vector3[];
  109812. holes?: Vector3[][];
  109813. depth?: number;
  109814. faceUV?: Vector4[];
  109815. faceColors?: Color4[];
  109816. updatable?: boolean;
  109817. sideOrientation?: number;
  109818. frontUVs?: Vector4;
  109819. backUVs?: Vector4;
  109820. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109821. /**
  109822. * Creates a tube mesh.
  109823. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109824. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  109825. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  109826. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  109827. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  109828. * * 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)
  109829. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  109830. * * 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
  109831. * * 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
  109832. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109833. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109834. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109836. * @param name defines the name of the mesh
  109837. * @param options defines the options used to create the mesh
  109838. * @param scene defines the hosting scene
  109839. * @returns the tube mesh
  109840. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109841. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  109842. */
  109843. static CreateTube(name: string, options: {
  109844. path: Vector3[];
  109845. radius?: number;
  109846. tessellation?: number;
  109847. radiusFunction?: {
  109848. (i: number, distance: number): number;
  109849. };
  109850. cap?: number;
  109851. arc?: number;
  109852. updatable?: boolean;
  109853. sideOrientation?: number;
  109854. frontUVs?: Vector4;
  109855. backUVs?: Vector4;
  109856. instance?: Mesh;
  109857. invertUV?: boolean;
  109858. }, scene?: Nullable<Scene>): Mesh;
  109859. /**
  109860. * Creates a polyhedron mesh
  109861. * * 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
  109862. * * The parameter `size` (positive float, default 1) sets the polygon size
  109863. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  109864. * * 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`
  109865. * * 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
  109866. * * 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)`)
  109867. * * 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
  109868. * * 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
  109869. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109870. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109872. * @param name defines the name of the mesh
  109873. * @param options defines the options used to create the mesh
  109874. * @param scene defines the hosting scene
  109875. * @returns the polyhedron mesh
  109876. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  109877. */
  109878. static CreatePolyhedron(name: string, options: {
  109879. type?: number;
  109880. size?: number;
  109881. sizeX?: number;
  109882. sizeY?: number;
  109883. sizeZ?: number;
  109884. custom?: any;
  109885. faceUV?: Vector4[];
  109886. faceColors?: Color4[];
  109887. flat?: boolean;
  109888. updatable?: boolean;
  109889. sideOrientation?: number;
  109890. frontUVs?: Vector4;
  109891. backUVs?: Vector4;
  109892. }, scene?: Nullable<Scene>): Mesh;
  109893. /**
  109894. * Creates a decal mesh.
  109895. * 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
  109896. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  109897. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  109898. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  109899. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  109900. * @param name defines the name of the mesh
  109901. * @param sourceMesh defines the mesh where the decal must be applied
  109902. * @param options defines the options used to create the mesh
  109903. * @param scene defines the hosting scene
  109904. * @returns the decal mesh
  109905. * @see https://doc.babylonjs.com/how_to/decals
  109906. */
  109907. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  109908. position?: Vector3;
  109909. normal?: Vector3;
  109910. size?: Vector3;
  109911. angle?: number;
  109912. }): Mesh;
  109913. }
  109914. }
  109915. declare module BABYLON {
  109916. /**
  109917. * A simplifier interface for future simplification implementations
  109918. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109919. */
  109920. export interface ISimplifier {
  109921. /**
  109922. * Simplification of a given mesh according to the given settings.
  109923. * Since this requires computation, it is assumed that the function runs async.
  109924. * @param settings The settings of the simplification, including quality and distance
  109925. * @param successCallback A callback that will be called after the mesh was simplified.
  109926. * @param errorCallback in case of an error, this callback will be called. optional.
  109927. */
  109928. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  109929. }
  109930. /**
  109931. * Expected simplification settings.
  109932. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  109933. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109934. */
  109935. export interface ISimplificationSettings {
  109936. /**
  109937. * Gets or sets the expected quality
  109938. */
  109939. quality: number;
  109940. /**
  109941. * Gets or sets the distance when this optimized version should be used
  109942. */
  109943. distance: number;
  109944. /**
  109945. * Gets an already optimized mesh
  109946. */
  109947. optimizeMesh?: boolean;
  109948. }
  109949. /**
  109950. * Class used to specify simplification options
  109951. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109952. */
  109953. export class SimplificationSettings implements ISimplificationSettings {
  109954. /** expected quality */
  109955. quality: number;
  109956. /** distance when this optimized version should be used */
  109957. distance: number;
  109958. /** already optimized mesh */
  109959. optimizeMesh?: boolean | undefined;
  109960. /**
  109961. * Creates a SimplificationSettings
  109962. * @param quality expected quality
  109963. * @param distance distance when this optimized version should be used
  109964. * @param optimizeMesh already optimized mesh
  109965. */
  109966. constructor(
  109967. /** expected quality */
  109968. quality: number,
  109969. /** distance when this optimized version should be used */
  109970. distance: number,
  109971. /** already optimized mesh */
  109972. optimizeMesh?: boolean | undefined);
  109973. }
  109974. /**
  109975. * Interface used to define a simplification task
  109976. */
  109977. export interface ISimplificationTask {
  109978. /**
  109979. * Array of settings
  109980. */
  109981. settings: Array<ISimplificationSettings>;
  109982. /**
  109983. * Simplification type
  109984. */
  109985. simplificationType: SimplificationType;
  109986. /**
  109987. * Mesh to simplify
  109988. */
  109989. mesh: Mesh;
  109990. /**
  109991. * Callback called on success
  109992. */
  109993. successCallback?: () => void;
  109994. /**
  109995. * Defines if parallel processing can be used
  109996. */
  109997. parallelProcessing: boolean;
  109998. }
  109999. /**
  110000. * Queue used to order the simplification tasks
  110001. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110002. */
  110003. export class SimplificationQueue {
  110004. private _simplificationArray;
  110005. /**
  110006. * Gets a boolean indicating that the process is still running
  110007. */
  110008. running: boolean;
  110009. /**
  110010. * Creates a new queue
  110011. */
  110012. constructor();
  110013. /**
  110014. * Adds a new simplification task
  110015. * @param task defines a task to add
  110016. */
  110017. addTask(task: ISimplificationTask): void;
  110018. /**
  110019. * Execute next task
  110020. */
  110021. executeNext(): void;
  110022. /**
  110023. * Execute a simplification task
  110024. * @param task defines the task to run
  110025. */
  110026. runSimplification(task: ISimplificationTask): void;
  110027. private getSimplifier;
  110028. }
  110029. /**
  110030. * The implemented types of simplification
  110031. * At the moment only Quadratic Error Decimation is implemented
  110032. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110033. */
  110034. export enum SimplificationType {
  110035. /** Quadratic error decimation */
  110036. QUADRATIC = 0
  110037. }
  110038. }
  110039. declare module BABYLON {
  110040. interface Scene {
  110041. /** @hidden (Backing field) */
  110042. _simplificationQueue: SimplificationQueue;
  110043. /**
  110044. * Gets or sets the simplification queue attached to the scene
  110045. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110046. */
  110047. simplificationQueue: SimplificationQueue;
  110048. }
  110049. interface Mesh {
  110050. /**
  110051. * Simplify the mesh according to the given array of settings.
  110052. * Function will return immediately and will simplify async
  110053. * @param settings a collection of simplification settings
  110054. * @param parallelProcessing should all levels calculate parallel or one after the other
  110055. * @param simplificationType the type of simplification to run
  110056. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  110057. * @returns the current mesh
  110058. */
  110059. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  110060. }
  110061. /**
  110062. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  110063. * created in a scene
  110064. */
  110065. export class SimplicationQueueSceneComponent implements ISceneComponent {
  110066. /**
  110067. * The component name helpfull to identify the component in the list of scene components.
  110068. */
  110069. readonly name: string;
  110070. /**
  110071. * The scene the component belongs to.
  110072. */
  110073. scene: Scene;
  110074. /**
  110075. * Creates a new instance of the component for the given scene
  110076. * @param scene Defines the scene to register the component in
  110077. */
  110078. constructor(scene: Scene);
  110079. /**
  110080. * Registers the component in a given scene
  110081. */
  110082. register(): void;
  110083. /**
  110084. * Rebuilds the elements related to this component in case of
  110085. * context lost for instance.
  110086. */
  110087. rebuild(): void;
  110088. /**
  110089. * Disposes the component and the associated ressources
  110090. */
  110091. dispose(): void;
  110092. private _beforeCameraUpdate;
  110093. }
  110094. }
  110095. declare module BABYLON {
  110096. /**
  110097. * Class used to enable access to IndexedDB
  110098. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  110099. */
  110100. export class Database implements IOfflineProvider {
  110101. private _callbackManifestChecked;
  110102. private _currentSceneUrl;
  110103. private _db;
  110104. private _enableSceneOffline;
  110105. private _enableTexturesOffline;
  110106. private _manifestVersionFound;
  110107. private _mustUpdateRessources;
  110108. private _hasReachedQuota;
  110109. private _isSupported;
  110110. private _idbFactory;
  110111. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  110112. private static IsUASupportingBlobStorage;
  110113. /**
  110114. * Gets a boolean indicating if Database storate is enabled (off by default)
  110115. */
  110116. static IDBStorageEnabled: boolean;
  110117. /**
  110118. * Gets a boolean indicating if scene must be saved in the database
  110119. */
  110120. readonly enableSceneOffline: boolean;
  110121. /**
  110122. * Gets a boolean indicating if textures must be saved in the database
  110123. */
  110124. readonly enableTexturesOffline: boolean;
  110125. /**
  110126. * Creates a new Database
  110127. * @param urlToScene defines the url to load the scene
  110128. * @param callbackManifestChecked defines the callback to use when manifest is checked
  110129. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  110130. */
  110131. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  110132. private static _ParseURL;
  110133. private static _ReturnFullUrlLocation;
  110134. private _checkManifestFile;
  110135. /**
  110136. * Open the database and make it available
  110137. * @param successCallback defines the callback to call on success
  110138. * @param errorCallback defines the callback to call on error
  110139. */
  110140. open(successCallback: () => void, errorCallback: () => void): void;
  110141. /**
  110142. * Loads an image from the database
  110143. * @param url defines the url to load from
  110144. * @param image defines the target DOM image
  110145. */
  110146. loadImage(url: string, image: HTMLImageElement): void;
  110147. private _loadImageFromDBAsync;
  110148. private _saveImageIntoDBAsync;
  110149. private _checkVersionFromDB;
  110150. private _loadVersionFromDBAsync;
  110151. private _saveVersionIntoDBAsync;
  110152. /**
  110153. * Loads a file from database
  110154. * @param url defines the URL to load from
  110155. * @param sceneLoaded defines a callback to call on success
  110156. * @param progressCallBack defines a callback to call when progress changed
  110157. * @param errorCallback defines a callback to call on error
  110158. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  110159. */
  110160. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  110161. private _loadFileAsync;
  110162. private _saveFileAsync;
  110163. /**
  110164. * Validates if xhr data is correct
  110165. * @param xhr defines the request to validate
  110166. * @param dataType defines the expected data type
  110167. * @returns true if data is correct
  110168. */
  110169. private static _ValidateXHRData;
  110170. }
  110171. }
  110172. declare module BABYLON {
  110173. /** @hidden */
  110174. export var gpuUpdateParticlesPixelShader: {
  110175. name: string;
  110176. shader: string;
  110177. };
  110178. }
  110179. declare module BABYLON {
  110180. /** @hidden */
  110181. export var gpuUpdateParticlesVertexShader: {
  110182. name: string;
  110183. shader: string;
  110184. };
  110185. }
  110186. declare module BABYLON {
  110187. /** @hidden */
  110188. export var clipPlaneFragmentDeclaration2: {
  110189. name: string;
  110190. shader: string;
  110191. };
  110192. }
  110193. declare module BABYLON {
  110194. /** @hidden */
  110195. export var gpuRenderParticlesPixelShader: {
  110196. name: string;
  110197. shader: string;
  110198. };
  110199. }
  110200. declare module BABYLON {
  110201. /** @hidden */
  110202. export var clipPlaneVertexDeclaration2: {
  110203. name: string;
  110204. shader: string;
  110205. };
  110206. }
  110207. declare module BABYLON {
  110208. /** @hidden */
  110209. export var gpuRenderParticlesVertexShader: {
  110210. name: string;
  110211. shader: string;
  110212. };
  110213. }
  110214. declare module BABYLON {
  110215. /**
  110216. * This represents a GPU particle system in Babylon
  110217. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  110218. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  110219. */
  110220. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  110221. /**
  110222. * The layer mask we are rendering the particles through.
  110223. */
  110224. layerMask: number;
  110225. private _capacity;
  110226. private _activeCount;
  110227. private _currentActiveCount;
  110228. private _accumulatedCount;
  110229. private _renderEffect;
  110230. private _updateEffect;
  110231. private _buffer0;
  110232. private _buffer1;
  110233. private _spriteBuffer;
  110234. private _updateVAO;
  110235. private _renderVAO;
  110236. private _targetIndex;
  110237. private _sourceBuffer;
  110238. private _targetBuffer;
  110239. private _engine;
  110240. private _currentRenderId;
  110241. private _started;
  110242. private _stopped;
  110243. private _timeDelta;
  110244. private _randomTexture;
  110245. private _randomTexture2;
  110246. private _attributesStrideSize;
  110247. private _updateEffectOptions;
  110248. private _randomTextureSize;
  110249. private _actualFrame;
  110250. private readonly _rawTextureWidth;
  110251. /**
  110252. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  110253. */
  110254. static readonly IsSupported: boolean;
  110255. /**
  110256. * An event triggered when the system is disposed.
  110257. */
  110258. onDisposeObservable: Observable<GPUParticleSystem>;
  110259. /**
  110260. * Gets the maximum number of particles active at the same time.
  110261. * @returns The max number of active particles.
  110262. */
  110263. getCapacity(): number;
  110264. /**
  110265. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  110266. * to override the particles.
  110267. */
  110268. forceDepthWrite: boolean;
  110269. /**
  110270. * Gets or set the number of active particles
  110271. */
  110272. activeParticleCount: number;
  110273. private _preWarmDone;
  110274. /**
  110275. * Is this system ready to be used/rendered
  110276. * @return true if the system is ready
  110277. */
  110278. isReady(): boolean;
  110279. /**
  110280. * Gets if the system has been started. (Note: this will still be true after stop is called)
  110281. * @returns True if it has been started, otherwise false.
  110282. */
  110283. isStarted(): boolean;
  110284. /**
  110285. * Starts the particle system and begins to emit
  110286. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  110287. */
  110288. start(delay?: number): void;
  110289. /**
  110290. * Stops the particle system.
  110291. */
  110292. stop(): void;
  110293. /**
  110294. * Remove all active particles
  110295. */
  110296. reset(): void;
  110297. /**
  110298. * Returns the string "GPUParticleSystem"
  110299. * @returns a string containing the class name
  110300. */
  110301. getClassName(): string;
  110302. private _colorGradientsTexture;
  110303. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  110304. /**
  110305. * Adds a new color gradient
  110306. * @param gradient defines the gradient to use (between 0 and 1)
  110307. * @param color1 defines the color to affect to the specified gradient
  110308. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  110309. * @returns the current particle system
  110310. */
  110311. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  110312. /**
  110313. * Remove a specific color gradient
  110314. * @param gradient defines the gradient to remove
  110315. * @returns the current particle system
  110316. */
  110317. removeColorGradient(gradient: number): GPUParticleSystem;
  110318. private _angularSpeedGradientsTexture;
  110319. private _sizeGradientsTexture;
  110320. private _velocityGradientsTexture;
  110321. private _limitVelocityGradientsTexture;
  110322. private _dragGradientsTexture;
  110323. private _addFactorGradient;
  110324. /**
  110325. * Adds a new size gradient
  110326. * @param gradient defines the gradient to use (between 0 and 1)
  110327. * @param factor defines the size factor to affect to the specified gradient
  110328. * @returns the current particle system
  110329. */
  110330. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  110331. /**
  110332. * Remove a specific size gradient
  110333. * @param gradient defines the gradient to remove
  110334. * @returns the current particle system
  110335. */
  110336. removeSizeGradient(gradient: number): GPUParticleSystem;
  110337. /**
  110338. * Adds a new angular speed gradient
  110339. * @param gradient defines the gradient to use (between 0 and 1)
  110340. * @param factor defines the angular speed to affect to the specified gradient
  110341. * @returns the current particle system
  110342. */
  110343. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  110344. /**
  110345. * Remove a specific angular speed gradient
  110346. * @param gradient defines the gradient to remove
  110347. * @returns the current particle system
  110348. */
  110349. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  110350. /**
  110351. * Adds a new velocity gradient
  110352. * @param gradient defines the gradient to use (between 0 and 1)
  110353. * @param factor defines the velocity to affect to the specified gradient
  110354. * @returns the current particle system
  110355. */
  110356. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  110357. /**
  110358. * Remove a specific velocity gradient
  110359. * @param gradient defines the gradient to remove
  110360. * @returns the current particle system
  110361. */
  110362. removeVelocityGradient(gradient: number): GPUParticleSystem;
  110363. /**
  110364. * Adds a new limit velocity gradient
  110365. * @param gradient defines the gradient to use (between 0 and 1)
  110366. * @param factor defines the limit velocity value to affect to the specified gradient
  110367. * @returns the current particle system
  110368. */
  110369. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  110370. /**
  110371. * Remove a specific limit velocity gradient
  110372. * @param gradient defines the gradient to remove
  110373. * @returns the current particle system
  110374. */
  110375. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  110376. /**
  110377. * Adds a new drag gradient
  110378. * @param gradient defines the gradient to use (between 0 and 1)
  110379. * @param factor defines the drag value to affect to the specified gradient
  110380. * @returns the current particle system
  110381. */
  110382. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  110383. /**
  110384. * Remove a specific drag gradient
  110385. * @param gradient defines the gradient to remove
  110386. * @returns the current particle system
  110387. */
  110388. removeDragGradient(gradient: number): GPUParticleSystem;
  110389. /**
  110390. * Not supported by GPUParticleSystem
  110391. * @param gradient defines the gradient to use (between 0 and 1)
  110392. * @param factor defines the emit rate value to affect to the specified gradient
  110393. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110394. * @returns the current particle system
  110395. */
  110396. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110397. /**
  110398. * Not supported by GPUParticleSystem
  110399. * @param gradient defines the gradient to remove
  110400. * @returns the current particle system
  110401. */
  110402. removeEmitRateGradient(gradient: number): IParticleSystem;
  110403. /**
  110404. * Not supported by GPUParticleSystem
  110405. * @param gradient defines the gradient to use (between 0 and 1)
  110406. * @param factor defines the start size value to affect to the specified gradient
  110407. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110408. * @returns the current particle system
  110409. */
  110410. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110411. /**
  110412. * Not supported by GPUParticleSystem
  110413. * @param gradient defines the gradient to remove
  110414. * @returns the current particle system
  110415. */
  110416. removeStartSizeGradient(gradient: number): IParticleSystem;
  110417. /**
  110418. * Not supported by GPUParticleSystem
  110419. * @param gradient defines the gradient to use (between 0 and 1)
  110420. * @param min defines the color remap minimal range
  110421. * @param max defines the color remap maximal range
  110422. * @returns the current particle system
  110423. */
  110424. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  110425. /**
  110426. * Not supported by GPUParticleSystem
  110427. * @param gradient defines the gradient to remove
  110428. * @returns the current particle system
  110429. */
  110430. removeColorRemapGradient(): IParticleSystem;
  110431. /**
  110432. * Not supported by GPUParticleSystem
  110433. * @param gradient defines the gradient to use (between 0 and 1)
  110434. * @param min defines the alpha remap minimal range
  110435. * @param max defines the alpha remap maximal range
  110436. * @returns the current particle system
  110437. */
  110438. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  110439. /**
  110440. * Not supported by GPUParticleSystem
  110441. * @param gradient defines the gradient to remove
  110442. * @returns the current particle system
  110443. */
  110444. removeAlphaRemapGradient(): IParticleSystem;
  110445. /**
  110446. * Not supported by GPUParticleSystem
  110447. * @param gradient defines the gradient to use (between 0 and 1)
  110448. * @param color defines the color to affect to the specified gradient
  110449. * @returns the current particle system
  110450. */
  110451. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  110452. /**
  110453. * Not supported by GPUParticleSystem
  110454. * @param gradient defines the gradient to remove
  110455. * @returns the current particle system
  110456. */
  110457. removeRampGradient(): IParticleSystem;
  110458. /**
  110459. * Not supported by GPUParticleSystem
  110460. * @returns the list of ramp gradients
  110461. */
  110462. getRampGradients(): Nullable<Array<Color3Gradient>>;
  110463. /**
  110464. * Not supported by GPUParticleSystem
  110465. * Gets or sets a boolean indicating that ramp gradients must be used
  110466. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  110467. */
  110468. useRampGradients: boolean;
  110469. /**
  110470. * Not supported by GPUParticleSystem
  110471. * @param gradient defines the gradient to use (between 0 and 1)
  110472. * @param factor defines the life time factor to affect to the specified gradient
  110473. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110474. * @returns the current particle system
  110475. */
  110476. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110477. /**
  110478. * Not supported by GPUParticleSystem
  110479. * @param gradient defines the gradient to remove
  110480. * @returns the current particle system
  110481. */
  110482. removeLifeTimeGradient(gradient: number): IParticleSystem;
  110483. /**
  110484. * Instantiates a GPU particle system.
  110485. * 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.
  110486. * @param name The name of the particle system
  110487. * @param options The options used to create the system
  110488. * @param scene The scene the particle system belongs to
  110489. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  110490. */
  110491. constructor(name: string, options: Partial<{
  110492. capacity: number;
  110493. randomTextureSize: number;
  110494. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  110495. protected _reset(): void;
  110496. private _createUpdateVAO;
  110497. private _createRenderVAO;
  110498. private _initialize;
  110499. /** @hidden */
  110500. _recreateUpdateEffect(): void;
  110501. /** @hidden */
  110502. _recreateRenderEffect(): void;
  110503. /**
  110504. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  110505. * @param preWarm defines if we are in the pre-warmimg phase
  110506. */
  110507. animate(preWarm?: boolean): void;
  110508. private _createFactorGradientTexture;
  110509. private _createSizeGradientTexture;
  110510. private _createAngularSpeedGradientTexture;
  110511. private _createVelocityGradientTexture;
  110512. private _createLimitVelocityGradientTexture;
  110513. private _createDragGradientTexture;
  110514. private _createColorGradientTexture;
  110515. /**
  110516. * Renders the particle system in its current state
  110517. * @param preWarm defines if the system should only update the particles but not render them
  110518. * @returns the current number of particles
  110519. */
  110520. render(preWarm?: boolean): number;
  110521. /**
  110522. * Rebuilds the particle system
  110523. */
  110524. rebuild(): void;
  110525. private _releaseBuffers;
  110526. private _releaseVAOs;
  110527. /**
  110528. * Disposes the particle system and free the associated resources
  110529. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  110530. */
  110531. dispose(disposeTexture?: boolean): void;
  110532. /**
  110533. * Clones the particle system.
  110534. * @param name The name of the cloned object
  110535. * @param newEmitter The new emitter to use
  110536. * @returns the cloned particle system
  110537. */
  110538. clone(name: string, newEmitter: any): GPUParticleSystem;
  110539. /**
  110540. * Serializes the particle system to a JSON object.
  110541. * @returns the JSON object
  110542. */
  110543. serialize(): any;
  110544. /**
  110545. * Parses a JSON object to create a GPU particle system.
  110546. * @param parsedParticleSystem The JSON object to parse
  110547. * @param scene The scene to create the particle system in
  110548. * @param rootUrl The root url to use to load external dependencies like texture
  110549. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  110550. * @returns the parsed GPU particle system
  110551. */
  110552. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  110553. }
  110554. }
  110555. declare module BABYLON {
  110556. /**
  110557. * Represents a set of particle systems working together to create a specific effect
  110558. */
  110559. export class ParticleSystemSet implements IDisposable {
  110560. private _emitterCreationOptions;
  110561. private _emitterNode;
  110562. /**
  110563. * Gets the particle system list
  110564. */
  110565. systems: IParticleSystem[];
  110566. /**
  110567. * Gets the emitter node used with this set
  110568. */
  110569. readonly emitterNode: Nullable<TransformNode>;
  110570. /**
  110571. * Creates a new emitter mesh as a sphere
  110572. * @param options defines the options used to create the sphere
  110573. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  110574. * @param scene defines the hosting scene
  110575. */
  110576. setEmitterAsSphere(options: {
  110577. diameter: number;
  110578. segments: number;
  110579. color: Color3;
  110580. }, renderingGroupId: number, scene: Scene): void;
  110581. /**
  110582. * Starts all particle systems of the set
  110583. * @param emitter defines an optional mesh to use as emitter for the particle systems
  110584. */
  110585. start(emitter?: AbstractMesh): void;
  110586. /**
  110587. * Release all associated resources
  110588. */
  110589. dispose(): void;
  110590. /**
  110591. * Serialize the set into a JSON compatible object
  110592. * @returns a JSON compatible representation of the set
  110593. */
  110594. serialize(): any;
  110595. /**
  110596. * Parse a new ParticleSystemSet from a serialized source
  110597. * @param data defines a JSON compatible representation of the set
  110598. * @param scene defines the hosting scene
  110599. * @param gpu defines if we want GPU particles or CPU particles
  110600. * @returns a new ParticleSystemSet
  110601. */
  110602. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  110603. }
  110604. }
  110605. declare module BABYLON {
  110606. /**
  110607. * This class is made for on one-liner static method to help creating particle system set.
  110608. */
  110609. export class ParticleHelper {
  110610. /**
  110611. * Gets or sets base Assets URL
  110612. */
  110613. static BaseAssetsUrl: string;
  110614. /**
  110615. * Create a default particle system that you can tweak
  110616. * @param emitter defines the emitter to use
  110617. * @param capacity defines the system capacity (default is 500 particles)
  110618. * @param scene defines the hosting scene
  110619. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  110620. * @returns the new Particle system
  110621. */
  110622. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  110623. /**
  110624. * This is the main static method (one-liner) of this helper to create different particle systems
  110625. * @param type This string represents the type to the particle system to create
  110626. * @param scene The scene where the particle system should live
  110627. * @param gpu If the system will use gpu
  110628. * @returns the ParticleSystemSet created
  110629. */
  110630. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  110631. /**
  110632. * Static function used to export a particle system to a ParticleSystemSet variable.
  110633. * Please note that the emitter shape is not exported
  110634. * @param systems defines the particle systems to export
  110635. * @returns the created particle system set
  110636. */
  110637. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  110638. }
  110639. }
  110640. declare module BABYLON {
  110641. interface Engine {
  110642. /**
  110643. * Create an effect to use with particle systems.
  110644. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  110645. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  110646. * @param uniformsNames defines a list of attribute names
  110647. * @param samplers defines an array of string used to represent textures
  110648. * @param defines defines the string containing the defines to use to compile the shaders
  110649. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  110650. * @param onCompiled defines a function to call when the effect creation is successful
  110651. * @param onError defines a function to call when the effect creation has failed
  110652. * @returns the new Effect
  110653. */
  110654. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  110655. }
  110656. interface Mesh {
  110657. /**
  110658. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  110659. * @returns an array of IParticleSystem
  110660. */
  110661. getEmittedParticleSystems(): IParticleSystem[];
  110662. /**
  110663. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  110664. * @returns an array of IParticleSystem
  110665. */
  110666. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  110667. }
  110668. /**
  110669. * @hidden
  110670. */
  110671. export var _IDoNeedToBeInTheBuild: number;
  110672. }
  110673. declare module BABYLON {
  110674. interface Scene {
  110675. /** @hidden (Backing field) */
  110676. _physicsEngine: Nullable<IPhysicsEngine>;
  110677. /**
  110678. * Gets the current physics engine
  110679. * @returns a IPhysicsEngine or null if none attached
  110680. */
  110681. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  110682. /**
  110683. * Enables physics to the current scene
  110684. * @param gravity defines the scene's gravity for the physics engine
  110685. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  110686. * @return a boolean indicating if the physics engine was initialized
  110687. */
  110688. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  110689. /**
  110690. * Disables and disposes the physics engine associated with the scene
  110691. */
  110692. disablePhysicsEngine(): void;
  110693. /**
  110694. * Gets a boolean indicating if there is an active physics engine
  110695. * @returns a boolean indicating if there is an active physics engine
  110696. */
  110697. isPhysicsEnabled(): boolean;
  110698. /**
  110699. * Deletes a physics compound impostor
  110700. * @param compound defines the compound to delete
  110701. */
  110702. deleteCompoundImpostor(compound: any): void;
  110703. /**
  110704. * An event triggered when physic simulation is about to be run
  110705. */
  110706. onBeforePhysicsObservable: Observable<Scene>;
  110707. /**
  110708. * An event triggered when physic simulation has been done
  110709. */
  110710. onAfterPhysicsObservable: Observable<Scene>;
  110711. }
  110712. interface AbstractMesh {
  110713. /** @hidden */
  110714. _physicsImpostor: Nullable<PhysicsImpostor>;
  110715. /**
  110716. * Gets or sets impostor used for physic simulation
  110717. * @see http://doc.babylonjs.com/features/physics_engine
  110718. */
  110719. physicsImpostor: Nullable<PhysicsImpostor>;
  110720. /**
  110721. * Gets the current physics impostor
  110722. * @see http://doc.babylonjs.com/features/physics_engine
  110723. * @returns a physics impostor or null
  110724. */
  110725. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  110726. /** Apply a physic impulse to the mesh
  110727. * @param force defines the force to apply
  110728. * @param contactPoint defines where to apply the force
  110729. * @returns the current mesh
  110730. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  110731. */
  110732. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  110733. /**
  110734. * Creates a physic joint between two meshes
  110735. * @param otherMesh defines the other mesh to use
  110736. * @param pivot1 defines the pivot to use on this mesh
  110737. * @param pivot2 defines the pivot to use on the other mesh
  110738. * @param options defines additional options (can be plugin dependent)
  110739. * @returns the current mesh
  110740. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  110741. */
  110742. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  110743. /** @hidden */
  110744. _disposePhysicsObserver: Nullable<Observer<Node>>;
  110745. }
  110746. /**
  110747. * Defines the physics engine scene component responsible to manage a physics engine
  110748. */
  110749. export class PhysicsEngineSceneComponent implements ISceneComponent {
  110750. /**
  110751. * The component name helpful to identify the component in the list of scene components.
  110752. */
  110753. readonly name: string;
  110754. /**
  110755. * The scene the component belongs to.
  110756. */
  110757. scene: Scene;
  110758. /**
  110759. * Creates a new instance of the component for the given scene
  110760. * @param scene Defines the scene to register the component in
  110761. */
  110762. constructor(scene: Scene);
  110763. /**
  110764. * Registers the component in a given scene
  110765. */
  110766. register(): void;
  110767. /**
  110768. * Rebuilds the elements related to this component in case of
  110769. * context lost for instance.
  110770. */
  110771. rebuild(): void;
  110772. /**
  110773. * Disposes the component and the associated ressources
  110774. */
  110775. dispose(): void;
  110776. }
  110777. }
  110778. declare module BABYLON {
  110779. /**
  110780. * A helper for physics simulations
  110781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110782. */
  110783. export class PhysicsHelper {
  110784. private _scene;
  110785. private _physicsEngine;
  110786. /**
  110787. * Initializes the Physics helper
  110788. * @param scene Babylon.js scene
  110789. */
  110790. constructor(scene: Scene);
  110791. /**
  110792. * Applies a radial explosion impulse
  110793. * @param origin the origin of the explosion
  110794. * @param radiusOrEventOptions the radius or the options of radial explosion
  110795. * @param strength the explosion strength
  110796. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110797. * @returns A physics radial explosion event, or null
  110798. */
  110799. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  110800. /**
  110801. * Applies a radial explosion force
  110802. * @param origin the origin of the explosion
  110803. * @param radiusOrEventOptions the radius or the options of radial explosion
  110804. * @param strength the explosion strength
  110805. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110806. * @returns A physics radial explosion event, or null
  110807. */
  110808. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  110809. /**
  110810. * Creates a gravitational field
  110811. * @param origin the origin of the explosion
  110812. * @param radiusOrEventOptions the radius or the options of radial explosion
  110813. * @param strength the explosion strength
  110814. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110815. * @returns A physics gravitational field event, or null
  110816. */
  110817. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  110818. /**
  110819. * Creates a physics updraft event
  110820. * @param origin the origin of the updraft
  110821. * @param radiusOrEventOptions the radius or the options of the updraft
  110822. * @param strength the strength of the updraft
  110823. * @param height the height of the updraft
  110824. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  110825. * @returns A physics updraft event, or null
  110826. */
  110827. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  110828. /**
  110829. * Creates a physics vortex event
  110830. * @param origin the of the vortex
  110831. * @param radiusOrEventOptions the radius or the options of the vortex
  110832. * @param strength the strength of the vortex
  110833. * @param height the height of the vortex
  110834. * @returns a Physics vortex event, or null
  110835. * A physics vortex event or null
  110836. */
  110837. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  110838. }
  110839. /**
  110840. * Represents a physics radial explosion event
  110841. */
  110842. class PhysicsRadialExplosionEvent {
  110843. private _scene;
  110844. private _options;
  110845. private _sphere;
  110846. private _dataFetched;
  110847. /**
  110848. * Initializes a radial explosioin event
  110849. * @param _scene BabylonJS scene
  110850. * @param _options The options for the vortex event
  110851. */
  110852. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  110853. /**
  110854. * Returns the data related to the radial explosion event (sphere).
  110855. * @returns The radial explosion event data
  110856. */
  110857. getData(): PhysicsRadialExplosionEventData;
  110858. /**
  110859. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  110860. * @param impostor A physics imposter
  110861. * @param origin the origin of the explosion
  110862. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  110863. */
  110864. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  110865. /**
  110866. * Triggers affecterd impostors callbacks
  110867. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  110868. */
  110869. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  110870. /**
  110871. * Disposes the sphere.
  110872. * @param force Specifies if the sphere should be disposed by force
  110873. */
  110874. dispose(force?: boolean): void;
  110875. /*** Helpers ***/
  110876. private _prepareSphere;
  110877. private _intersectsWithSphere;
  110878. }
  110879. /**
  110880. * Represents a gravitational field event
  110881. */
  110882. class PhysicsGravitationalFieldEvent {
  110883. private _physicsHelper;
  110884. private _scene;
  110885. private _origin;
  110886. private _options;
  110887. private _tickCallback;
  110888. private _sphere;
  110889. private _dataFetched;
  110890. /**
  110891. * Initializes the physics gravitational field event
  110892. * @param _physicsHelper A physics helper
  110893. * @param _scene BabylonJS scene
  110894. * @param _origin The origin position of the gravitational field event
  110895. * @param _options The options for the vortex event
  110896. */
  110897. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  110898. /**
  110899. * Returns the data related to the gravitational field event (sphere).
  110900. * @returns A gravitational field event
  110901. */
  110902. getData(): PhysicsGravitationalFieldEventData;
  110903. /**
  110904. * Enables the gravitational field.
  110905. */
  110906. enable(): void;
  110907. /**
  110908. * Disables the gravitational field.
  110909. */
  110910. disable(): void;
  110911. /**
  110912. * Disposes the sphere.
  110913. * @param force The force to dispose from the gravitational field event
  110914. */
  110915. dispose(force?: boolean): void;
  110916. private _tick;
  110917. }
  110918. /**
  110919. * Represents a physics updraft event
  110920. */
  110921. class PhysicsUpdraftEvent {
  110922. private _scene;
  110923. private _origin;
  110924. private _options;
  110925. private _physicsEngine;
  110926. private _originTop;
  110927. private _originDirection;
  110928. private _tickCallback;
  110929. private _cylinder;
  110930. private _cylinderPosition;
  110931. private _dataFetched;
  110932. /**
  110933. * Initializes the physics updraft event
  110934. * @param _scene BabylonJS scene
  110935. * @param _origin The origin position of the updraft
  110936. * @param _options The options for the updraft event
  110937. */
  110938. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  110939. /**
  110940. * Returns the data related to the updraft event (cylinder).
  110941. * @returns A physics updraft event
  110942. */
  110943. getData(): PhysicsUpdraftEventData;
  110944. /**
  110945. * Enables the updraft.
  110946. */
  110947. enable(): void;
  110948. /**
  110949. * Disables the updraft.
  110950. */
  110951. disable(): void;
  110952. /**
  110953. * Disposes the cylinder.
  110954. * @param force Specifies if the updraft should be disposed by force
  110955. */
  110956. dispose(force?: boolean): void;
  110957. private getImpostorHitData;
  110958. private _tick;
  110959. /*** Helpers ***/
  110960. private _prepareCylinder;
  110961. private _intersectsWithCylinder;
  110962. }
  110963. /**
  110964. * Represents a physics vortex event
  110965. */
  110966. class PhysicsVortexEvent {
  110967. private _scene;
  110968. private _origin;
  110969. private _options;
  110970. private _physicsEngine;
  110971. private _originTop;
  110972. private _tickCallback;
  110973. private _cylinder;
  110974. private _cylinderPosition;
  110975. private _dataFetched;
  110976. /**
  110977. * Initializes the physics vortex event
  110978. * @param _scene The BabylonJS scene
  110979. * @param _origin The origin position of the vortex
  110980. * @param _options The options for the vortex event
  110981. */
  110982. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  110983. /**
  110984. * Returns the data related to the vortex event (cylinder).
  110985. * @returns The physics vortex event data
  110986. */
  110987. getData(): PhysicsVortexEventData;
  110988. /**
  110989. * Enables the vortex.
  110990. */
  110991. enable(): void;
  110992. /**
  110993. * Disables the cortex.
  110994. */
  110995. disable(): void;
  110996. /**
  110997. * Disposes the sphere.
  110998. * @param force
  110999. */
  111000. dispose(force?: boolean): void;
  111001. private getImpostorHitData;
  111002. private _tick;
  111003. /*** Helpers ***/
  111004. private _prepareCylinder;
  111005. private _intersectsWithCylinder;
  111006. }
  111007. /**
  111008. * Options fot the radial explosion event
  111009. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111010. */
  111011. export class PhysicsRadialExplosionEventOptions {
  111012. /**
  111013. * The radius of the sphere for the radial explosion.
  111014. */
  111015. radius: number;
  111016. /**
  111017. * The strenth of the explosion.
  111018. */
  111019. strength: number;
  111020. /**
  111021. * The strenght of the force in correspondence to the distance of the affected object
  111022. */
  111023. falloff: PhysicsRadialImpulseFalloff;
  111024. /**
  111025. * Sphere options for the radial explosion.
  111026. */
  111027. sphere: {
  111028. segments: number;
  111029. diameter: number;
  111030. };
  111031. /**
  111032. * Sphere options for the radial explosion.
  111033. */
  111034. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  111035. }
  111036. /**
  111037. * Options fot the updraft event
  111038. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111039. */
  111040. export class PhysicsUpdraftEventOptions {
  111041. /**
  111042. * The radius of the cylinder for the vortex
  111043. */
  111044. radius: number;
  111045. /**
  111046. * The strenth of the updraft.
  111047. */
  111048. strength: number;
  111049. /**
  111050. * The height of the cylinder for the updraft.
  111051. */
  111052. height: number;
  111053. /**
  111054. * The mode for the the updraft.
  111055. */
  111056. updraftMode: PhysicsUpdraftMode;
  111057. }
  111058. /**
  111059. * Options fot the vortex event
  111060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111061. */
  111062. export class PhysicsVortexEventOptions {
  111063. /**
  111064. * The radius of the cylinder for the vortex
  111065. */
  111066. radius: number;
  111067. /**
  111068. * The strenth of the vortex.
  111069. */
  111070. strength: number;
  111071. /**
  111072. * The height of the cylinder for the vortex.
  111073. */
  111074. height: number;
  111075. /**
  111076. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  111077. */
  111078. centripetalForceThreshold: number;
  111079. /**
  111080. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  111081. */
  111082. centripetalForceMultiplier: number;
  111083. /**
  111084. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  111085. */
  111086. centrifugalForceMultiplier: number;
  111087. /**
  111088. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  111089. */
  111090. updraftForceMultiplier: number;
  111091. }
  111092. /**
  111093. * The strenght of the force in correspondence to the distance of the affected object
  111094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111095. */
  111096. export enum PhysicsRadialImpulseFalloff {
  111097. /** Defines that impulse is constant in strength across it's whole radius */
  111098. Constant = 0,
  111099. /** Defines that impulse gets weaker if it's further from the origin */
  111100. Linear = 1
  111101. }
  111102. /**
  111103. * The strength of the force in correspondence to the distance of the affected object
  111104. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111105. */
  111106. export enum PhysicsUpdraftMode {
  111107. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  111108. Center = 0,
  111109. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  111110. Perpendicular = 1
  111111. }
  111112. /**
  111113. * Interface for a physics hit data
  111114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111115. */
  111116. export interface PhysicsHitData {
  111117. /**
  111118. * The force applied at the contact point
  111119. */
  111120. force: Vector3;
  111121. /**
  111122. * The contact point
  111123. */
  111124. contactPoint: Vector3;
  111125. /**
  111126. * The distance from the origin to the contact point
  111127. */
  111128. distanceFromOrigin: number;
  111129. }
  111130. /**
  111131. * Interface for radial explosion event data
  111132. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111133. */
  111134. export interface PhysicsRadialExplosionEventData {
  111135. /**
  111136. * A sphere used for the radial explosion event
  111137. */
  111138. sphere: Mesh;
  111139. }
  111140. /**
  111141. * Interface for gravitational field event data
  111142. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111143. */
  111144. export interface PhysicsGravitationalFieldEventData {
  111145. /**
  111146. * A sphere mesh used for the gravitational field event
  111147. */
  111148. sphere: Mesh;
  111149. }
  111150. /**
  111151. * Interface for updraft event data
  111152. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111153. */
  111154. export interface PhysicsUpdraftEventData {
  111155. /**
  111156. * A cylinder used for the updraft event
  111157. */
  111158. cylinder: Mesh;
  111159. }
  111160. /**
  111161. * Interface for vortex event data
  111162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111163. */
  111164. export interface PhysicsVortexEventData {
  111165. /**
  111166. * A cylinder used for the vortex event
  111167. */
  111168. cylinder: Mesh;
  111169. }
  111170. /**
  111171. * Interface for an affected physics impostor
  111172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111173. */
  111174. export interface PhysicsAffectedImpostorWithData {
  111175. /**
  111176. * The impostor affected by the effect
  111177. */
  111178. impostor: PhysicsImpostor;
  111179. /**
  111180. * The data about the hit/horce from the explosion
  111181. */
  111182. hitData: PhysicsHitData;
  111183. }
  111184. }
  111185. declare module BABYLON {
  111186. /** @hidden */
  111187. export var blackAndWhitePixelShader: {
  111188. name: string;
  111189. shader: string;
  111190. };
  111191. }
  111192. declare module BABYLON {
  111193. /**
  111194. * Post process used to render in black and white
  111195. */
  111196. export class BlackAndWhitePostProcess extends PostProcess {
  111197. /**
  111198. * Linear about to convert he result to black and white (default: 1)
  111199. */
  111200. degree: number;
  111201. /**
  111202. * Creates a black and white post process
  111203. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  111204. * @param name The name of the effect.
  111205. * @param options The required width/height ratio to downsize to before computing the render pass.
  111206. * @param camera The camera to apply the render pass to.
  111207. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111208. * @param engine The engine which the post process will be applied. (default: current engine)
  111209. * @param reusable If the post process can be reused on the same frame. (default: false)
  111210. */
  111211. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111212. }
  111213. }
  111214. declare module BABYLON {
  111215. /**
  111216. * This represents a set of one or more post processes in Babylon.
  111217. * A post process can be used to apply a shader to a texture after it is rendered.
  111218. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  111219. */
  111220. export class PostProcessRenderEffect {
  111221. private _postProcesses;
  111222. private _getPostProcesses;
  111223. private _singleInstance;
  111224. private _cameras;
  111225. private _indicesForCamera;
  111226. /**
  111227. * Name of the effect
  111228. * @hidden
  111229. */
  111230. _name: string;
  111231. /**
  111232. * Instantiates a post process render effect.
  111233. * A post process can be used to apply a shader to a texture after it is rendered.
  111234. * @param engine The engine the effect is tied to
  111235. * @param name The name of the effect
  111236. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  111237. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  111238. */
  111239. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  111240. /**
  111241. * Checks if all the post processes in the effect are supported.
  111242. */
  111243. readonly isSupported: boolean;
  111244. /**
  111245. * Updates the current state of the effect
  111246. * @hidden
  111247. */
  111248. _update(): void;
  111249. /**
  111250. * Attaches the effect on cameras
  111251. * @param cameras The camera to attach to.
  111252. * @hidden
  111253. */
  111254. _attachCameras(cameras: Camera): void;
  111255. /**
  111256. * Attaches the effect on cameras
  111257. * @param cameras The camera to attach to.
  111258. * @hidden
  111259. */
  111260. _attachCameras(cameras: Camera[]): void;
  111261. /**
  111262. * Detatches the effect on cameras
  111263. * @param cameras The camera to detatch from.
  111264. * @hidden
  111265. */
  111266. _detachCameras(cameras: Camera): void;
  111267. /**
  111268. * Detatches the effect on cameras
  111269. * @param cameras The camera to detatch from.
  111270. * @hidden
  111271. */
  111272. _detachCameras(cameras: Camera[]): void;
  111273. /**
  111274. * Enables the effect on given cameras
  111275. * @param cameras The camera to enable.
  111276. * @hidden
  111277. */
  111278. _enable(cameras: Camera): void;
  111279. /**
  111280. * Enables the effect on given cameras
  111281. * @param cameras The camera to enable.
  111282. * @hidden
  111283. */
  111284. _enable(cameras: Nullable<Camera[]>): void;
  111285. /**
  111286. * Disables the effect on the given cameras
  111287. * @param cameras The camera to disable.
  111288. * @hidden
  111289. */
  111290. _disable(cameras: Camera): void;
  111291. /**
  111292. * Disables the effect on the given cameras
  111293. * @param cameras The camera to disable.
  111294. * @hidden
  111295. */
  111296. _disable(cameras: Nullable<Camera[]>): void;
  111297. /**
  111298. * Gets a list of the post processes contained in the effect.
  111299. * @param camera The camera to get the post processes on.
  111300. * @returns The list of the post processes in the effect.
  111301. */
  111302. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  111303. }
  111304. }
  111305. declare module BABYLON {
  111306. /** @hidden */
  111307. export var extractHighlightsPixelShader: {
  111308. name: string;
  111309. shader: string;
  111310. };
  111311. }
  111312. declare module BABYLON {
  111313. /**
  111314. * 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.
  111315. */
  111316. export class ExtractHighlightsPostProcess extends PostProcess {
  111317. /**
  111318. * The luminance threshold, pixels below this value will be set to black.
  111319. */
  111320. threshold: number;
  111321. /** @hidden */
  111322. _exposure: number;
  111323. /**
  111324. * Post process which has the input texture to be used when performing highlight extraction
  111325. * @hidden
  111326. */
  111327. _inputPostProcess: Nullable<PostProcess>;
  111328. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111329. }
  111330. }
  111331. declare module BABYLON {
  111332. /** @hidden */
  111333. export var bloomMergePixelShader: {
  111334. name: string;
  111335. shader: string;
  111336. };
  111337. }
  111338. declare module BABYLON {
  111339. /**
  111340. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  111341. */
  111342. export class BloomMergePostProcess extends PostProcess {
  111343. /** Weight of the bloom to be added to the original input. */
  111344. weight: number;
  111345. /**
  111346. * Creates a new instance of @see BloomMergePostProcess
  111347. * @param name The name of the effect.
  111348. * @param originalFromInput Post process which's input will be used for the merge.
  111349. * @param blurred Blurred highlights post process which's output will be used.
  111350. * @param weight Weight of the bloom to be added to the original input.
  111351. * @param options The required width/height ratio to downsize to before computing the render pass.
  111352. * @param camera The camera to apply the render pass to.
  111353. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111354. * @param engine The engine which the post process will be applied. (default: current engine)
  111355. * @param reusable If the post process can be reused on the same frame. (default: false)
  111356. * @param textureType Type of textures used when performing the post process. (default: 0)
  111357. * @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)
  111358. */
  111359. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  111360. /** Weight of the bloom to be added to the original input. */
  111361. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111362. }
  111363. }
  111364. declare module BABYLON {
  111365. /**
  111366. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  111367. */
  111368. export class BloomEffect extends PostProcessRenderEffect {
  111369. private bloomScale;
  111370. /**
  111371. * @hidden Internal
  111372. */
  111373. _effects: Array<PostProcess>;
  111374. /**
  111375. * @hidden Internal
  111376. */
  111377. _downscale: ExtractHighlightsPostProcess;
  111378. private _blurX;
  111379. private _blurY;
  111380. private _merge;
  111381. /**
  111382. * The luminance threshold to find bright areas of the image to bloom.
  111383. */
  111384. threshold: number;
  111385. /**
  111386. * The strength of the bloom.
  111387. */
  111388. weight: number;
  111389. /**
  111390. * Specifies the size of the bloom blur kernel, relative to the final output size
  111391. */
  111392. kernel: number;
  111393. /**
  111394. * Creates a new instance of @see BloomEffect
  111395. * @param scene The scene the effect belongs to.
  111396. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  111397. * @param bloomKernel The size of the kernel to be used when applying the blur.
  111398. * @param bloomWeight The the strength of bloom.
  111399. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  111400. * @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)
  111401. */
  111402. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  111403. /**
  111404. * Disposes each of the internal effects for a given camera.
  111405. * @param camera The camera to dispose the effect on.
  111406. */
  111407. disposeEffects(camera: Camera): void;
  111408. /**
  111409. * @hidden Internal
  111410. */
  111411. _updateEffects(): void;
  111412. /**
  111413. * Internal
  111414. * @returns if all the contained post processes are ready.
  111415. * @hidden
  111416. */
  111417. _isReady(): boolean;
  111418. }
  111419. }
  111420. declare module BABYLON {
  111421. /** @hidden */
  111422. export var chromaticAberrationPixelShader: {
  111423. name: string;
  111424. shader: string;
  111425. };
  111426. }
  111427. declare module BABYLON {
  111428. /**
  111429. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  111430. */
  111431. export class ChromaticAberrationPostProcess extends PostProcess {
  111432. /**
  111433. * The amount of seperation of rgb channels (default: 30)
  111434. */
  111435. aberrationAmount: number;
  111436. /**
  111437. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  111438. */
  111439. radialIntensity: number;
  111440. /**
  111441. * 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))
  111442. */
  111443. direction: Vector2;
  111444. /**
  111445. * 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))
  111446. */
  111447. centerPosition: Vector2;
  111448. /**
  111449. * Creates a new instance ChromaticAberrationPostProcess
  111450. * @param name The name of the effect.
  111451. * @param screenWidth The width of the screen to apply the effect on.
  111452. * @param screenHeight The height of the screen to apply the effect on.
  111453. * @param options The required width/height ratio to downsize to before computing the render pass.
  111454. * @param camera The camera to apply the render pass to.
  111455. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111456. * @param engine The engine which the post process will be applied. (default: current engine)
  111457. * @param reusable If the post process can be reused on the same frame. (default: false)
  111458. * @param textureType Type of textures used when performing the post process. (default: 0)
  111459. * @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)
  111460. */
  111461. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111462. }
  111463. }
  111464. declare module BABYLON {
  111465. /** @hidden */
  111466. export var circleOfConfusionPixelShader: {
  111467. name: string;
  111468. shader: string;
  111469. };
  111470. }
  111471. declare module BABYLON {
  111472. /**
  111473. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  111474. */
  111475. export class CircleOfConfusionPostProcess extends PostProcess {
  111476. /**
  111477. * 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.
  111478. */
  111479. lensSize: number;
  111480. /**
  111481. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  111482. */
  111483. fStop: number;
  111484. /**
  111485. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  111486. */
  111487. focusDistance: number;
  111488. /**
  111489. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  111490. */
  111491. focalLength: number;
  111492. private _depthTexture;
  111493. /**
  111494. * Creates a new instance CircleOfConfusionPostProcess
  111495. * @param name The name of the effect.
  111496. * @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.
  111497. * @param options The required width/height ratio to downsize to before computing the render pass.
  111498. * @param camera The camera to apply the render pass to.
  111499. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111500. * @param engine The engine which the post process will be applied. (default: current engine)
  111501. * @param reusable If the post process can be reused on the same frame. (default: false)
  111502. * @param textureType Type of textures used when performing the post process. (default: 0)
  111503. * @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)
  111504. */
  111505. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111506. /**
  111507. * 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.
  111508. */
  111509. depthTexture: RenderTargetTexture;
  111510. }
  111511. }
  111512. declare module BABYLON {
  111513. /** @hidden */
  111514. export var colorCorrectionPixelShader: {
  111515. name: string;
  111516. shader: string;
  111517. };
  111518. }
  111519. declare module BABYLON {
  111520. /**
  111521. *
  111522. * This post-process allows the modification of rendered colors by using
  111523. * a 'look-up table' (LUT). This effect is also called Color Grading.
  111524. *
  111525. * The object needs to be provided an url to a texture containing the color
  111526. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  111527. * Use an image editing software to tweak the LUT to match your needs.
  111528. *
  111529. * For an example of a color LUT, see here:
  111530. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  111531. * For explanations on color grading, see here:
  111532. * @see http://udn.epicgames.com/Three/ColorGrading.html
  111533. *
  111534. */
  111535. export class ColorCorrectionPostProcess extends PostProcess {
  111536. private _colorTableTexture;
  111537. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111538. }
  111539. }
  111540. declare module BABYLON {
  111541. /** @hidden */
  111542. export var convolutionPixelShader: {
  111543. name: string;
  111544. shader: string;
  111545. };
  111546. }
  111547. declare module BABYLON {
  111548. /**
  111549. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  111550. * input texture to perform effects such as edge detection or sharpening
  111551. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  111552. */
  111553. export class ConvolutionPostProcess extends PostProcess {
  111554. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  111555. kernel: number[];
  111556. /**
  111557. * Creates a new instance ConvolutionPostProcess
  111558. * @param name The name of the effect.
  111559. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  111560. * @param options The required width/height ratio to downsize to before computing the render pass.
  111561. * @param camera The camera to apply the render pass to.
  111562. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111563. * @param engine The engine which the post process will be applied. (default: current engine)
  111564. * @param reusable If the post process can be reused on the same frame. (default: false)
  111565. * @param textureType Type of textures used when performing the post process. (default: 0)
  111566. */
  111567. constructor(name: string,
  111568. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  111569. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111570. /**
  111571. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111572. */
  111573. static EdgeDetect0Kernel: number[];
  111574. /**
  111575. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111576. */
  111577. static EdgeDetect1Kernel: number[];
  111578. /**
  111579. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111580. */
  111581. static EdgeDetect2Kernel: number[];
  111582. /**
  111583. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111584. */
  111585. static SharpenKernel: number[];
  111586. /**
  111587. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111588. */
  111589. static EmbossKernel: number[];
  111590. /**
  111591. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111592. */
  111593. static GaussianKernel: number[];
  111594. }
  111595. }
  111596. declare module BABYLON {
  111597. /**
  111598. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  111599. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  111600. * based on samples that have a large difference in distance than the center pixel.
  111601. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  111602. */
  111603. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  111604. direction: Vector2;
  111605. /**
  111606. * Creates a new instance CircleOfConfusionPostProcess
  111607. * @param name The name of the effect.
  111608. * @param scene The scene the effect belongs to.
  111609. * @param direction The direction the blur should be applied.
  111610. * @param kernel The size of the kernel used to blur.
  111611. * @param options The required width/height ratio to downsize to before computing the render pass.
  111612. * @param camera The camera to apply the render pass to.
  111613. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  111614. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  111615. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111616. * @param engine The engine which the post process will be applied. (default: current engine)
  111617. * @param reusable If the post process can be reused on the same frame. (default: false)
  111618. * @param textureType Type of textures used when performing the post process. (default: 0)
  111619. * @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)
  111620. */
  111621. 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);
  111622. }
  111623. }
  111624. declare module BABYLON {
  111625. /** @hidden */
  111626. export var depthOfFieldMergePixelShader: {
  111627. name: string;
  111628. shader: string;
  111629. };
  111630. }
  111631. declare module BABYLON {
  111632. /**
  111633. * Options to be set when merging outputs from the default pipeline.
  111634. */
  111635. export class DepthOfFieldMergePostProcessOptions {
  111636. /**
  111637. * The original image to merge on top of
  111638. */
  111639. originalFromInput: PostProcess;
  111640. /**
  111641. * Parameters to perform the merge of the depth of field effect
  111642. */
  111643. depthOfField?: {
  111644. circleOfConfusion: PostProcess;
  111645. blurSteps: Array<PostProcess>;
  111646. };
  111647. /**
  111648. * Parameters to perform the merge of bloom effect
  111649. */
  111650. bloom?: {
  111651. blurred: PostProcess;
  111652. weight: number;
  111653. };
  111654. }
  111655. /**
  111656. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  111657. */
  111658. export class DepthOfFieldMergePostProcess extends PostProcess {
  111659. private blurSteps;
  111660. /**
  111661. * Creates a new instance of DepthOfFieldMergePostProcess
  111662. * @param name The name of the effect.
  111663. * @param originalFromInput Post process which's input will be used for the merge.
  111664. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  111665. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  111666. * @param options The required width/height ratio to downsize to before computing the render pass.
  111667. * @param camera The camera to apply the render pass to.
  111668. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111669. * @param engine The engine which the post process will be applied. (default: current engine)
  111670. * @param reusable If the post process can be reused on the same frame. (default: false)
  111671. * @param textureType Type of textures used when performing the post process. (default: 0)
  111672. * @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)
  111673. */
  111674. 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);
  111675. /**
  111676. * Updates the effect with the current post process compile time values and recompiles the shader.
  111677. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  111678. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  111679. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  111680. * @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
  111681. * @param onCompiled Called when the shader has been compiled.
  111682. * @param onError Called if there is an error when compiling a shader.
  111683. */
  111684. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  111685. }
  111686. }
  111687. declare module BABYLON {
  111688. /**
  111689. * Specifies the level of max blur that should be applied when using the depth of field effect
  111690. */
  111691. export enum DepthOfFieldEffectBlurLevel {
  111692. /**
  111693. * Subtle blur
  111694. */
  111695. Low = 0,
  111696. /**
  111697. * Medium blur
  111698. */
  111699. Medium = 1,
  111700. /**
  111701. * Large blur
  111702. */
  111703. High = 2
  111704. }
  111705. /**
  111706. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  111707. */
  111708. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  111709. private _circleOfConfusion;
  111710. /**
  111711. * @hidden Internal, blurs from high to low
  111712. */
  111713. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  111714. private _depthOfFieldBlurY;
  111715. private _dofMerge;
  111716. /**
  111717. * @hidden Internal post processes in depth of field effect
  111718. */
  111719. _effects: Array<PostProcess>;
  111720. /**
  111721. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  111722. */
  111723. focalLength: number;
  111724. /**
  111725. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  111726. */
  111727. fStop: number;
  111728. /**
  111729. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  111730. */
  111731. focusDistance: number;
  111732. /**
  111733. * 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.
  111734. */
  111735. lensSize: number;
  111736. /**
  111737. * Creates a new instance DepthOfFieldEffect
  111738. * @param scene The scene the effect belongs to.
  111739. * @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.
  111740. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  111741. * @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)
  111742. */
  111743. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  111744. /**
  111745. * 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.
  111746. */
  111747. depthTexture: RenderTargetTexture;
  111748. /**
  111749. * Disposes each of the internal effects for a given camera.
  111750. * @param camera The camera to dispose the effect on.
  111751. */
  111752. disposeEffects(camera: Camera): void;
  111753. /**
  111754. * @hidden Internal
  111755. */
  111756. _updateEffects(): void;
  111757. /**
  111758. * Internal
  111759. * @returns if all the contained post processes are ready.
  111760. * @hidden
  111761. */
  111762. _isReady(): boolean;
  111763. }
  111764. }
  111765. declare module BABYLON {
  111766. /** @hidden */
  111767. export var displayPassPixelShader: {
  111768. name: string;
  111769. shader: string;
  111770. };
  111771. }
  111772. declare module BABYLON {
  111773. /**
  111774. * DisplayPassPostProcess which produces an output the same as it's input
  111775. */
  111776. export class DisplayPassPostProcess extends PostProcess {
  111777. /**
  111778. * Creates the DisplayPassPostProcess
  111779. * @param name The name of the effect.
  111780. * @param options The required width/height ratio to downsize to before computing the render pass.
  111781. * @param camera The camera to apply the render pass to.
  111782. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111783. * @param engine The engine which the post process will be applied. (default: current engine)
  111784. * @param reusable If the post process can be reused on the same frame. (default: false)
  111785. */
  111786. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111787. }
  111788. }
  111789. declare module BABYLON {
  111790. /** @hidden */
  111791. export var filterPixelShader: {
  111792. name: string;
  111793. shader: string;
  111794. };
  111795. }
  111796. declare module BABYLON {
  111797. /**
  111798. * Applies a kernel filter to the image
  111799. */
  111800. export class FilterPostProcess extends PostProcess {
  111801. /** The matrix to be applied to the image */
  111802. kernelMatrix: Matrix;
  111803. /**
  111804. *
  111805. * @param name The name of the effect.
  111806. * @param kernelMatrix The matrix to be applied to the image
  111807. * @param options The required width/height ratio to downsize to before computing the render pass.
  111808. * @param camera The camera to apply the render pass to.
  111809. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111810. * @param engine The engine which the post process will be applied. (default: current engine)
  111811. * @param reusable If the post process can be reused on the same frame. (default: false)
  111812. */
  111813. constructor(name: string,
  111814. /** The matrix to be applied to the image */
  111815. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111816. }
  111817. }
  111818. declare module BABYLON {
  111819. /** @hidden */
  111820. export var fxaaPixelShader: {
  111821. name: string;
  111822. shader: string;
  111823. };
  111824. }
  111825. declare module BABYLON {
  111826. /** @hidden */
  111827. export var fxaaVertexShader: {
  111828. name: string;
  111829. shader: string;
  111830. };
  111831. }
  111832. declare module BABYLON {
  111833. /**
  111834. * Fxaa post process
  111835. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  111836. */
  111837. export class FxaaPostProcess extends PostProcess {
  111838. /** @hidden */
  111839. texelWidth: number;
  111840. /** @hidden */
  111841. texelHeight: number;
  111842. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111843. private _getDefines;
  111844. }
  111845. }
  111846. declare module BABYLON {
  111847. /** @hidden */
  111848. export var grainPixelShader: {
  111849. name: string;
  111850. shader: string;
  111851. };
  111852. }
  111853. declare module BABYLON {
  111854. /**
  111855. * The GrainPostProcess adds noise to the image at mid luminance levels
  111856. */
  111857. export class GrainPostProcess extends PostProcess {
  111858. /**
  111859. * The intensity of the grain added (default: 30)
  111860. */
  111861. intensity: number;
  111862. /**
  111863. * If the grain should be randomized on every frame
  111864. */
  111865. animated: boolean;
  111866. /**
  111867. * Creates a new instance of @see GrainPostProcess
  111868. * @param name The name of the effect.
  111869. * @param options The required width/height ratio to downsize to before computing the render pass.
  111870. * @param camera The camera to apply the render pass to.
  111871. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111872. * @param engine The engine which the post process will be applied. (default: current engine)
  111873. * @param reusable If the post process can be reused on the same frame. (default: false)
  111874. * @param textureType Type of textures used when performing the post process. (default: 0)
  111875. * @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)
  111876. */
  111877. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111878. }
  111879. }
  111880. declare module BABYLON {
  111881. /** @hidden */
  111882. export var highlightsPixelShader: {
  111883. name: string;
  111884. shader: string;
  111885. };
  111886. }
  111887. declare module BABYLON {
  111888. /**
  111889. * Extracts highlights from the image
  111890. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  111891. */
  111892. export class HighlightsPostProcess extends PostProcess {
  111893. /**
  111894. * Extracts highlights from the image
  111895. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  111896. * @param name The name of the effect.
  111897. * @param options The required width/height ratio to downsize to before computing the render pass.
  111898. * @param camera The camera to apply the render pass to.
  111899. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111900. * @param engine The engine which the post process will be applied. (default: current engine)
  111901. * @param reusable If the post process can be reused on the same frame. (default: false)
  111902. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  111903. */
  111904. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111905. }
  111906. }
  111907. declare module BABYLON {
  111908. /** @hidden */
  111909. export var mrtFragmentDeclaration: {
  111910. name: string;
  111911. shader: string;
  111912. };
  111913. }
  111914. declare module BABYLON {
  111915. /** @hidden */
  111916. export var geometryPixelShader: {
  111917. name: string;
  111918. shader: string;
  111919. };
  111920. }
  111921. declare module BABYLON {
  111922. /** @hidden */
  111923. export var geometryVertexShader: {
  111924. name: string;
  111925. shader: string;
  111926. };
  111927. }
  111928. declare module BABYLON {
  111929. /**
  111930. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  111931. */
  111932. export class GeometryBufferRenderer {
  111933. /**
  111934. * Constant used to retrieve the position texture index in the G-Buffer textures array
  111935. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  111936. */
  111937. static readonly POSITION_TEXTURE_TYPE: number;
  111938. /**
  111939. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  111940. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  111941. */
  111942. static readonly VELOCITY_TEXTURE_TYPE: number;
  111943. /**
  111944. * Dictionary used to store the previous transformation matrices of each rendered mesh
  111945. * in order to compute objects velocities when enableVelocity is set to "true"
  111946. * @hidden
  111947. */
  111948. _previousTransformationMatrices: {
  111949. [index: number]: Matrix;
  111950. };
  111951. private _scene;
  111952. private _multiRenderTarget;
  111953. private _ratio;
  111954. private _enablePosition;
  111955. private _enableVelocity;
  111956. private _positionIndex;
  111957. private _velocityIndex;
  111958. protected _effect: Effect;
  111959. protected _cachedDefines: string;
  111960. /**
  111961. * Set the render list (meshes to be rendered) used in the G buffer.
  111962. */
  111963. renderList: Mesh[];
  111964. /**
  111965. * Gets wether or not G buffer are supported by the running hardware.
  111966. * This requires draw buffer supports
  111967. */
  111968. readonly isSupported: boolean;
  111969. /**
  111970. * Returns the index of the given texture type in the G-Buffer textures array
  111971. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  111972. * @returns the index of the given texture type in the G-Buffer textures array
  111973. */
  111974. getTextureIndex(textureType: number): number;
  111975. /**
  111976. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  111977. */
  111978. /**
  111979. * Sets whether or not objects positions are enabled for the G buffer.
  111980. */
  111981. enablePosition: boolean;
  111982. /**
  111983. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  111984. */
  111985. /**
  111986. * Sets wether or not objects velocities are enabled for the G buffer.
  111987. */
  111988. enableVelocity: boolean;
  111989. /**
  111990. * Gets the scene associated with the buffer.
  111991. */
  111992. readonly scene: Scene;
  111993. /**
  111994. * Gets the ratio used by the buffer during its creation.
  111995. * How big is the buffer related to the main canvas.
  111996. */
  111997. readonly ratio: number;
  111998. /** @hidden */
  111999. static _SceneComponentInitialization: (scene: Scene) => void;
  112000. /**
  112001. * Creates a new G Buffer for the scene
  112002. * @param scene The scene the buffer belongs to
  112003. * @param ratio How big is the buffer related to the main canvas.
  112004. */
  112005. constructor(scene: Scene, ratio?: number);
  112006. /**
  112007. * Checks wether everything is ready to render a submesh to the G buffer.
  112008. * @param subMesh the submesh to check readiness for
  112009. * @param useInstances is the mesh drawn using instance or not
  112010. * @returns true if ready otherwise false
  112011. */
  112012. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112013. /**
  112014. * Gets the current underlying G Buffer.
  112015. * @returns the buffer
  112016. */
  112017. getGBuffer(): MultiRenderTarget;
  112018. /**
  112019. * Gets the number of samples used to render the buffer (anti aliasing).
  112020. */
  112021. /**
  112022. * Sets the number of samples used to render the buffer (anti aliasing).
  112023. */
  112024. samples: number;
  112025. /**
  112026. * Disposes the renderer and frees up associated resources.
  112027. */
  112028. dispose(): void;
  112029. protected _createRenderTargets(): void;
  112030. }
  112031. }
  112032. declare module BABYLON {
  112033. interface Scene {
  112034. /** @hidden (Backing field) */
  112035. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  112036. /**
  112037. * Gets or Sets the current geometry buffer associated to the scene.
  112038. */
  112039. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  112040. /**
  112041. * Enables a GeometryBufferRender and associates it with the scene
  112042. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  112043. * @returns the GeometryBufferRenderer
  112044. */
  112045. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  112046. /**
  112047. * Disables the GeometryBufferRender associated with the scene
  112048. */
  112049. disableGeometryBufferRenderer(): void;
  112050. }
  112051. /**
  112052. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  112053. * in several rendering techniques.
  112054. */
  112055. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  112056. /**
  112057. * The component name helpful to identify the component in the list of scene components.
  112058. */
  112059. readonly name: string;
  112060. /**
  112061. * The scene the component belongs to.
  112062. */
  112063. scene: Scene;
  112064. /**
  112065. * Creates a new instance of the component for the given scene
  112066. * @param scene Defines the scene to register the component in
  112067. */
  112068. constructor(scene: Scene);
  112069. /**
  112070. * Registers the component in a given scene
  112071. */
  112072. register(): void;
  112073. /**
  112074. * Rebuilds the elements related to this component in case of
  112075. * context lost for instance.
  112076. */
  112077. rebuild(): void;
  112078. /**
  112079. * Disposes the component and the associated ressources
  112080. */
  112081. dispose(): void;
  112082. private _gatherRenderTargets;
  112083. }
  112084. }
  112085. declare module BABYLON {
  112086. /** @hidden */
  112087. export var motionBlurPixelShader: {
  112088. name: string;
  112089. shader: string;
  112090. };
  112091. }
  112092. declare module BABYLON {
  112093. /**
  112094. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  112095. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  112096. * As an example, all you have to do is to create the post-process:
  112097. * var mb = new BABYLON.MotionBlurPostProcess(
  112098. * 'mb', // The name of the effect.
  112099. * scene, // The scene containing the objects to blur according to their velocity.
  112100. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  112101. * camera // The camera to apply the render pass to.
  112102. * );
  112103. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  112104. */
  112105. export class MotionBlurPostProcess extends PostProcess {
  112106. /**
  112107. * Defines how much the image is blurred by the movement. Default value is equal to 1
  112108. */
  112109. motionStrength: number;
  112110. /**
  112111. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  112112. */
  112113. /**
  112114. * Sets the number of iterations to be used for motion blur quality
  112115. */
  112116. motionBlurSamples: number;
  112117. private _motionBlurSamples;
  112118. private _geometryBufferRenderer;
  112119. /**
  112120. * Creates a new instance MotionBlurPostProcess
  112121. * @param name The name of the effect.
  112122. * @param scene The scene containing the objects to blur according to their velocity.
  112123. * @param options The required width/height ratio to downsize to before computing the render pass.
  112124. * @param camera The camera to apply the render pass to.
  112125. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112126. * @param engine The engine which the post process will be applied. (default: current engine)
  112127. * @param reusable If the post process can be reused on the same frame. (default: false)
  112128. * @param textureType Type of textures used when performing the post process. (default: 0)
  112129. * @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)
  112130. */
  112131. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112132. /**
  112133. * Disposes the post process.
  112134. * @param camera The camera to dispose the post process on.
  112135. */
  112136. dispose(camera?: Camera): void;
  112137. }
  112138. }
  112139. declare module BABYLON {
  112140. /** @hidden */
  112141. export var refractionPixelShader: {
  112142. name: string;
  112143. shader: string;
  112144. };
  112145. }
  112146. declare module BABYLON {
  112147. /**
  112148. * Post process which applies a refractin texture
  112149. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  112150. */
  112151. export class RefractionPostProcess extends PostProcess {
  112152. /** the base color of the refraction (used to taint the rendering) */
  112153. color: Color3;
  112154. /** simulated refraction depth */
  112155. depth: number;
  112156. /** the coefficient of the base color (0 to remove base color tainting) */
  112157. colorLevel: number;
  112158. private _refTexture;
  112159. private _ownRefractionTexture;
  112160. /**
  112161. * Gets or sets the refraction texture
  112162. * Please note that you are responsible for disposing the texture if you set it manually
  112163. */
  112164. refractionTexture: Texture;
  112165. /**
  112166. * Initializes the RefractionPostProcess
  112167. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  112168. * @param name The name of the effect.
  112169. * @param refractionTextureUrl Url of the refraction texture to use
  112170. * @param color the base color of the refraction (used to taint the rendering)
  112171. * @param depth simulated refraction depth
  112172. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  112173. * @param camera The camera to apply the render pass to.
  112174. * @param options The required width/height ratio to downsize to before computing the render pass.
  112175. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112176. * @param engine The engine which the post process will be applied. (default: current engine)
  112177. * @param reusable If the post process can be reused on the same frame. (default: false)
  112178. */
  112179. constructor(name: string, refractionTextureUrl: string,
  112180. /** the base color of the refraction (used to taint the rendering) */
  112181. color: Color3,
  112182. /** simulated refraction depth */
  112183. depth: number,
  112184. /** the coefficient of the base color (0 to remove base color tainting) */
  112185. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112186. /**
  112187. * Disposes of the post process
  112188. * @param camera Camera to dispose post process on
  112189. */
  112190. dispose(camera: Camera): void;
  112191. }
  112192. }
  112193. declare module BABYLON {
  112194. /** @hidden */
  112195. export var sharpenPixelShader: {
  112196. name: string;
  112197. shader: string;
  112198. };
  112199. }
  112200. declare module BABYLON {
  112201. /**
  112202. * The SharpenPostProcess applies a sharpen kernel to every pixel
  112203. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  112204. */
  112205. export class SharpenPostProcess extends PostProcess {
  112206. /**
  112207. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  112208. */
  112209. colorAmount: number;
  112210. /**
  112211. * How much sharpness should be applied (default: 0.3)
  112212. */
  112213. edgeAmount: number;
  112214. /**
  112215. * Creates a new instance ConvolutionPostProcess
  112216. * @param name The name of the effect.
  112217. * @param options The required width/height ratio to downsize to before computing the render pass.
  112218. * @param camera The camera to apply the render pass to.
  112219. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112220. * @param engine The engine which the post process will be applied. (default: current engine)
  112221. * @param reusable If the post process can be reused on the same frame. (default: false)
  112222. * @param textureType Type of textures used when performing the post process. (default: 0)
  112223. * @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)
  112224. */
  112225. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112226. }
  112227. }
  112228. declare module BABYLON {
  112229. /**
  112230. * PostProcessRenderPipeline
  112231. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112232. */
  112233. export class PostProcessRenderPipeline {
  112234. private engine;
  112235. private _renderEffects;
  112236. private _renderEffectsForIsolatedPass;
  112237. /**
  112238. * List of inspectable custom properties (used by the Inspector)
  112239. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  112240. */
  112241. inspectableCustomProperties: IInspectable[];
  112242. /**
  112243. * @hidden
  112244. */
  112245. protected _cameras: Camera[];
  112246. /** @hidden */
  112247. _name: string;
  112248. /**
  112249. * Gets pipeline name
  112250. */
  112251. readonly name: string;
  112252. /**
  112253. * Initializes a PostProcessRenderPipeline
  112254. * @param engine engine to add the pipeline to
  112255. * @param name name of the pipeline
  112256. */
  112257. constructor(engine: Engine, name: string);
  112258. /**
  112259. * Gets the class name
  112260. * @returns "PostProcessRenderPipeline"
  112261. */
  112262. getClassName(): string;
  112263. /**
  112264. * If all the render effects in the pipeline are supported
  112265. */
  112266. readonly isSupported: boolean;
  112267. /**
  112268. * Adds an effect to the pipeline
  112269. * @param renderEffect the effect to add
  112270. */
  112271. addEffect(renderEffect: PostProcessRenderEffect): void;
  112272. /** @hidden */
  112273. _rebuild(): void;
  112274. /** @hidden */
  112275. _enableEffect(renderEffectName: string, cameras: Camera): void;
  112276. /** @hidden */
  112277. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  112278. /** @hidden */
  112279. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  112280. /** @hidden */
  112281. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  112282. /** @hidden */
  112283. _attachCameras(cameras: Camera, unique: boolean): void;
  112284. /** @hidden */
  112285. _attachCameras(cameras: Camera[], unique: boolean): void;
  112286. /** @hidden */
  112287. _detachCameras(cameras: Camera): void;
  112288. /** @hidden */
  112289. _detachCameras(cameras: Nullable<Camera[]>): void;
  112290. /** @hidden */
  112291. _update(): void;
  112292. /** @hidden */
  112293. _reset(): void;
  112294. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  112295. /**
  112296. * Disposes of the pipeline
  112297. */
  112298. dispose(): void;
  112299. }
  112300. }
  112301. declare module BABYLON {
  112302. /**
  112303. * PostProcessRenderPipelineManager class
  112304. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112305. */
  112306. export class PostProcessRenderPipelineManager {
  112307. private _renderPipelines;
  112308. /**
  112309. * Initializes a PostProcessRenderPipelineManager
  112310. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112311. */
  112312. constructor();
  112313. /**
  112314. * Gets the list of supported render pipelines
  112315. */
  112316. readonly supportedPipelines: PostProcessRenderPipeline[];
  112317. /**
  112318. * Adds a pipeline to the manager
  112319. * @param renderPipeline The pipeline to add
  112320. */
  112321. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  112322. /**
  112323. * Attaches a camera to the pipeline
  112324. * @param renderPipelineName The name of the pipeline to attach to
  112325. * @param cameras the camera to attach
  112326. * @param unique if the camera can be attached multiple times to the pipeline
  112327. */
  112328. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  112329. /**
  112330. * Detaches a camera from the pipeline
  112331. * @param renderPipelineName The name of the pipeline to detach from
  112332. * @param cameras the camera to detach
  112333. */
  112334. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  112335. /**
  112336. * Enables an effect by name on a pipeline
  112337. * @param renderPipelineName the name of the pipeline to enable the effect in
  112338. * @param renderEffectName the name of the effect to enable
  112339. * @param cameras the cameras that the effect should be enabled on
  112340. */
  112341. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  112342. /**
  112343. * Disables an effect by name on a pipeline
  112344. * @param renderPipelineName the name of the pipeline to disable the effect in
  112345. * @param renderEffectName the name of the effect to disable
  112346. * @param cameras the cameras that the effect should be disabled on
  112347. */
  112348. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  112349. /**
  112350. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  112351. */
  112352. update(): void;
  112353. /** @hidden */
  112354. _rebuild(): void;
  112355. /**
  112356. * Disposes of the manager and pipelines
  112357. */
  112358. dispose(): void;
  112359. }
  112360. }
  112361. declare module BABYLON {
  112362. interface Scene {
  112363. /** @hidden (Backing field) */
  112364. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  112365. /**
  112366. * Gets the postprocess render pipeline manager
  112367. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112368. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  112369. */
  112370. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  112371. }
  112372. /**
  112373. * Defines the Render Pipeline scene component responsible to rendering pipelines
  112374. */
  112375. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  112376. /**
  112377. * The component name helpfull to identify the component in the list of scene components.
  112378. */
  112379. readonly name: string;
  112380. /**
  112381. * The scene the component belongs to.
  112382. */
  112383. scene: Scene;
  112384. /**
  112385. * Creates a new instance of the component for the given scene
  112386. * @param scene Defines the scene to register the component in
  112387. */
  112388. constructor(scene: Scene);
  112389. /**
  112390. * Registers the component in a given scene
  112391. */
  112392. register(): void;
  112393. /**
  112394. * Rebuilds the elements related to this component in case of
  112395. * context lost for instance.
  112396. */
  112397. rebuild(): void;
  112398. /**
  112399. * Disposes the component and the associated ressources
  112400. */
  112401. dispose(): void;
  112402. private _gatherRenderTargets;
  112403. }
  112404. }
  112405. declare module BABYLON {
  112406. /**
  112407. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  112408. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  112409. */
  112410. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  112411. private _scene;
  112412. private _camerasToBeAttached;
  112413. /**
  112414. * ID of the sharpen post process,
  112415. */
  112416. private readonly SharpenPostProcessId;
  112417. /**
  112418. * @ignore
  112419. * ID of the image processing post process;
  112420. */
  112421. readonly ImageProcessingPostProcessId: string;
  112422. /**
  112423. * @ignore
  112424. * ID of the Fast Approximate Anti-Aliasing post process;
  112425. */
  112426. readonly FxaaPostProcessId: string;
  112427. /**
  112428. * ID of the chromatic aberration post process,
  112429. */
  112430. private readonly ChromaticAberrationPostProcessId;
  112431. /**
  112432. * ID of the grain post process
  112433. */
  112434. private readonly GrainPostProcessId;
  112435. /**
  112436. * Sharpen post process which will apply a sharpen convolution to enhance edges
  112437. */
  112438. sharpen: SharpenPostProcess;
  112439. private _sharpenEffect;
  112440. private bloom;
  112441. /**
  112442. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  112443. */
  112444. depthOfField: DepthOfFieldEffect;
  112445. /**
  112446. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  112447. */
  112448. fxaa: FxaaPostProcess;
  112449. /**
  112450. * Image post processing pass used to perform operations such as tone mapping or color grading.
  112451. */
  112452. imageProcessing: ImageProcessingPostProcess;
  112453. /**
  112454. * Chromatic aberration post process which will shift rgb colors in the image
  112455. */
  112456. chromaticAberration: ChromaticAberrationPostProcess;
  112457. private _chromaticAberrationEffect;
  112458. /**
  112459. * Grain post process which add noise to the image
  112460. */
  112461. grain: GrainPostProcess;
  112462. private _grainEffect;
  112463. /**
  112464. * Glow post process which adds a glow to emissive areas of the image
  112465. */
  112466. private _glowLayer;
  112467. /**
  112468. * Animations which can be used to tweak settings over a period of time
  112469. */
  112470. animations: Animation[];
  112471. private _imageProcessingConfigurationObserver;
  112472. private _sharpenEnabled;
  112473. private _bloomEnabled;
  112474. private _depthOfFieldEnabled;
  112475. private _depthOfFieldBlurLevel;
  112476. private _fxaaEnabled;
  112477. private _imageProcessingEnabled;
  112478. private _defaultPipelineTextureType;
  112479. private _bloomScale;
  112480. private _chromaticAberrationEnabled;
  112481. private _grainEnabled;
  112482. private _buildAllowed;
  112483. /**
  112484. * Gets active scene
  112485. */
  112486. readonly scene: Scene;
  112487. /**
  112488. * Enable or disable the sharpen process from the pipeline
  112489. */
  112490. sharpenEnabled: boolean;
  112491. private _resizeObserver;
  112492. private _hardwareScaleLevel;
  112493. private _bloomKernel;
  112494. /**
  112495. * Specifies the size of the bloom blur kernel, relative to the final output size
  112496. */
  112497. bloomKernel: number;
  112498. /**
  112499. * Specifies the weight of the bloom in the final rendering
  112500. */
  112501. private _bloomWeight;
  112502. /**
  112503. * Specifies the luma threshold for the area that will be blurred by the bloom
  112504. */
  112505. private _bloomThreshold;
  112506. private _hdr;
  112507. /**
  112508. * The strength of the bloom.
  112509. */
  112510. bloomWeight: number;
  112511. /**
  112512. * The strength of the bloom.
  112513. */
  112514. bloomThreshold: number;
  112515. /**
  112516. * The scale of the bloom, lower value will provide better performance.
  112517. */
  112518. bloomScale: number;
  112519. /**
  112520. * Enable or disable the bloom from the pipeline
  112521. */
  112522. bloomEnabled: boolean;
  112523. private _rebuildBloom;
  112524. /**
  112525. * If the depth of field is enabled.
  112526. */
  112527. depthOfFieldEnabled: boolean;
  112528. /**
  112529. * Blur level of the depth of field effect. (Higher blur will effect performance)
  112530. */
  112531. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  112532. /**
  112533. * If the anti aliasing is enabled.
  112534. */
  112535. fxaaEnabled: boolean;
  112536. private _samples;
  112537. /**
  112538. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  112539. */
  112540. samples: number;
  112541. /**
  112542. * If image processing is enabled.
  112543. */
  112544. imageProcessingEnabled: boolean;
  112545. /**
  112546. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  112547. */
  112548. glowLayerEnabled: boolean;
  112549. /**
  112550. * Enable or disable the chromaticAberration process from the pipeline
  112551. */
  112552. chromaticAberrationEnabled: boolean;
  112553. /**
  112554. * Enable or disable the grain process from the pipeline
  112555. */
  112556. grainEnabled: boolean;
  112557. /**
  112558. * @constructor
  112559. * @param name - The rendering pipeline name (default: "")
  112560. * @param hdr - If high dynamic range textures should be used (default: true)
  112561. * @param scene - The scene linked to this pipeline (default: the last created scene)
  112562. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  112563. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  112564. */
  112565. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  112566. /**
  112567. * Get the class name
  112568. * @returns "DefaultRenderingPipeline"
  112569. */
  112570. getClassName(): string;
  112571. /**
  112572. * Force the compilation of the entire pipeline.
  112573. */
  112574. prepare(): void;
  112575. private _hasCleared;
  112576. private _prevPostProcess;
  112577. private _prevPrevPostProcess;
  112578. private _setAutoClearAndTextureSharing;
  112579. private _depthOfFieldSceneObserver;
  112580. private _buildPipeline;
  112581. private _disposePostProcesses;
  112582. /**
  112583. * Adds a camera to the pipeline
  112584. * @param camera the camera to be added
  112585. */
  112586. addCamera(camera: Camera): void;
  112587. /**
  112588. * Removes a camera from the pipeline
  112589. * @param camera the camera to remove
  112590. */
  112591. removeCamera(camera: Camera): void;
  112592. /**
  112593. * Dispose of the pipeline and stop all post processes
  112594. */
  112595. dispose(): void;
  112596. /**
  112597. * Serialize the rendering pipeline (Used when exporting)
  112598. * @returns the serialized object
  112599. */
  112600. serialize(): any;
  112601. /**
  112602. * Parse the serialized pipeline
  112603. * @param source Source pipeline.
  112604. * @param scene The scene to load the pipeline to.
  112605. * @param rootUrl The URL of the serialized pipeline.
  112606. * @returns An instantiated pipeline from the serialized object.
  112607. */
  112608. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  112609. }
  112610. }
  112611. declare module BABYLON {
  112612. /** @hidden */
  112613. export var lensHighlightsPixelShader: {
  112614. name: string;
  112615. shader: string;
  112616. };
  112617. }
  112618. declare module BABYLON {
  112619. /** @hidden */
  112620. export var depthOfFieldPixelShader: {
  112621. name: string;
  112622. shader: string;
  112623. };
  112624. }
  112625. declare module BABYLON {
  112626. /**
  112627. * BABYLON.JS Chromatic Aberration GLSL Shader
  112628. * Author: Olivier Guyot
  112629. * Separates very slightly R, G and B colors on the edges of the screen
  112630. * Inspired by Francois Tarlier & Martins Upitis
  112631. */
  112632. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  112633. /**
  112634. * @ignore
  112635. * The chromatic aberration PostProcess id in the pipeline
  112636. */
  112637. LensChromaticAberrationEffect: string;
  112638. /**
  112639. * @ignore
  112640. * The highlights enhancing PostProcess id in the pipeline
  112641. */
  112642. HighlightsEnhancingEffect: string;
  112643. /**
  112644. * @ignore
  112645. * The depth-of-field PostProcess id in the pipeline
  112646. */
  112647. LensDepthOfFieldEffect: string;
  112648. private _scene;
  112649. private _depthTexture;
  112650. private _grainTexture;
  112651. private _chromaticAberrationPostProcess;
  112652. private _highlightsPostProcess;
  112653. private _depthOfFieldPostProcess;
  112654. private _edgeBlur;
  112655. private _grainAmount;
  112656. private _chromaticAberration;
  112657. private _distortion;
  112658. private _highlightsGain;
  112659. private _highlightsThreshold;
  112660. private _dofDistance;
  112661. private _dofAperture;
  112662. private _dofDarken;
  112663. private _dofPentagon;
  112664. private _blurNoise;
  112665. /**
  112666. * @constructor
  112667. *
  112668. * Effect parameters are as follow:
  112669. * {
  112670. * chromatic_aberration: number; // from 0 to x (1 for realism)
  112671. * edge_blur: number; // from 0 to x (1 for realism)
  112672. * distortion: number; // from 0 to x (1 for realism)
  112673. * grain_amount: number; // from 0 to 1
  112674. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  112675. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  112676. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  112677. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  112678. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  112679. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  112680. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  112681. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  112682. * }
  112683. * Note: if an effect parameter is unset, effect is disabled
  112684. *
  112685. * @param name The rendering pipeline name
  112686. * @param parameters - An object containing all parameters (see above)
  112687. * @param scene The scene linked to this pipeline
  112688. * @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)
  112689. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112690. */
  112691. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  112692. /**
  112693. * Get the class name
  112694. * @returns "LensRenderingPipeline"
  112695. */
  112696. getClassName(): string;
  112697. /**
  112698. * Gets associated scene
  112699. */
  112700. readonly scene: Scene;
  112701. /**
  112702. * Gets or sets the edge blur
  112703. */
  112704. edgeBlur: number;
  112705. /**
  112706. * Gets or sets the grain amount
  112707. */
  112708. grainAmount: number;
  112709. /**
  112710. * Gets or sets the chromatic aberration amount
  112711. */
  112712. chromaticAberration: number;
  112713. /**
  112714. * Gets or sets the depth of field aperture
  112715. */
  112716. dofAperture: number;
  112717. /**
  112718. * Gets or sets the edge distortion
  112719. */
  112720. edgeDistortion: number;
  112721. /**
  112722. * Gets or sets the depth of field distortion
  112723. */
  112724. dofDistortion: number;
  112725. /**
  112726. * Gets or sets the darken out of focus amount
  112727. */
  112728. darkenOutOfFocus: number;
  112729. /**
  112730. * Gets or sets a boolean indicating if blur noise is enabled
  112731. */
  112732. blurNoise: boolean;
  112733. /**
  112734. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  112735. */
  112736. pentagonBokeh: boolean;
  112737. /**
  112738. * Gets or sets the highlight grain amount
  112739. */
  112740. highlightsGain: number;
  112741. /**
  112742. * Gets or sets the highlight threshold
  112743. */
  112744. highlightsThreshold: number;
  112745. /**
  112746. * Sets the amount of blur at the edges
  112747. * @param amount blur amount
  112748. */
  112749. setEdgeBlur(amount: number): void;
  112750. /**
  112751. * Sets edge blur to 0
  112752. */
  112753. disableEdgeBlur(): void;
  112754. /**
  112755. * Sets the amout of grain
  112756. * @param amount Amount of grain
  112757. */
  112758. setGrainAmount(amount: number): void;
  112759. /**
  112760. * Set grain amount to 0
  112761. */
  112762. disableGrain(): void;
  112763. /**
  112764. * Sets the chromatic aberration amount
  112765. * @param amount amount of chromatic aberration
  112766. */
  112767. setChromaticAberration(amount: number): void;
  112768. /**
  112769. * Sets chromatic aberration amount to 0
  112770. */
  112771. disableChromaticAberration(): void;
  112772. /**
  112773. * Sets the EdgeDistortion amount
  112774. * @param amount amount of EdgeDistortion
  112775. */
  112776. setEdgeDistortion(amount: number): void;
  112777. /**
  112778. * Sets edge distortion to 0
  112779. */
  112780. disableEdgeDistortion(): void;
  112781. /**
  112782. * Sets the FocusDistance amount
  112783. * @param amount amount of FocusDistance
  112784. */
  112785. setFocusDistance(amount: number): void;
  112786. /**
  112787. * Disables depth of field
  112788. */
  112789. disableDepthOfField(): void;
  112790. /**
  112791. * Sets the Aperture amount
  112792. * @param amount amount of Aperture
  112793. */
  112794. setAperture(amount: number): void;
  112795. /**
  112796. * Sets the DarkenOutOfFocus amount
  112797. * @param amount amount of DarkenOutOfFocus
  112798. */
  112799. setDarkenOutOfFocus(amount: number): void;
  112800. private _pentagonBokehIsEnabled;
  112801. /**
  112802. * Creates a pentagon bokeh effect
  112803. */
  112804. enablePentagonBokeh(): void;
  112805. /**
  112806. * Disables the pentagon bokeh effect
  112807. */
  112808. disablePentagonBokeh(): void;
  112809. /**
  112810. * Enables noise blur
  112811. */
  112812. enableNoiseBlur(): void;
  112813. /**
  112814. * Disables noise blur
  112815. */
  112816. disableNoiseBlur(): void;
  112817. /**
  112818. * Sets the HighlightsGain amount
  112819. * @param amount amount of HighlightsGain
  112820. */
  112821. setHighlightsGain(amount: number): void;
  112822. /**
  112823. * Sets the HighlightsThreshold amount
  112824. * @param amount amount of HighlightsThreshold
  112825. */
  112826. setHighlightsThreshold(amount: number): void;
  112827. /**
  112828. * Disables highlights
  112829. */
  112830. disableHighlights(): void;
  112831. /**
  112832. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  112833. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  112834. */
  112835. dispose(disableDepthRender?: boolean): void;
  112836. private _createChromaticAberrationPostProcess;
  112837. private _createHighlightsPostProcess;
  112838. private _createDepthOfFieldPostProcess;
  112839. private _createGrainTexture;
  112840. }
  112841. }
  112842. declare module BABYLON {
  112843. /** @hidden */
  112844. export var ssao2PixelShader: {
  112845. name: string;
  112846. shader: string;
  112847. };
  112848. }
  112849. declare module BABYLON {
  112850. /** @hidden */
  112851. export var ssaoCombinePixelShader: {
  112852. name: string;
  112853. shader: string;
  112854. };
  112855. }
  112856. declare module BABYLON {
  112857. /**
  112858. * Render pipeline to produce ssao effect
  112859. */
  112860. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  112861. /**
  112862. * @ignore
  112863. * The PassPostProcess id in the pipeline that contains the original scene color
  112864. */
  112865. SSAOOriginalSceneColorEffect: string;
  112866. /**
  112867. * @ignore
  112868. * The SSAO PostProcess id in the pipeline
  112869. */
  112870. SSAORenderEffect: string;
  112871. /**
  112872. * @ignore
  112873. * The horizontal blur PostProcess id in the pipeline
  112874. */
  112875. SSAOBlurHRenderEffect: string;
  112876. /**
  112877. * @ignore
  112878. * The vertical blur PostProcess id in the pipeline
  112879. */
  112880. SSAOBlurVRenderEffect: string;
  112881. /**
  112882. * @ignore
  112883. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  112884. */
  112885. SSAOCombineRenderEffect: string;
  112886. /**
  112887. * The output strength of the SSAO post-process. Default value is 1.0.
  112888. */
  112889. totalStrength: number;
  112890. /**
  112891. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  112892. */
  112893. maxZ: number;
  112894. /**
  112895. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  112896. */
  112897. minZAspect: number;
  112898. private _samples;
  112899. /**
  112900. * Number of samples used for the SSAO calculations. Default value is 8
  112901. */
  112902. samples: number;
  112903. private _textureSamples;
  112904. /**
  112905. * Number of samples to use for antialiasing
  112906. */
  112907. textureSamples: number;
  112908. /**
  112909. * Ratio object used for SSAO ratio and blur ratio
  112910. */
  112911. private _ratio;
  112912. /**
  112913. * Dynamically generated sphere sampler.
  112914. */
  112915. private _sampleSphere;
  112916. /**
  112917. * Blur filter offsets
  112918. */
  112919. private _samplerOffsets;
  112920. private _expensiveBlur;
  112921. /**
  112922. * If bilateral blur should be used
  112923. */
  112924. expensiveBlur: boolean;
  112925. /**
  112926. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  112927. */
  112928. radius: number;
  112929. /**
  112930. * The base color of the SSAO post-process
  112931. * The final result is "base + ssao" between [0, 1]
  112932. */
  112933. base: number;
  112934. /**
  112935. * Support test.
  112936. */
  112937. static readonly IsSupported: boolean;
  112938. private _scene;
  112939. private _depthTexture;
  112940. private _normalTexture;
  112941. private _randomTexture;
  112942. private _originalColorPostProcess;
  112943. private _ssaoPostProcess;
  112944. private _blurHPostProcess;
  112945. private _blurVPostProcess;
  112946. private _ssaoCombinePostProcess;
  112947. private _firstUpdate;
  112948. /**
  112949. * Gets active scene
  112950. */
  112951. readonly scene: Scene;
  112952. /**
  112953. * @constructor
  112954. * @param name The rendering pipeline name
  112955. * @param scene The scene linked to this pipeline
  112956. * @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 }
  112957. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112958. */
  112959. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  112960. /**
  112961. * Get the class name
  112962. * @returns "SSAO2RenderingPipeline"
  112963. */
  112964. getClassName(): string;
  112965. /**
  112966. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  112967. */
  112968. dispose(disableGeometryBufferRenderer?: boolean): void;
  112969. private _createBlurPostProcess;
  112970. /** @hidden */
  112971. _rebuild(): void;
  112972. private _bits;
  112973. private _radicalInverse_VdC;
  112974. private _hammersley;
  112975. private _hemisphereSample_uniform;
  112976. private _generateHemisphere;
  112977. private _createSSAOPostProcess;
  112978. private _createSSAOCombinePostProcess;
  112979. private _createRandomTexture;
  112980. /**
  112981. * Serialize the rendering pipeline (Used when exporting)
  112982. * @returns the serialized object
  112983. */
  112984. serialize(): any;
  112985. /**
  112986. * Parse the serialized pipeline
  112987. * @param source Source pipeline.
  112988. * @param scene The scene to load the pipeline to.
  112989. * @param rootUrl The URL of the serialized pipeline.
  112990. * @returns An instantiated pipeline from the serialized object.
  112991. */
  112992. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  112993. }
  112994. }
  112995. declare module BABYLON {
  112996. /** @hidden */
  112997. export var ssaoPixelShader: {
  112998. name: string;
  112999. shader: string;
  113000. };
  113001. }
  113002. declare module BABYLON {
  113003. /**
  113004. * Render pipeline to produce ssao effect
  113005. */
  113006. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  113007. /**
  113008. * @ignore
  113009. * The PassPostProcess id in the pipeline that contains the original scene color
  113010. */
  113011. SSAOOriginalSceneColorEffect: string;
  113012. /**
  113013. * @ignore
  113014. * The SSAO PostProcess id in the pipeline
  113015. */
  113016. SSAORenderEffect: string;
  113017. /**
  113018. * @ignore
  113019. * The horizontal blur PostProcess id in the pipeline
  113020. */
  113021. SSAOBlurHRenderEffect: string;
  113022. /**
  113023. * @ignore
  113024. * The vertical blur PostProcess id in the pipeline
  113025. */
  113026. SSAOBlurVRenderEffect: string;
  113027. /**
  113028. * @ignore
  113029. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113030. */
  113031. SSAOCombineRenderEffect: string;
  113032. /**
  113033. * The output strength of the SSAO post-process. Default value is 1.0.
  113034. */
  113035. totalStrength: number;
  113036. /**
  113037. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  113038. */
  113039. radius: number;
  113040. /**
  113041. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  113042. * Must not be equal to fallOff and superior to fallOff.
  113043. * Default value is 0.0075
  113044. */
  113045. area: number;
  113046. /**
  113047. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  113048. * Must not be equal to area and inferior to area.
  113049. * Default value is 0.000001
  113050. */
  113051. fallOff: number;
  113052. /**
  113053. * The base color of the SSAO post-process
  113054. * The final result is "base + ssao" between [0, 1]
  113055. */
  113056. base: number;
  113057. private _scene;
  113058. private _depthTexture;
  113059. private _randomTexture;
  113060. private _originalColorPostProcess;
  113061. private _ssaoPostProcess;
  113062. private _blurHPostProcess;
  113063. private _blurVPostProcess;
  113064. private _ssaoCombinePostProcess;
  113065. private _firstUpdate;
  113066. /**
  113067. * Gets active scene
  113068. */
  113069. readonly scene: Scene;
  113070. /**
  113071. * @constructor
  113072. * @param name - The rendering pipeline name
  113073. * @param scene - The scene linked to this pipeline
  113074. * @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 }
  113075. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  113076. */
  113077. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  113078. /**
  113079. * Get the class name
  113080. * @returns "SSAORenderingPipeline"
  113081. */
  113082. getClassName(): string;
  113083. /**
  113084. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113085. */
  113086. dispose(disableDepthRender?: boolean): void;
  113087. private _createBlurPostProcess;
  113088. /** @hidden */
  113089. _rebuild(): void;
  113090. private _createSSAOPostProcess;
  113091. private _createSSAOCombinePostProcess;
  113092. private _createRandomTexture;
  113093. }
  113094. }
  113095. declare module BABYLON {
  113096. /** @hidden */
  113097. export var standardPixelShader: {
  113098. name: string;
  113099. shader: string;
  113100. };
  113101. }
  113102. declare module BABYLON {
  113103. /**
  113104. * Standard rendering pipeline
  113105. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  113106. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  113107. */
  113108. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  113109. /**
  113110. * Public members
  113111. */
  113112. /**
  113113. * Post-process which contains the original scene color before the pipeline applies all the effects
  113114. */
  113115. originalPostProcess: Nullable<PostProcess>;
  113116. /**
  113117. * Post-process used to down scale an image x4
  113118. */
  113119. downSampleX4PostProcess: Nullable<PostProcess>;
  113120. /**
  113121. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  113122. */
  113123. brightPassPostProcess: Nullable<PostProcess>;
  113124. /**
  113125. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  113126. */
  113127. blurHPostProcesses: PostProcess[];
  113128. /**
  113129. * Post-process array storing all the vertical blur post-processes used by the pipeline
  113130. */
  113131. blurVPostProcesses: PostProcess[];
  113132. /**
  113133. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  113134. */
  113135. textureAdderPostProcess: Nullable<PostProcess>;
  113136. /**
  113137. * Post-process used to create volumetric lighting effect
  113138. */
  113139. volumetricLightPostProcess: Nullable<PostProcess>;
  113140. /**
  113141. * Post-process used to smooth the previous volumetric light post-process on the X axis
  113142. */
  113143. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  113144. /**
  113145. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  113146. */
  113147. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  113148. /**
  113149. * Post-process used to merge the volumetric light effect and the real scene color
  113150. */
  113151. volumetricLightMergePostProces: Nullable<PostProcess>;
  113152. /**
  113153. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  113154. */
  113155. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  113156. /**
  113157. * Base post-process used to calculate the average luminance of the final image for HDR
  113158. */
  113159. luminancePostProcess: Nullable<PostProcess>;
  113160. /**
  113161. * Post-processes used to create down sample post-processes in order to get
  113162. * the average luminance of the final image for HDR
  113163. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  113164. */
  113165. luminanceDownSamplePostProcesses: PostProcess[];
  113166. /**
  113167. * Post-process used to create a HDR effect (light adaptation)
  113168. */
  113169. hdrPostProcess: Nullable<PostProcess>;
  113170. /**
  113171. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  113172. */
  113173. textureAdderFinalPostProcess: Nullable<PostProcess>;
  113174. /**
  113175. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  113176. */
  113177. lensFlareFinalPostProcess: Nullable<PostProcess>;
  113178. /**
  113179. * Post-process used to merge the final HDR post-process and the real scene color
  113180. */
  113181. hdrFinalPostProcess: Nullable<PostProcess>;
  113182. /**
  113183. * Post-process used to create a lens flare effect
  113184. */
  113185. lensFlarePostProcess: Nullable<PostProcess>;
  113186. /**
  113187. * Post-process that merges the result of the lens flare post-process and the real scene color
  113188. */
  113189. lensFlareComposePostProcess: Nullable<PostProcess>;
  113190. /**
  113191. * Post-process used to create a motion blur effect
  113192. */
  113193. motionBlurPostProcess: Nullable<PostProcess>;
  113194. /**
  113195. * Post-process used to create a depth of field effect
  113196. */
  113197. depthOfFieldPostProcess: Nullable<PostProcess>;
  113198. /**
  113199. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  113200. */
  113201. fxaaPostProcess: Nullable<FxaaPostProcess>;
  113202. /**
  113203. * Represents the brightness threshold in order to configure the illuminated surfaces
  113204. */
  113205. brightThreshold: number;
  113206. /**
  113207. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  113208. */
  113209. blurWidth: number;
  113210. /**
  113211. * Sets if the blur for highlighted surfaces must be only horizontal
  113212. */
  113213. horizontalBlur: boolean;
  113214. /**
  113215. * Gets the overall exposure used by the pipeline
  113216. */
  113217. /**
  113218. * Sets the overall exposure used by the pipeline
  113219. */
  113220. exposure: number;
  113221. /**
  113222. * Texture used typically to simulate "dirty" on camera lens
  113223. */
  113224. lensTexture: Nullable<Texture>;
  113225. /**
  113226. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  113227. */
  113228. volumetricLightCoefficient: number;
  113229. /**
  113230. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  113231. */
  113232. volumetricLightPower: number;
  113233. /**
  113234. * Used the set the blur intensity to smooth the volumetric lights
  113235. */
  113236. volumetricLightBlurScale: number;
  113237. /**
  113238. * Light (spot or directional) used to generate the volumetric lights rays
  113239. * The source light must have a shadow generate so the pipeline can get its
  113240. * depth map
  113241. */
  113242. sourceLight: Nullable<SpotLight | DirectionalLight>;
  113243. /**
  113244. * For eye adaptation, represents the minimum luminance the eye can see
  113245. */
  113246. hdrMinimumLuminance: number;
  113247. /**
  113248. * For eye adaptation, represents the decrease luminance speed
  113249. */
  113250. hdrDecreaseRate: number;
  113251. /**
  113252. * For eye adaptation, represents the increase luminance speed
  113253. */
  113254. hdrIncreaseRate: number;
  113255. /**
  113256. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  113257. */
  113258. /**
  113259. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  113260. */
  113261. hdrAutoExposure: boolean;
  113262. /**
  113263. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  113264. */
  113265. lensColorTexture: Nullable<Texture>;
  113266. /**
  113267. * The overall strengh for the lens flare effect
  113268. */
  113269. lensFlareStrength: number;
  113270. /**
  113271. * Dispersion coefficient for lens flare ghosts
  113272. */
  113273. lensFlareGhostDispersal: number;
  113274. /**
  113275. * Main lens flare halo width
  113276. */
  113277. lensFlareHaloWidth: number;
  113278. /**
  113279. * Based on the lens distortion effect, defines how much the lens flare result
  113280. * is distorted
  113281. */
  113282. lensFlareDistortionStrength: number;
  113283. /**
  113284. * Lens star texture must be used to simulate rays on the flares and is available
  113285. * in the documentation
  113286. */
  113287. lensStarTexture: Nullable<Texture>;
  113288. /**
  113289. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  113290. * flare effect by taking account of the dirt texture
  113291. */
  113292. lensFlareDirtTexture: Nullable<Texture>;
  113293. /**
  113294. * Represents the focal length for the depth of field effect
  113295. */
  113296. depthOfFieldDistance: number;
  113297. /**
  113298. * Represents the blur intensity for the blurred part of the depth of field effect
  113299. */
  113300. depthOfFieldBlurWidth: number;
  113301. /**
  113302. * For motion blur, defines how much the image is blurred by the movement
  113303. */
  113304. motionStrength: number;
  113305. /**
  113306. * List of animations for the pipeline (IAnimatable implementation)
  113307. */
  113308. animations: Animation[];
  113309. /**
  113310. * Private members
  113311. */
  113312. private _scene;
  113313. private _currentDepthOfFieldSource;
  113314. private _basePostProcess;
  113315. private _fixedExposure;
  113316. private _currentExposure;
  113317. private _hdrAutoExposure;
  113318. private _hdrCurrentLuminance;
  113319. private _floatTextureType;
  113320. private _ratio;
  113321. private _bloomEnabled;
  113322. private _depthOfFieldEnabled;
  113323. private _vlsEnabled;
  113324. private _lensFlareEnabled;
  113325. private _hdrEnabled;
  113326. private _motionBlurEnabled;
  113327. private _fxaaEnabled;
  113328. private _motionBlurSamples;
  113329. private _volumetricLightStepsCount;
  113330. private _samples;
  113331. /**
  113332. * @ignore
  113333. * Specifies if the bloom pipeline is enabled
  113334. */
  113335. BloomEnabled: boolean;
  113336. /**
  113337. * @ignore
  113338. * Specifies if the depth of field pipeline is enabed
  113339. */
  113340. DepthOfFieldEnabled: boolean;
  113341. /**
  113342. * @ignore
  113343. * Specifies if the lens flare pipeline is enabed
  113344. */
  113345. LensFlareEnabled: boolean;
  113346. /**
  113347. * @ignore
  113348. * Specifies if the HDR pipeline is enabled
  113349. */
  113350. HDREnabled: boolean;
  113351. /**
  113352. * @ignore
  113353. * Specifies if the volumetric lights scattering effect is enabled
  113354. */
  113355. VLSEnabled: boolean;
  113356. /**
  113357. * @ignore
  113358. * Specifies if the motion blur effect is enabled
  113359. */
  113360. MotionBlurEnabled: boolean;
  113361. /**
  113362. * Specifies if anti-aliasing is enabled
  113363. */
  113364. fxaaEnabled: boolean;
  113365. /**
  113366. * Specifies the number of steps used to calculate the volumetric lights
  113367. * Typically in interval [50, 200]
  113368. */
  113369. volumetricLightStepsCount: number;
  113370. /**
  113371. * Specifies the number of samples used for the motion blur effect
  113372. * Typically in interval [16, 64]
  113373. */
  113374. motionBlurSamples: number;
  113375. /**
  113376. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113377. */
  113378. samples: number;
  113379. /**
  113380. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  113381. * @constructor
  113382. * @param name The rendering pipeline name
  113383. * @param scene The scene linked to this pipeline
  113384. * @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)
  113385. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  113386. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113387. */
  113388. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  113389. private _buildPipeline;
  113390. private _createDownSampleX4PostProcess;
  113391. private _createBrightPassPostProcess;
  113392. private _createBlurPostProcesses;
  113393. private _createTextureAdderPostProcess;
  113394. private _createVolumetricLightPostProcess;
  113395. private _createLuminancePostProcesses;
  113396. private _createHdrPostProcess;
  113397. private _createLensFlarePostProcess;
  113398. private _createDepthOfFieldPostProcess;
  113399. private _createMotionBlurPostProcess;
  113400. private _getDepthTexture;
  113401. private _disposePostProcesses;
  113402. /**
  113403. * Dispose of the pipeline and stop all post processes
  113404. */
  113405. dispose(): void;
  113406. /**
  113407. * Serialize the rendering pipeline (Used when exporting)
  113408. * @returns the serialized object
  113409. */
  113410. serialize(): any;
  113411. /**
  113412. * Parse the serialized pipeline
  113413. * @param source Source pipeline.
  113414. * @param scene The scene to load the pipeline to.
  113415. * @param rootUrl The URL of the serialized pipeline.
  113416. * @returns An instantiated pipeline from the serialized object.
  113417. */
  113418. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  113419. /**
  113420. * Luminance steps
  113421. */
  113422. static LuminanceSteps: number;
  113423. }
  113424. }
  113425. declare module BABYLON {
  113426. /** @hidden */
  113427. export var tonemapPixelShader: {
  113428. name: string;
  113429. shader: string;
  113430. };
  113431. }
  113432. declare module BABYLON {
  113433. /** Defines operator used for tonemapping */
  113434. export enum TonemappingOperator {
  113435. /** Hable */
  113436. Hable = 0,
  113437. /** Reinhard */
  113438. Reinhard = 1,
  113439. /** HejiDawson */
  113440. HejiDawson = 2,
  113441. /** Photographic */
  113442. Photographic = 3
  113443. }
  113444. /**
  113445. * Defines a post process to apply tone mapping
  113446. */
  113447. export class TonemapPostProcess extends PostProcess {
  113448. private _operator;
  113449. /** Defines the required exposure adjustement */
  113450. exposureAdjustment: number;
  113451. /**
  113452. * Creates a new TonemapPostProcess
  113453. * @param name defines the name of the postprocess
  113454. * @param _operator defines the operator to use
  113455. * @param exposureAdjustment defines the required exposure adjustement
  113456. * @param camera defines the camera to use (can be null)
  113457. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  113458. * @param engine defines the hosting engine (can be ignore if camera is set)
  113459. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  113460. */
  113461. constructor(name: string, _operator: TonemappingOperator,
  113462. /** Defines the required exposure adjustement */
  113463. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  113464. }
  113465. }
  113466. declare module BABYLON {
  113467. /** @hidden */
  113468. export var depthVertexShader: {
  113469. name: string;
  113470. shader: string;
  113471. };
  113472. }
  113473. declare module BABYLON {
  113474. /** @hidden */
  113475. export var volumetricLightScatteringPixelShader: {
  113476. name: string;
  113477. shader: string;
  113478. };
  113479. }
  113480. declare module BABYLON {
  113481. /** @hidden */
  113482. export var volumetricLightScatteringPassPixelShader: {
  113483. name: string;
  113484. shader: string;
  113485. };
  113486. }
  113487. declare module BABYLON {
  113488. /**
  113489. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  113490. */
  113491. export class VolumetricLightScatteringPostProcess extends PostProcess {
  113492. private _volumetricLightScatteringPass;
  113493. private _volumetricLightScatteringRTT;
  113494. private _viewPort;
  113495. private _screenCoordinates;
  113496. private _cachedDefines;
  113497. /**
  113498. * If not undefined, the mesh position is computed from the attached node position
  113499. */
  113500. attachedNode: {
  113501. position: Vector3;
  113502. };
  113503. /**
  113504. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  113505. */
  113506. customMeshPosition: Vector3;
  113507. /**
  113508. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  113509. */
  113510. useCustomMeshPosition: boolean;
  113511. /**
  113512. * If the post-process should inverse the light scattering direction
  113513. */
  113514. invert: boolean;
  113515. /**
  113516. * The internal mesh used by the post-process
  113517. */
  113518. mesh: Mesh;
  113519. /**
  113520. * @hidden
  113521. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  113522. */
  113523. useDiffuseColor: boolean;
  113524. /**
  113525. * Array containing the excluded meshes not rendered in the internal pass
  113526. */
  113527. excludedMeshes: AbstractMesh[];
  113528. /**
  113529. * Controls the overall intensity of the post-process
  113530. */
  113531. exposure: number;
  113532. /**
  113533. * Dissipates each sample's contribution in range [0, 1]
  113534. */
  113535. decay: number;
  113536. /**
  113537. * Controls the overall intensity of each sample
  113538. */
  113539. weight: number;
  113540. /**
  113541. * Controls the density of each sample
  113542. */
  113543. density: number;
  113544. /**
  113545. * @constructor
  113546. * @param name The post-process name
  113547. * @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)
  113548. * @param camera The camera that the post-process will be attached to
  113549. * @param mesh The mesh used to create the light scattering
  113550. * @param samples The post-process quality, default 100
  113551. * @param samplingModeThe post-process filtering mode
  113552. * @param engine The babylon engine
  113553. * @param reusable If the post-process is reusable
  113554. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  113555. */
  113556. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  113557. /**
  113558. * Returns the string "VolumetricLightScatteringPostProcess"
  113559. * @returns "VolumetricLightScatteringPostProcess"
  113560. */
  113561. getClassName(): string;
  113562. private _isReady;
  113563. /**
  113564. * Sets the new light position for light scattering effect
  113565. * @param position The new custom light position
  113566. */
  113567. setCustomMeshPosition(position: Vector3): void;
  113568. /**
  113569. * Returns the light position for light scattering effect
  113570. * @return Vector3 The custom light position
  113571. */
  113572. getCustomMeshPosition(): Vector3;
  113573. /**
  113574. * Disposes the internal assets and detaches the post-process from the camera
  113575. */
  113576. dispose(camera: Camera): void;
  113577. /**
  113578. * Returns the render target texture used by the post-process
  113579. * @return the render target texture used by the post-process
  113580. */
  113581. getPass(): RenderTargetTexture;
  113582. private _meshExcluded;
  113583. private _createPass;
  113584. private _updateMeshScreenCoordinates;
  113585. /**
  113586. * Creates a default mesh for the Volumeric Light Scattering post-process
  113587. * @param name The mesh name
  113588. * @param scene The scene where to create the mesh
  113589. * @return the default mesh
  113590. */
  113591. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  113592. }
  113593. }
  113594. declare module BABYLON {
  113595. interface Scene {
  113596. /** @hidden (Backing field) */
  113597. _boundingBoxRenderer: BoundingBoxRenderer;
  113598. /** @hidden (Backing field) */
  113599. _forceShowBoundingBoxes: boolean;
  113600. /**
  113601. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  113602. */
  113603. forceShowBoundingBoxes: boolean;
  113604. /**
  113605. * Gets the bounding box renderer associated with the scene
  113606. * @returns a BoundingBoxRenderer
  113607. */
  113608. getBoundingBoxRenderer(): BoundingBoxRenderer;
  113609. }
  113610. interface AbstractMesh {
  113611. /** @hidden (Backing field) */
  113612. _showBoundingBox: boolean;
  113613. /**
  113614. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  113615. */
  113616. showBoundingBox: boolean;
  113617. }
  113618. /**
  113619. * Component responsible of rendering the bounding box of the meshes in a scene.
  113620. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  113621. */
  113622. export class BoundingBoxRenderer implements ISceneComponent {
  113623. /**
  113624. * The component name helpfull to identify the component in the list of scene components.
  113625. */
  113626. readonly name: string;
  113627. /**
  113628. * The scene the component belongs to.
  113629. */
  113630. scene: Scene;
  113631. /**
  113632. * Color of the bounding box lines placed in front of an object
  113633. */
  113634. frontColor: Color3;
  113635. /**
  113636. * Color of the bounding box lines placed behind an object
  113637. */
  113638. backColor: Color3;
  113639. /**
  113640. * Defines if the renderer should show the back lines or not
  113641. */
  113642. showBackLines: boolean;
  113643. /**
  113644. * @hidden
  113645. */
  113646. renderList: SmartArray<BoundingBox>;
  113647. private _colorShader;
  113648. private _vertexBuffers;
  113649. private _indexBuffer;
  113650. /**
  113651. * Instantiates a new bounding box renderer in a scene.
  113652. * @param scene the scene the renderer renders in
  113653. */
  113654. constructor(scene: Scene);
  113655. /**
  113656. * Registers the component in a given scene
  113657. */
  113658. register(): void;
  113659. private _evaluateSubMesh;
  113660. private _activeMesh;
  113661. private _prepareRessources;
  113662. private _createIndexBuffer;
  113663. /**
  113664. * Rebuilds the elements related to this component in case of
  113665. * context lost for instance.
  113666. */
  113667. rebuild(): void;
  113668. /**
  113669. * @hidden
  113670. */
  113671. reset(): void;
  113672. /**
  113673. * Render the bounding boxes of a specific rendering group
  113674. * @param renderingGroupId defines the rendering group to render
  113675. */
  113676. render(renderingGroupId: number): void;
  113677. /**
  113678. * In case of occlusion queries, we can render the occlusion bounding box through this method
  113679. * @param mesh Define the mesh to render the occlusion bounding box for
  113680. */
  113681. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  113682. /**
  113683. * Dispose and release the resources attached to this renderer.
  113684. */
  113685. dispose(): void;
  113686. }
  113687. }
  113688. declare module BABYLON {
  113689. /** @hidden */
  113690. export var depthPixelShader: {
  113691. name: string;
  113692. shader: string;
  113693. };
  113694. }
  113695. declare module BABYLON {
  113696. /**
  113697. * This represents a depth renderer in Babylon.
  113698. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  113699. */
  113700. export class DepthRenderer {
  113701. private _scene;
  113702. private _depthMap;
  113703. private _effect;
  113704. private _cachedDefines;
  113705. private _camera;
  113706. /**
  113707. * Specifiess that the depth renderer will only be used within
  113708. * the camera it is created for.
  113709. * This can help forcing its rendering during the camera processing.
  113710. */
  113711. useOnlyInActiveCamera: boolean;
  113712. /** @hidden */
  113713. static _SceneComponentInitialization: (scene: Scene) => void;
  113714. /**
  113715. * Instantiates a depth renderer
  113716. * @param scene The scene the renderer belongs to
  113717. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  113718. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  113719. */
  113720. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  113721. /**
  113722. * Creates the depth rendering effect and checks if the effect is ready.
  113723. * @param subMesh The submesh to be used to render the depth map of
  113724. * @param useInstances If multiple world instances should be used
  113725. * @returns if the depth renderer is ready to render the depth map
  113726. */
  113727. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113728. /**
  113729. * Gets the texture which the depth map will be written to.
  113730. * @returns The depth map texture
  113731. */
  113732. getDepthMap(): RenderTargetTexture;
  113733. /**
  113734. * Disposes of the depth renderer.
  113735. */
  113736. dispose(): void;
  113737. }
  113738. }
  113739. declare module BABYLON {
  113740. interface Scene {
  113741. /** @hidden (Backing field) */
  113742. _depthRenderer: {
  113743. [id: string]: DepthRenderer;
  113744. };
  113745. /**
  113746. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  113747. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  113748. * @returns the created depth renderer
  113749. */
  113750. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  113751. /**
  113752. * Disables a depth renderer for a given camera
  113753. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  113754. */
  113755. disableDepthRenderer(camera?: Nullable<Camera>): void;
  113756. }
  113757. /**
  113758. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  113759. * in several rendering techniques.
  113760. */
  113761. export class DepthRendererSceneComponent implements ISceneComponent {
  113762. /**
  113763. * The component name helpfull to identify the component in the list of scene components.
  113764. */
  113765. readonly name: string;
  113766. /**
  113767. * The scene the component belongs to.
  113768. */
  113769. scene: Scene;
  113770. /**
  113771. * Creates a new instance of the component for the given scene
  113772. * @param scene Defines the scene to register the component in
  113773. */
  113774. constructor(scene: Scene);
  113775. /**
  113776. * Registers the component in a given scene
  113777. */
  113778. register(): void;
  113779. /**
  113780. * Rebuilds the elements related to this component in case of
  113781. * context lost for instance.
  113782. */
  113783. rebuild(): void;
  113784. /**
  113785. * Disposes the component and the associated ressources
  113786. */
  113787. dispose(): void;
  113788. private _gatherRenderTargets;
  113789. private _gatherActiveCameraRenderTargets;
  113790. }
  113791. }
  113792. declare module BABYLON {
  113793. /** @hidden */
  113794. export var outlinePixelShader: {
  113795. name: string;
  113796. shader: string;
  113797. };
  113798. }
  113799. declare module BABYLON {
  113800. /** @hidden */
  113801. export var outlineVertexShader: {
  113802. name: string;
  113803. shader: string;
  113804. };
  113805. }
  113806. declare module BABYLON {
  113807. interface Scene {
  113808. /** @hidden */
  113809. _outlineRenderer: OutlineRenderer;
  113810. /**
  113811. * Gets the outline renderer associated with the scene
  113812. * @returns a OutlineRenderer
  113813. */
  113814. getOutlineRenderer(): OutlineRenderer;
  113815. }
  113816. interface AbstractMesh {
  113817. /** @hidden (Backing field) */
  113818. _renderOutline: boolean;
  113819. /**
  113820. * Gets or sets a boolean indicating if the outline must be rendered as well
  113821. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  113822. */
  113823. renderOutline: boolean;
  113824. /** @hidden (Backing field) */
  113825. _renderOverlay: boolean;
  113826. /**
  113827. * Gets or sets a boolean indicating if the overlay must be rendered as well
  113828. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  113829. */
  113830. renderOverlay: boolean;
  113831. }
  113832. /**
  113833. * This class is responsible to draw bothe outline/overlay of meshes.
  113834. * It should not be used directly but through the available method on mesh.
  113835. */
  113836. export class OutlineRenderer implements ISceneComponent {
  113837. /**
  113838. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  113839. */
  113840. private static _StencilReference;
  113841. /**
  113842. * The name of the component. Each component must have a unique name.
  113843. */
  113844. name: string;
  113845. /**
  113846. * The scene the component belongs to.
  113847. */
  113848. scene: Scene;
  113849. /**
  113850. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  113851. */
  113852. zOffset: number;
  113853. private _engine;
  113854. private _effect;
  113855. private _cachedDefines;
  113856. private _savedDepthWrite;
  113857. /**
  113858. * Instantiates a new outline renderer. (There could be only one per scene).
  113859. * @param scene Defines the scene it belongs to
  113860. */
  113861. constructor(scene: Scene);
  113862. /**
  113863. * Register the component to one instance of a scene.
  113864. */
  113865. register(): void;
  113866. /**
  113867. * Rebuilds the elements related to this component in case of
  113868. * context lost for instance.
  113869. */
  113870. rebuild(): void;
  113871. /**
  113872. * Disposes the component and the associated ressources.
  113873. */
  113874. dispose(): void;
  113875. /**
  113876. * Renders the outline in the canvas.
  113877. * @param subMesh Defines the sumesh to render
  113878. * @param batch Defines the batch of meshes in case of instances
  113879. * @param useOverlay Defines if the rendering is for the overlay or the outline
  113880. */
  113881. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  113882. /**
  113883. * Returns whether or not the outline renderer is ready for a given submesh.
  113884. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  113885. * @param subMesh Defines the submesh to check readyness for
  113886. * @param useInstances Defines wheter wee are trying to render instances or not
  113887. * @returns true if ready otherwise false
  113888. */
  113889. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113890. private _beforeRenderingMesh;
  113891. private _afterRenderingMesh;
  113892. }
  113893. }
  113894. declare module BABYLON {
  113895. /**
  113896. * Defines the list of states available for a task inside a AssetsManager
  113897. */
  113898. export enum AssetTaskState {
  113899. /**
  113900. * Initialization
  113901. */
  113902. INIT = 0,
  113903. /**
  113904. * Running
  113905. */
  113906. RUNNING = 1,
  113907. /**
  113908. * Done
  113909. */
  113910. DONE = 2,
  113911. /**
  113912. * Error
  113913. */
  113914. ERROR = 3
  113915. }
  113916. /**
  113917. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  113918. */
  113919. export abstract class AbstractAssetTask {
  113920. /**
  113921. * Task name
  113922. */ name: string;
  113923. /**
  113924. * Callback called when the task is successful
  113925. */
  113926. onSuccess: (task: any) => void;
  113927. /**
  113928. * Callback called when the task is not successful
  113929. */
  113930. onError: (task: any, message?: string, exception?: any) => void;
  113931. /**
  113932. * Creates a new AssetsManager
  113933. * @param name defines the name of the task
  113934. */
  113935. constructor(
  113936. /**
  113937. * Task name
  113938. */ name: string);
  113939. private _isCompleted;
  113940. private _taskState;
  113941. private _errorObject;
  113942. /**
  113943. * Get if the task is completed
  113944. */
  113945. readonly isCompleted: boolean;
  113946. /**
  113947. * Gets the current state of the task
  113948. */
  113949. readonly taskState: AssetTaskState;
  113950. /**
  113951. * Gets the current error object (if task is in error)
  113952. */
  113953. readonly errorObject: {
  113954. message?: string;
  113955. exception?: any;
  113956. };
  113957. /**
  113958. * Internal only
  113959. * @hidden
  113960. */
  113961. _setErrorObject(message?: string, exception?: any): void;
  113962. /**
  113963. * Execute the current task
  113964. * @param scene defines the scene where you want your assets to be loaded
  113965. * @param onSuccess is a callback called when the task is successfully executed
  113966. * @param onError is a callback called if an error occurs
  113967. */
  113968. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113969. /**
  113970. * Execute the current task
  113971. * @param scene defines the scene where you want your assets to be loaded
  113972. * @param onSuccess is a callback called when the task is successfully executed
  113973. * @param onError is a callback called if an error occurs
  113974. */
  113975. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113976. /**
  113977. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  113978. * This can be used with failed tasks that have the reason for failure fixed.
  113979. */
  113980. reset(): void;
  113981. private onErrorCallback;
  113982. private onDoneCallback;
  113983. }
  113984. /**
  113985. * Define the interface used by progress events raised during assets loading
  113986. */
  113987. export interface IAssetsProgressEvent {
  113988. /**
  113989. * Defines the number of remaining tasks to process
  113990. */
  113991. remainingCount: number;
  113992. /**
  113993. * Defines the total number of tasks
  113994. */
  113995. totalCount: number;
  113996. /**
  113997. * Defines the task that was just processed
  113998. */
  113999. task: AbstractAssetTask;
  114000. }
  114001. /**
  114002. * Class used to share progress information about assets loading
  114003. */
  114004. export class AssetsProgressEvent implements IAssetsProgressEvent {
  114005. /**
  114006. * Defines the number of remaining tasks to process
  114007. */
  114008. remainingCount: number;
  114009. /**
  114010. * Defines the total number of tasks
  114011. */
  114012. totalCount: number;
  114013. /**
  114014. * Defines the task that was just processed
  114015. */
  114016. task: AbstractAssetTask;
  114017. /**
  114018. * Creates a AssetsProgressEvent
  114019. * @param remainingCount defines the number of remaining tasks to process
  114020. * @param totalCount defines the total number of tasks
  114021. * @param task defines the task that was just processed
  114022. */
  114023. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  114024. }
  114025. /**
  114026. * Define a task used by AssetsManager to load meshes
  114027. */
  114028. export class MeshAssetTask extends AbstractAssetTask {
  114029. /**
  114030. * Defines the name of the task
  114031. */
  114032. name: string;
  114033. /**
  114034. * Defines the list of mesh's names you want to load
  114035. */
  114036. meshesNames: any;
  114037. /**
  114038. * Defines the root url to use as a base to load your meshes and associated resources
  114039. */
  114040. rootUrl: string;
  114041. /**
  114042. * Defines the filename of the scene to load from
  114043. */
  114044. sceneFilename: string;
  114045. /**
  114046. * Gets the list of loaded meshes
  114047. */
  114048. loadedMeshes: Array<AbstractMesh>;
  114049. /**
  114050. * Gets the list of loaded particle systems
  114051. */
  114052. loadedParticleSystems: Array<IParticleSystem>;
  114053. /**
  114054. * Gets the list of loaded skeletons
  114055. */
  114056. loadedSkeletons: Array<Skeleton>;
  114057. /**
  114058. * Gets the list of loaded animation groups
  114059. */
  114060. loadedAnimationGroups: Array<AnimationGroup>;
  114061. /**
  114062. * Callback called when the task is successful
  114063. */
  114064. onSuccess: (task: MeshAssetTask) => void;
  114065. /**
  114066. * Callback called when the task is successful
  114067. */
  114068. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  114069. /**
  114070. * Creates a new MeshAssetTask
  114071. * @param name defines the name of the task
  114072. * @param meshesNames defines the list of mesh's names you want to load
  114073. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  114074. * @param sceneFilename defines the filename of the scene to load from
  114075. */
  114076. constructor(
  114077. /**
  114078. * Defines the name of the task
  114079. */
  114080. name: string,
  114081. /**
  114082. * Defines the list of mesh's names you want to load
  114083. */
  114084. meshesNames: any,
  114085. /**
  114086. * Defines the root url to use as a base to load your meshes and associated resources
  114087. */
  114088. rootUrl: string,
  114089. /**
  114090. * Defines the filename of the scene to load from
  114091. */
  114092. sceneFilename: string);
  114093. /**
  114094. * Execute the current task
  114095. * @param scene defines the scene where you want your assets to be loaded
  114096. * @param onSuccess is a callback called when the task is successfully executed
  114097. * @param onError is a callback called if an error occurs
  114098. */
  114099. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114100. }
  114101. /**
  114102. * Define a task used by AssetsManager to load text content
  114103. */
  114104. export class TextFileAssetTask extends AbstractAssetTask {
  114105. /**
  114106. * Defines the name of the task
  114107. */
  114108. name: string;
  114109. /**
  114110. * Defines the location of the file to load
  114111. */
  114112. url: string;
  114113. /**
  114114. * Gets the loaded text string
  114115. */
  114116. text: string;
  114117. /**
  114118. * Callback called when the task is successful
  114119. */
  114120. onSuccess: (task: TextFileAssetTask) => void;
  114121. /**
  114122. * Callback called when the task is successful
  114123. */
  114124. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  114125. /**
  114126. * Creates a new TextFileAssetTask object
  114127. * @param name defines the name of the task
  114128. * @param url defines the location of the file to load
  114129. */
  114130. constructor(
  114131. /**
  114132. * Defines the name of the task
  114133. */
  114134. name: string,
  114135. /**
  114136. * Defines the location of the file to load
  114137. */
  114138. url: string);
  114139. /**
  114140. * Execute the current task
  114141. * @param scene defines the scene where you want your assets to be loaded
  114142. * @param onSuccess is a callback called when the task is successfully executed
  114143. * @param onError is a callback called if an error occurs
  114144. */
  114145. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114146. }
  114147. /**
  114148. * Define a task used by AssetsManager to load binary data
  114149. */
  114150. export class BinaryFileAssetTask extends AbstractAssetTask {
  114151. /**
  114152. * Defines the name of the task
  114153. */
  114154. name: string;
  114155. /**
  114156. * Defines the location of the file to load
  114157. */
  114158. url: string;
  114159. /**
  114160. * Gets the lodaded data (as an array buffer)
  114161. */
  114162. data: ArrayBuffer;
  114163. /**
  114164. * Callback called when the task is successful
  114165. */
  114166. onSuccess: (task: BinaryFileAssetTask) => void;
  114167. /**
  114168. * Callback called when the task is successful
  114169. */
  114170. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  114171. /**
  114172. * Creates a new BinaryFileAssetTask object
  114173. * @param name defines the name of the new task
  114174. * @param url defines the location of the file to load
  114175. */
  114176. constructor(
  114177. /**
  114178. * Defines the name of the task
  114179. */
  114180. name: string,
  114181. /**
  114182. * Defines the location of the file to load
  114183. */
  114184. url: string);
  114185. /**
  114186. * Execute the current task
  114187. * @param scene defines the scene where you want your assets to be loaded
  114188. * @param onSuccess is a callback called when the task is successfully executed
  114189. * @param onError is a callback called if an error occurs
  114190. */
  114191. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114192. }
  114193. /**
  114194. * Define a task used by AssetsManager to load images
  114195. */
  114196. export class ImageAssetTask extends AbstractAssetTask {
  114197. /**
  114198. * Defines the name of the task
  114199. */
  114200. name: string;
  114201. /**
  114202. * Defines the location of the image to load
  114203. */
  114204. url: string;
  114205. /**
  114206. * Gets the loaded images
  114207. */
  114208. image: HTMLImageElement;
  114209. /**
  114210. * Callback called when the task is successful
  114211. */
  114212. onSuccess: (task: ImageAssetTask) => void;
  114213. /**
  114214. * Callback called when the task is successful
  114215. */
  114216. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  114217. /**
  114218. * Creates a new ImageAssetTask
  114219. * @param name defines the name of the task
  114220. * @param url defines the location of the image to load
  114221. */
  114222. constructor(
  114223. /**
  114224. * Defines the name of the task
  114225. */
  114226. name: string,
  114227. /**
  114228. * Defines the location of the image to load
  114229. */
  114230. url: string);
  114231. /**
  114232. * Execute the current task
  114233. * @param scene defines the scene where you want your assets to be loaded
  114234. * @param onSuccess is a callback called when the task is successfully executed
  114235. * @param onError is a callback called if an error occurs
  114236. */
  114237. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114238. }
  114239. /**
  114240. * Defines the interface used by texture loading tasks
  114241. */
  114242. export interface ITextureAssetTask<TEX extends BaseTexture> {
  114243. /**
  114244. * Gets the loaded texture
  114245. */
  114246. texture: TEX;
  114247. }
  114248. /**
  114249. * Define a task used by AssetsManager to load 2D textures
  114250. */
  114251. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  114252. /**
  114253. * Defines the name of the task
  114254. */
  114255. name: string;
  114256. /**
  114257. * Defines the location of the file to load
  114258. */
  114259. url: string;
  114260. /**
  114261. * Defines if mipmap should not be generated (default is false)
  114262. */
  114263. noMipmap?: boolean | undefined;
  114264. /**
  114265. * Defines if texture must be inverted on Y axis (default is false)
  114266. */
  114267. invertY?: boolean | undefined;
  114268. /**
  114269. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114270. */
  114271. samplingMode: number;
  114272. /**
  114273. * Gets the loaded texture
  114274. */
  114275. texture: Texture;
  114276. /**
  114277. * Callback called when the task is successful
  114278. */
  114279. onSuccess: (task: TextureAssetTask) => void;
  114280. /**
  114281. * Callback called when the task is successful
  114282. */
  114283. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  114284. /**
  114285. * Creates a new TextureAssetTask object
  114286. * @param name defines the name of the task
  114287. * @param url defines the location of the file to load
  114288. * @param noMipmap defines if mipmap should not be generated (default is false)
  114289. * @param invertY defines if texture must be inverted on Y axis (default is false)
  114290. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114291. */
  114292. constructor(
  114293. /**
  114294. * Defines the name of the task
  114295. */
  114296. name: string,
  114297. /**
  114298. * Defines the location of the file to load
  114299. */
  114300. url: string,
  114301. /**
  114302. * Defines if mipmap should not be generated (default is false)
  114303. */
  114304. noMipmap?: boolean | undefined,
  114305. /**
  114306. * Defines if texture must be inverted on Y axis (default is false)
  114307. */
  114308. invertY?: boolean | undefined,
  114309. /**
  114310. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114311. */
  114312. samplingMode?: number);
  114313. /**
  114314. * Execute the current task
  114315. * @param scene defines the scene where you want your assets to be loaded
  114316. * @param onSuccess is a callback called when the task is successfully executed
  114317. * @param onError is a callback called if an error occurs
  114318. */
  114319. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114320. }
  114321. /**
  114322. * Define a task used by AssetsManager to load cube textures
  114323. */
  114324. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  114325. /**
  114326. * Defines the name of the task
  114327. */
  114328. name: string;
  114329. /**
  114330. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114331. */
  114332. url: string;
  114333. /**
  114334. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114335. */
  114336. extensions?: string[] | undefined;
  114337. /**
  114338. * Defines if mipmaps should not be generated (default is false)
  114339. */
  114340. noMipmap?: boolean | undefined;
  114341. /**
  114342. * Defines the explicit list of files (undefined by default)
  114343. */
  114344. files?: string[] | undefined;
  114345. /**
  114346. * Gets the loaded texture
  114347. */
  114348. texture: CubeTexture;
  114349. /**
  114350. * Callback called when the task is successful
  114351. */
  114352. onSuccess: (task: CubeTextureAssetTask) => void;
  114353. /**
  114354. * Callback called when the task is successful
  114355. */
  114356. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  114357. /**
  114358. * Creates a new CubeTextureAssetTask
  114359. * @param name defines the name of the task
  114360. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114361. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114362. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114363. * @param files defines the explicit list of files (undefined by default)
  114364. */
  114365. constructor(
  114366. /**
  114367. * Defines the name of the task
  114368. */
  114369. name: string,
  114370. /**
  114371. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114372. */
  114373. url: string,
  114374. /**
  114375. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114376. */
  114377. extensions?: string[] | undefined,
  114378. /**
  114379. * Defines if mipmaps should not be generated (default is false)
  114380. */
  114381. noMipmap?: boolean | undefined,
  114382. /**
  114383. * Defines the explicit list of files (undefined by default)
  114384. */
  114385. files?: string[] | undefined);
  114386. /**
  114387. * Execute the current task
  114388. * @param scene defines the scene where you want your assets to be loaded
  114389. * @param onSuccess is a callback called when the task is successfully executed
  114390. * @param onError is a callback called if an error occurs
  114391. */
  114392. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114393. }
  114394. /**
  114395. * Define a task used by AssetsManager to load HDR cube textures
  114396. */
  114397. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  114398. /**
  114399. * Defines the name of the task
  114400. */
  114401. name: string;
  114402. /**
  114403. * Defines the location of the file to load
  114404. */
  114405. url: string;
  114406. /**
  114407. * Defines the desired size (the more it increases the longer the generation will be)
  114408. */
  114409. size: number;
  114410. /**
  114411. * Defines if mipmaps should not be generated (default is false)
  114412. */
  114413. noMipmap: boolean;
  114414. /**
  114415. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114416. */
  114417. generateHarmonics: boolean;
  114418. /**
  114419. * 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)
  114420. */
  114421. gammaSpace: boolean;
  114422. /**
  114423. * Internal Use Only
  114424. */
  114425. reserved: boolean;
  114426. /**
  114427. * Gets the loaded texture
  114428. */
  114429. texture: HDRCubeTexture;
  114430. /**
  114431. * Callback called when the task is successful
  114432. */
  114433. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  114434. /**
  114435. * Callback called when the task is successful
  114436. */
  114437. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  114438. /**
  114439. * Creates a new HDRCubeTextureAssetTask object
  114440. * @param name defines the name of the task
  114441. * @param url defines the location of the file to load
  114442. * @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.
  114443. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114444. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114445. * @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)
  114446. * @param reserved Internal use only
  114447. */
  114448. constructor(
  114449. /**
  114450. * Defines the name of the task
  114451. */
  114452. name: string,
  114453. /**
  114454. * Defines the location of the file to load
  114455. */
  114456. url: string,
  114457. /**
  114458. * Defines the desired size (the more it increases the longer the generation will be)
  114459. */
  114460. size: number,
  114461. /**
  114462. * Defines if mipmaps should not be generated (default is false)
  114463. */
  114464. noMipmap?: boolean,
  114465. /**
  114466. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114467. */
  114468. generateHarmonics?: boolean,
  114469. /**
  114470. * 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)
  114471. */
  114472. gammaSpace?: boolean,
  114473. /**
  114474. * Internal Use Only
  114475. */
  114476. reserved?: boolean);
  114477. /**
  114478. * Execute the current task
  114479. * @param scene defines the scene where you want your assets to be loaded
  114480. * @param onSuccess is a callback called when the task is successfully executed
  114481. * @param onError is a callback called if an error occurs
  114482. */
  114483. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114484. }
  114485. /**
  114486. * Define a task used by AssetsManager to load Equirectangular cube textures
  114487. */
  114488. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  114489. /**
  114490. * Defines the name of the task
  114491. */
  114492. name: string;
  114493. /**
  114494. * Defines the location of the file to load
  114495. */
  114496. url: string;
  114497. /**
  114498. * Defines the desired size (the more it increases the longer the generation will be)
  114499. */
  114500. size: number;
  114501. /**
  114502. * Defines if mipmaps should not be generated (default is false)
  114503. */
  114504. noMipmap: boolean;
  114505. /**
  114506. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  114507. * but the standard material would require them in Gamma space) (default is true)
  114508. */
  114509. gammaSpace: boolean;
  114510. /**
  114511. * Gets the loaded texture
  114512. */
  114513. texture: EquiRectangularCubeTexture;
  114514. /**
  114515. * Callback called when the task is successful
  114516. */
  114517. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  114518. /**
  114519. * Callback called when the task is successful
  114520. */
  114521. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  114522. /**
  114523. * Creates a new EquiRectangularCubeTextureAssetTask object
  114524. * @param name defines the name of the task
  114525. * @param url defines the location of the file to load
  114526. * @param size defines the desired size (the more it increases the longer the generation will be)
  114527. * If the size is omitted this implies you are using a preprocessed cubemap.
  114528. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114529. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  114530. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  114531. * (default is true)
  114532. */
  114533. constructor(
  114534. /**
  114535. * Defines the name of the task
  114536. */
  114537. name: string,
  114538. /**
  114539. * Defines the location of the file to load
  114540. */
  114541. url: string,
  114542. /**
  114543. * Defines the desired size (the more it increases the longer the generation will be)
  114544. */
  114545. size: number,
  114546. /**
  114547. * Defines if mipmaps should not be generated (default is false)
  114548. */
  114549. noMipmap?: boolean,
  114550. /**
  114551. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  114552. * but the standard material would require them in Gamma space) (default is true)
  114553. */
  114554. gammaSpace?: boolean);
  114555. /**
  114556. * Execute the current task
  114557. * @param scene defines the scene where you want your assets to be loaded
  114558. * @param onSuccess is a callback called when the task is successfully executed
  114559. * @param onError is a callback called if an error occurs
  114560. */
  114561. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114562. }
  114563. /**
  114564. * This class can be used to easily import assets into a scene
  114565. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  114566. */
  114567. export class AssetsManager {
  114568. private _scene;
  114569. private _isLoading;
  114570. protected _tasks: AbstractAssetTask[];
  114571. protected _waitingTasksCount: number;
  114572. protected _totalTasksCount: number;
  114573. /**
  114574. * Callback called when all tasks are processed
  114575. */
  114576. onFinish: (tasks: AbstractAssetTask[]) => void;
  114577. /**
  114578. * Callback called when a task is successful
  114579. */
  114580. onTaskSuccess: (task: AbstractAssetTask) => void;
  114581. /**
  114582. * Callback called when a task had an error
  114583. */
  114584. onTaskError: (task: AbstractAssetTask) => void;
  114585. /**
  114586. * Callback called when a task is done (whatever the result is)
  114587. */
  114588. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  114589. /**
  114590. * Observable called when all tasks are processed
  114591. */
  114592. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  114593. /**
  114594. * Observable called when a task had an error
  114595. */
  114596. onTaskErrorObservable: Observable<AbstractAssetTask>;
  114597. /**
  114598. * Observable called when all tasks were executed
  114599. */
  114600. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  114601. /**
  114602. * Observable called when a task is done (whatever the result is)
  114603. */
  114604. onProgressObservable: Observable<IAssetsProgressEvent>;
  114605. /**
  114606. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  114607. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114608. */
  114609. useDefaultLoadingScreen: boolean;
  114610. /**
  114611. * Creates a new AssetsManager
  114612. * @param scene defines the scene to work on
  114613. */
  114614. constructor(scene: Scene);
  114615. /**
  114616. * Add a MeshAssetTask to the list of active tasks
  114617. * @param taskName defines the name of the new task
  114618. * @param meshesNames defines the name of meshes to load
  114619. * @param rootUrl defines the root url to use to locate files
  114620. * @param sceneFilename defines the filename of the scene file
  114621. * @returns a new MeshAssetTask object
  114622. */
  114623. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  114624. /**
  114625. * Add a TextFileAssetTask to the list of active tasks
  114626. * @param taskName defines the name of the new task
  114627. * @param url defines the url of the file to load
  114628. * @returns a new TextFileAssetTask object
  114629. */
  114630. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  114631. /**
  114632. * Add a BinaryFileAssetTask to the list of active tasks
  114633. * @param taskName defines the name of the new task
  114634. * @param url defines the url of the file to load
  114635. * @returns a new BinaryFileAssetTask object
  114636. */
  114637. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  114638. /**
  114639. * Add a ImageAssetTask to the list of active tasks
  114640. * @param taskName defines the name of the new task
  114641. * @param url defines the url of the file to load
  114642. * @returns a new ImageAssetTask object
  114643. */
  114644. addImageTask(taskName: string, url: string): ImageAssetTask;
  114645. /**
  114646. * Add a TextureAssetTask to the list of active tasks
  114647. * @param taskName defines the name of the new task
  114648. * @param url defines the url of the file to load
  114649. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114650. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  114651. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  114652. * @returns a new TextureAssetTask object
  114653. */
  114654. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  114655. /**
  114656. * Add a CubeTextureAssetTask to the list of active tasks
  114657. * @param taskName defines the name of the new task
  114658. * @param url defines the url of the file to load
  114659. * @param extensions defines the extension to use to load the cube map (can be null)
  114660. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114661. * @param files defines the list of files to load (can be null)
  114662. * @returns a new CubeTextureAssetTask object
  114663. */
  114664. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  114665. /**
  114666. *
  114667. * Add a HDRCubeTextureAssetTask to the list of active tasks
  114668. * @param taskName defines the name of the new task
  114669. * @param url defines the url of the file to load
  114670. * @param size defines the size you want for the cubemap (can be null)
  114671. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114672. * @param generateHarmonics defines if you want to automatically generate (true by default)
  114673. * @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)
  114674. * @param reserved Internal use only
  114675. * @returns a new HDRCubeTextureAssetTask object
  114676. */
  114677. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  114678. /**
  114679. *
  114680. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  114681. * @param taskName defines the name of the new task
  114682. * @param url defines the url of the file to load
  114683. * @param size defines the size you want for the cubemap (can be null)
  114684. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114685. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  114686. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  114687. * @returns a new EquiRectangularCubeTextureAssetTask object
  114688. */
  114689. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  114690. /**
  114691. * Remove a task from the assets manager.
  114692. * @param task the task to remove
  114693. */
  114694. removeTask(task: AbstractAssetTask): void;
  114695. private _decreaseWaitingTasksCount;
  114696. private _runTask;
  114697. /**
  114698. * Reset the AssetsManager and remove all tasks
  114699. * @return the current instance of the AssetsManager
  114700. */
  114701. reset(): AssetsManager;
  114702. /**
  114703. * Start the loading process
  114704. * @return the current instance of the AssetsManager
  114705. */
  114706. load(): AssetsManager;
  114707. /**
  114708. * Start the loading process as an async operation
  114709. * @return a promise returning the list of failed tasks
  114710. */
  114711. loadAsync(): Promise<void>;
  114712. }
  114713. }
  114714. declare module BABYLON {
  114715. /**
  114716. * Wrapper class for promise with external resolve and reject.
  114717. */
  114718. export class Deferred<T> {
  114719. /**
  114720. * The promise associated with this deferred object.
  114721. */
  114722. readonly promise: Promise<T>;
  114723. private _resolve;
  114724. private _reject;
  114725. /**
  114726. * The resolve method of the promise associated with this deferred object.
  114727. */
  114728. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  114729. /**
  114730. * The reject method of the promise associated with this deferred object.
  114731. */
  114732. readonly reject: (reason?: any) => void;
  114733. /**
  114734. * Constructor for this deferred object.
  114735. */
  114736. constructor();
  114737. }
  114738. }
  114739. declare module BABYLON {
  114740. /**
  114741. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  114742. */
  114743. export class MeshExploder {
  114744. private _centerMesh;
  114745. private _meshes;
  114746. private _meshesOrigins;
  114747. private _toCenterVectors;
  114748. private _scaledDirection;
  114749. private _newPosition;
  114750. private _centerPosition;
  114751. /**
  114752. * Explodes meshes from a center mesh.
  114753. * @param meshes The meshes to explode.
  114754. * @param centerMesh The mesh to be center of explosion.
  114755. */
  114756. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  114757. private _setCenterMesh;
  114758. /**
  114759. * Get class name
  114760. * @returns "MeshExploder"
  114761. */
  114762. getClassName(): string;
  114763. /**
  114764. * "Exploded meshes"
  114765. * @returns Array of meshes with the centerMesh at index 0.
  114766. */
  114767. getMeshes(): Array<Mesh>;
  114768. /**
  114769. * Explodes meshes giving a specific direction
  114770. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  114771. */
  114772. explode(direction?: number): void;
  114773. }
  114774. }
  114775. declare module BABYLON {
  114776. /**
  114777. * Class used to help managing file picking and drag'n'drop
  114778. */
  114779. export class FilesInput {
  114780. /**
  114781. * List of files ready to be loaded
  114782. */
  114783. static readonly FilesToLoad: {
  114784. [key: string]: File;
  114785. };
  114786. /**
  114787. * Callback called when a file is processed
  114788. */
  114789. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  114790. private _engine;
  114791. private _currentScene;
  114792. private _sceneLoadedCallback;
  114793. private _progressCallback;
  114794. private _additionalRenderLoopLogicCallback;
  114795. private _textureLoadingCallback;
  114796. private _startingProcessingFilesCallback;
  114797. private _onReloadCallback;
  114798. private _errorCallback;
  114799. private _elementToMonitor;
  114800. private _sceneFileToLoad;
  114801. private _filesToLoad;
  114802. /**
  114803. * Creates a new FilesInput
  114804. * @param engine defines the rendering engine
  114805. * @param scene defines the hosting scene
  114806. * @param sceneLoadedCallback callback called when scene is loaded
  114807. * @param progressCallback callback called to track progress
  114808. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  114809. * @param textureLoadingCallback callback called when a texture is loading
  114810. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  114811. * @param onReloadCallback callback called when a reload is requested
  114812. * @param errorCallback callback call if an error occurs
  114813. */
  114814. 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);
  114815. private _dragEnterHandler;
  114816. private _dragOverHandler;
  114817. private _dropHandler;
  114818. /**
  114819. * Calls this function to listen to drag'n'drop events on a specific DOM element
  114820. * @param elementToMonitor defines the DOM element to track
  114821. */
  114822. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  114823. /**
  114824. * Release all associated resources
  114825. */
  114826. dispose(): void;
  114827. private renderFunction;
  114828. private drag;
  114829. private drop;
  114830. private _traverseFolder;
  114831. private _processFiles;
  114832. /**
  114833. * Load files from a drop event
  114834. * @param event defines the drop event to use as source
  114835. */
  114836. loadFiles(event: any): void;
  114837. private _processReload;
  114838. /**
  114839. * Reload the current scene from the loaded files
  114840. */
  114841. reload(): void;
  114842. }
  114843. }
  114844. declare module BABYLON {
  114845. /**
  114846. * Defines the root class used to create scene optimization to use with SceneOptimizer
  114847. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114848. */
  114849. export class SceneOptimization {
  114850. /**
  114851. * Defines the priority of this optimization (0 by default which means first in the list)
  114852. */
  114853. priority: number;
  114854. /**
  114855. * Gets a string describing the action executed by the current optimization
  114856. * @returns description string
  114857. */
  114858. getDescription(): string;
  114859. /**
  114860. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114861. * @param scene defines the current scene where to apply this optimization
  114862. * @param optimizer defines the current optimizer
  114863. * @returns true if everything that can be done was applied
  114864. */
  114865. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114866. /**
  114867. * Creates the SceneOptimization object
  114868. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114869. * @param desc defines the description associated with the optimization
  114870. */
  114871. constructor(
  114872. /**
  114873. * Defines the priority of this optimization (0 by default which means first in the list)
  114874. */
  114875. priority?: number);
  114876. }
  114877. /**
  114878. * Defines an optimization used to reduce the size of render target textures
  114879. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114880. */
  114881. export class TextureOptimization extends SceneOptimization {
  114882. /**
  114883. * Defines the priority of this optimization (0 by default which means first in the list)
  114884. */
  114885. priority: number;
  114886. /**
  114887. * 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
  114888. */
  114889. maximumSize: number;
  114890. /**
  114891. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114892. */
  114893. step: number;
  114894. /**
  114895. * Gets a string describing the action executed by the current optimization
  114896. * @returns description string
  114897. */
  114898. getDescription(): string;
  114899. /**
  114900. * Creates the TextureOptimization object
  114901. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114902. * @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
  114903. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114904. */
  114905. constructor(
  114906. /**
  114907. * Defines the priority of this optimization (0 by default which means first in the list)
  114908. */
  114909. priority?: number,
  114910. /**
  114911. * 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
  114912. */
  114913. maximumSize?: number,
  114914. /**
  114915. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114916. */
  114917. step?: number);
  114918. /**
  114919. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114920. * @param scene defines the current scene where to apply this optimization
  114921. * @param optimizer defines the current optimizer
  114922. * @returns true if everything that can be done was applied
  114923. */
  114924. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114925. }
  114926. /**
  114927. * Defines an optimization used to increase or decrease the rendering resolution
  114928. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114929. */
  114930. export class HardwareScalingOptimization extends SceneOptimization {
  114931. /**
  114932. * Defines the priority of this optimization (0 by default which means first in the list)
  114933. */
  114934. priority: number;
  114935. /**
  114936. * Defines the maximum scale to use (2 by default)
  114937. */
  114938. maximumScale: number;
  114939. /**
  114940. * Defines the step to use between two passes (0.5 by default)
  114941. */
  114942. step: number;
  114943. private _currentScale;
  114944. private _directionOffset;
  114945. /**
  114946. * Gets a string describing the action executed by the current optimization
  114947. * @return description string
  114948. */
  114949. getDescription(): string;
  114950. /**
  114951. * Creates the HardwareScalingOptimization object
  114952. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114953. * @param maximumScale defines the maximum scale to use (2 by default)
  114954. * @param step defines the step to use between two passes (0.5 by default)
  114955. */
  114956. constructor(
  114957. /**
  114958. * Defines the priority of this optimization (0 by default which means first in the list)
  114959. */
  114960. priority?: number,
  114961. /**
  114962. * Defines the maximum scale to use (2 by default)
  114963. */
  114964. maximumScale?: number,
  114965. /**
  114966. * Defines the step to use between two passes (0.5 by default)
  114967. */
  114968. step?: number);
  114969. /**
  114970. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114971. * @param scene defines the current scene where to apply this optimization
  114972. * @param optimizer defines the current optimizer
  114973. * @returns true if everything that can be done was applied
  114974. */
  114975. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114976. }
  114977. /**
  114978. * Defines an optimization used to remove shadows
  114979. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114980. */
  114981. export class ShadowsOptimization extends SceneOptimization {
  114982. /**
  114983. * Gets a string describing the action executed by the current optimization
  114984. * @return description string
  114985. */
  114986. getDescription(): string;
  114987. /**
  114988. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114989. * @param scene defines the current scene where to apply this optimization
  114990. * @param optimizer defines the current optimizer
  114991. * @returns true if everything that can be done was applied
  114992. */
  114993. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114994. }
  114995. /**
  114996. * Defines an optimization used to turn post-processes off
  114997. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114998. */
  114999. export class PostProcessesOptimization extends SceneOptimization {
  115000. /**
  115001. * Gets a string describing the action executed by the current optimization
  115002. * @return description string
  115003. */
  115004. getDescription(): string;
  115005. /**
  115006. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115007. * @param scene defines the current scene where to apply this optimization
  115008. * @param optimizer defines the current optimizer
  115009. * @returns true if everything that can be done was applied
  115010. */
  115011. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115012. }
  115013. /**
  115014. * Defines an optimization used to turn lens flares off
  115015. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115016. */
  115017. export class LensFlaresOptimization extends SceneOptimization {
  115018. /**
  115019. * Gets a string describing the action executed by the current optimization
  115020. * @return description string
  115021. */
  115022. getDescription(): string;
  115023. /**
  115024. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115025. * @param scene defines the current scene where to apply this optimization
  115026. * @param optimizer defines the current optimizer
  115027. * @returns true if everything that can be done was applied
  115028. */
  115029. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115030. }
  115031. /**
  115032. * Defines an optimization based on user defined callback.
  115033. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115034. */
  115035. export class CustomOptimization extends SceneOptimization {
  115036. /**
  115037. * Callback called to apply the custom optimization.
  115038. */
  115039. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  115040. /**
  115041. * Callback called to get custom description
  115042. */
  115043. onGetDescription: () => string;
  115044. /**
  115045. * Gets a string describing the action executed by the current optimization
  115046. * @returns description string
  115047. */
  115048. getDescription(): string;
  115049. /**
  115050. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115051. * @param scene defines the current scene where to apply this optimization
  115052. * @param optimizer defines the current optimizer
  115053. * @returns true if everything that can be done was applied
  115054. */
  115055. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115056. }
  115057. /**
  115058. * Defines an optimization used to turn particles off
  115059. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115060. */
  115061. export class ParticlesOptimization extends SceneOptimization {
  115062. /**
  115063. * Gets a string describing the action executed by the current optimization
  115064. * @return description string
  115065. */
  115066. getDescription(): string;
  115067. /**
  115068. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115069. * @param scene defines the current scene where to apply this optimization
  115070. * @param optimizer defines the current optimizer
  115071. * @returns true if everything that can be done was applied
  115072. */
  115073. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115074. }
  115075. /**
  115076. * Defines an optimization used to turn render targets off
  115077. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115078. */
  115079. export class RenderTargetsOptimization extends SceneOptimization {
  115080. /**
  115081. * Gets a string describing the action executed by the current optimization
  115082. * @return description string
  115083. */
  115084. getDescription(): string;
  115085. /**
  115086. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115087. * @param scene defines the current scene where to apply this optimization
  115088. * @param optimizer defines the current optimizer
  115089. * @returns true if everything that can be done was applied
  115090. */
  115091. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115092. }
  115093. /**
  115094. * Defines an optimization used to merge meshes with compatible materials
  115095. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115096. */
  115097. export class MergeMeshesOptimization extends SceneOptimization {
  115098. private static _UpdateSelectionTree;
  115099. /**
  115100. * Gets or sets a boolean which defines if optimization octree has to be updated
  115101. */
  115102. /**
  115103. * Gets or sets a boolean which defines if optimization octree has to be updated
  115104. */
  115105. static UpdateSelectionTree: boolean;
  115106. /**
  115107. * Gets a string describing the action executed by the current optimization
  115108. * @return description string
  115109. */
  115110. getDescription(): string;
  115111. private _canBeMerged;
  115112. /**
  115113. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115114. * @param scene defines the current scene where to apply this optimization
  115115. * @param optimizer defines the current optimizer
  115116. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  115117. * @returns true if everything that can be done was applied
  115118. */
  115119. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  115120. }
  115121. /**
  115122. * Defines a list of options used by SceneOptimizer
  115123. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115124. */
  115125. export class SceneOptimizerOptions {
  115126. /**
  115127. * Defines the target frame rate to reach (60 by default)
  115128. */
  115129. targetFrameRate: number;
  115130. /**
  115131. * Defines the interval between two checkes (2000ms by default)
  115132. */
  115133. trackerDuration: number;
  115134. /**
  115135. * Gets the list of optimizations to apply
  115136. */
  115137. optimizations: SceneOptimization[];
  115138. /**
  115139. * Creates a new list of options used by SceneOptimizer
  115140. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  115141. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  115142. */
  115143. constructor(
  115144. /**
  115145. * Defines the target frame rate to reach (60 by default)
  115146. */
  115147. targetFrameRate?: number,
  115148. /**
  115149. * Defines the interval between two checkes (2000ms by default)
  115150. */
  115151. trackerDuration?: number);
  115152. /**
  115153. * Add a new optimization
  115154. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  115155. * @returns the current SceneOptimizerOptions
  115156. */
  115157. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  115158. /**
  115159. * Add a new custom optimization
  115160. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  115161. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  115162. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115163. * @returns the current SceneOptimizerOptions
  115164. */
  115165. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  115166. /**
  115167. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  115168. * @param targetFrameRate defines the target frame rate (60 by default)
  115169. * @returns a SceneOptimizerOptions object
  115170. */
  115171. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115172. /**
  115173. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  115174. * @param targetFrameRate defines the target frame rate (60 by default)
  115175. * @returns a SceneOptimizerOptions object
  115176. */
  115177. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115178. /**
  115179. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  115180. * @param targetFrameRate defines the target frame rate (60 by default)
  115181. * @returns a SceneOptimizerOptions object
  115182. */
  115183. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115184. }
  115185. /**
  115186. * Class used to run optimizations in order to reach a target frame rate
  115187. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115188. */
  115189. export class SceneOptimizer implements IDisposable {
  115190. private _isRunning;
  115191. private _options;
  115192. private _scene;
  115193. private _currentPriorityLevel;
  115194. private _targetFrameRate;
  115195. private _trackerDuration;
  115196. private _currentFrameRate;
  115197. private _sceneDisposeObserver;
  115198. private _improvementMode;
  115199. /**
  115200. * Defines an observable called when the optimizer reaches the target frame rate
  115201. */
  115202. onSuccessObservable: Observable<SceneOptimizer>;
  115203. /**
  115204. * Defines an observable called when the optimizer enables an optimization
  115205. */
  115206. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  115207. /**
  115208. * Defines an observable called when the optimizer is not able to reach the target frame rate
  115209. */
  115210. onFailureObservable: Observable<SceneOptimizer>;
  115211. /**
  115212. * Gets a boolean indicating if the optimizer is in improvement mode
  115213. */
  115214. readonly isInImprovementMode: boolean;
  115215. /**
  115216. * Gets the current priority level (0 at start)
  115217. */
  115218. readonly currentPriorityLevel: number;
  115219. /**
  115220. * Gets the current frame rate checked by the SceneOptimizer
  115221. */
  115222. readonly currentFrameRate: number;
  115223. /**
  115224. * Gets or sets the current target frame rate (60 by default)
  115225. */
  115226. /**
  115227. * Gets or sets the current target frame rate (60 by default)
  115228. */
  115229. targetFrameRate: number;
  115230. /**
  115231. * Gets or sets the current interval between two checks (every 2000ms by default)
  115232. */
  115233. /**
  115234. * Gets or sets the current interval between two checks (every 2000ms by default)
  115235. */
  115236. trackerDuration: number;
  115237. /**
  115238. * Gets the list of active optimizations
  115239. */
  115240. readonly optimizations: SceneOptimization[];
  115241. /**
  115242. * Creates a new SceneOptimizer
  115243. * @param scene defines the scene to work on
  115244. * @param options defines the options to use with the SceneOptimizer
  115245. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  115246. * @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)
  115247. */
  115248. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  115249. /**
  115250. * Stops the current optimizer
  115251. */
  115252. stop(): void;
  115253. /**
  115254. * Reset the optimizer to initial step (current priority level = 0)
  115255. */
  115256. reset(): void;
  115257. /**
  115258. * Start the optimizer. By default it will try to reach a specific framerate
  115259. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  115260. */
  115261. start(): void;
  115262. private _checkCurrentState;
  115263. /**
  115264. * Release all resources
  115265. */
  115266. dispose(): void;
  115267. /**
  115268. * Helper function to create a SceneOptimizer with one single line of code
  115269. * @param scene defines the scene to work on
  115270. * @param options defines the options to use with the SceneOptimizer
  115271. * @param onSuccess defines a callback to call on success
  115272. * @param onFailure defines a callback to call on failure
  115273. * @returns the new SceneOptimizer object
  115274. */
  115275. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  115276. }
  115277. }
  115278. declare module BABYLON {
  115279. /**
  115280. * Class used to serialize a scene into a string
  115281. */
  115282. export class SceneSerializer {
  115283. /**
  115284. * Clear cache used by a previous serialization
  115285. */
  115286. static ClearCache(): void;
  115287. /**
  115288. * Serialize a scene into a JSON compatible object
  115289. * @param scene defines the scene to serialize
  115290. * @returns a JSON compatible object
  115291. */
  115292. static Serialize(scene: Scene): any;
  115293. /**
  115294. * Serialize a mesh into a JSON compatible object
  115295. * @param toSerialize defines the mesh to serialize
  115296. * @param withParents defines if parents must be serialized as well
  115297. * @param withChildren defines if children must be serialized as well
  115298. * @returns a JSON compatible object
  115299. */
  115300. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  115301. }
  115302. }
  115303. declare module BABYLON {
  115304. /**
  115305. * Class used to host texture specific utilities
  115306. */
  115307. export class TextureTools {
  115308. /**
  115309. * Uses the GPU to create a copy texture rescaled at a given size
  115310. * @param texture Texture to copy from
  115311. * @param width defines the desired width
  115312. * @param height defines the desired height
  115313. * @param useBilinearMode defines if bilinear mode has to be used
  115314. * @return the generated texture
  115315. */
  115316. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  115317. }
  115318. }
  115319. declare module BABYLON {
  115320. /**
  115321. * This represents the different options avilable for the video capture.
  115322. */
  115323. export interface VideoRecorderOptions {
  115324. /** Defines the mime type of the video */
  115325. mimeType: string;
  115326. /** Defines the video the video should be recorded at */
  115327. fps: number;
  115328. /** Defines the chunk size for the recording data */
  115329. recordChunckSize: number;
  115330. /** The audio tracks to attach to the record */
  115331. audioTracks?: MediaStreamTrack[];
  115332. }
  115333. /**
  115334. * This can helps recording videos from BabylonJS.
  115335. * This is based on the available WebRTC functionalities of the browser.
  115336. *
  115337. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  115338. */
  115339. export class VideoRecorder {
  115340. private static readonly _defaultOptions;
  115341. /**
  115342. * Returns wehther or not the VideoRecorder is available in your browser.
  115343. * @param engine Defines the Babylon Engine to check the support for
  115344. * @returns true if supported otherwise false
  115345. */
  115346. static IsSupported(engine: Engine): boolean;
  115347. private readonly _options;
  115348. private _canvas;
  115349. private _mediaRecorder;
  115350. private _recordedChunks;
  115351. private _fileName;
  115352. private _resolve;
  115353. private _reject;
  115354. /**
  115355. * True wether a recording is already in progress.
  115356. */
  115357. readonly isRecording: boolean;
  115358. /**
  115359. * Create a new VideoCapture object which can help converting what you see in Babylon to
  115360. * a video file.
  115361. * @param engine Defines the BabylonJS Engine you wish to record
  115362. * @param options Defines options that can be used to customized the capture
  115363. */
  115364. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  115365. /**
  115366. * Stops the current recording before the default capture timeout passed in the startRecording
  115367. * functions.
  115368. */
  115369. stopRecording(): void;
  115370. /**
  115371. * Starts recording the canvas for a max duration specified in parameters.
  115372. * @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.
  115373. * @param maxDuration Defines the maximum recording time in seconds.
  115374. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  115375. * @return a promise callback at the end of the recording with the video data in Blob.
  115376. */
  115377. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  115378. /**
  115379. * Releases internal resources used during the recording.
  115380. */
  115381. dispose(): void;
  115382. private _handleDataAvailable;
  115383. private _handleError;
  115384. private _handleStop;
  115385. }
  115386. }
  115387. declare module BABYLON {
  115388. /**
  115389. * Class containing a set of static utilities functions for screenshots
  115390. */
  115391. export class ScreenshotTools {
  115392. /**
  115393. * Captures a screenshot of the current rendering
  115394. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115395. * @param engine defines the rendering engine
  115396. * @param camera defines the source camera
  115397. * @param size This parameter can be set to a single number or to an object with the
  115398. * following (optional) properties: precision, width, height. If a single number is passed,
  115399. * it will be used for both width and height. If an object is passed, the screenshot size
  115400. * will be derived from the parameters. The precision property is a multiplier allowing
  115401. * rendering at a higher or lower resolution
  115402. * @param successCallback defines the callback receives a single parameter which contains the
  115403. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115404. * src parameter of an <img> to display it
  115405. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115406. * Check your browser for supported MIME types
  115407. */
  115408. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  115409. /**
  115410. * Generates an image screenshot from the specified camera.
  115411. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115412. * @param engine The engine to use for rendering
  115413. * @param camera The camera to use for rendering
  115414. * @param size This parameter can be set to a single number or to an object with the
  115415. * following (optional) properties: precision, width, height. If a single number is passed,
  115416. * it will be used for both width and height. If an object is passed, the screenshot size
  115417. * will be derived from the parameters. The precision property is a multiplier allowing
  115418. * rendering at a higher or lower resolution
  115419. * @param successCallback The callback receives a single parameter which contains the
  115420. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115421. * src parameter of an <img> to display it
  115422. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115423. * Check your browser for supported MIME types
  115424. * @param samples Texture samples (default: 1)
  115425. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115426. * @param fileName A name for for the downloaded file.
  115427. */
  115428. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  115429. }
  115430. }
  115431. declare module BABYLON {
  115432. /**
  115433. * A cursor which tracks a point on a path
  115434. */
  115435. export class PathCursor {
  115436. private path;
  115437. /**
  115438. * Stores path cursor callbacks for when an onchange event is triggered
  115439. */
  115440. private _onchange;
  115441. /**
  115442. * The value of the path cursor
  115443. */
  115444. value: number;
  115445. /**
  115446. * The animation array of the path cursor
  115447. */
  115448. animations: Animation[];
  115449. /**
  115450. * Initializes the path cursor
  115451. * @param path The path to track
  115452. */
  115453. constructor(path: Path2);
  115454. /**
  115455. * Gets the cursor point on the path
  115456. * @returns A point on the path cursor at the cursor location
  115457. */
  115458. getPoint(): Vector3;
  115459. /**
  115460. * Moves the cursor ahead by the step amount
  115461. * @param step The amount to move the cursor forward
  115462. * @returns This path cursor
  115463. */
  115464. moveAhead(step?: number): PathCursor;
  115465. /**
  115466. * Moves the cursor behind by the step amount
  115467. * @param step The amount to move the cursor back
  115468. * @returns This path cursor
  115469. */
  115470. moveBack(step?: number): PathCursor;
  115471. /**
  115472. * Moves the cursor by the step amount
  115473. * If the step amount is greater than one, an exception is thrown
  115474. * @param step The amount to move the cursor
  115475. * @returns This path cursor
  115476. */
  115477. move(step: number): PathCursor;
  115478. /**
  115479. * Ensures that the value is limited between zero and one
  115480. * @returns This path cursor
  115481. */
  115482. private ensureLimits;
  115483. /**
  115484. * Runs onchange callbacks on change (used by the animation engine)
  115485. * @returns This path cursor
  115486. */
  115487. private raiseOnChange;
  115488. /**
  115489. * Executes a function on change
  115490. * @param f A path cursor onchange callback
  115491. * @returns This path cursor
  115492. */
  115493. onchange(f: (cursor: PathCursor) => void): PathCursor;
  115494. }
  115495. }
  115496. declare module BABYLON {
  115497. /** @hidden */
  115498. export var blurPixelShader: {
  115499. name: string;
  115500. shader: string;
  115501. };
  115502. }
  115503. declare module BABYLON {
  115504. /** @hidden */
  115505. export var bones300Declaration: {
  115506. name: string;
  115507. shader: string;
  115508. };
  115509. }
  115510. declare module BABYLON {
  115511. /** @hidden */
  115512. export var instances300Declaration: {
  115513. name: string;
  115514. shader: string;
  115515. };
  115516. }
  115517. declare module BABYLON {
  115518. /** @hidden */
  115519. export var pointCloudVertexDeclaration: {
  115520. name: string;
  115521. shader: string;
  115522. };
  115523. }
  115524. // Mixins
  115525. interface Window {
  115526. mozIndexedDB: IDBFactory;
  115527. webkitIndexedDB: IDBFactory;
  115528. msIndexedDB: IDBFactory;
  115529. webkitURL: typeof URL;
  115530. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  115531. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  115532. WebGLRenderingContext: WebGLRenderingContext;
  115533. MSGesture: MSGesture;
  115534. CANNON: any;
  115535. AudioContext: AudioContext;
  115536. webkitAudioContext: AudioContext;
  115537. PointerEvent: any;
  115538. Math: Math;
  115539. Uint8Array: Uint8ArrayConstructor;
  115540. Float32Array: Float32ArrayConstructor;
  115541. mozURL: typeof URL;
  115542. msURL: typeof URL;
  115543. VRFrameData: any; // WebVR, from specs 1.1
  115544. DracoDecoderModule: any;
  115545. setImmediate(handler: (...args: any[]) => void): number;
  115546. }
  115547. interface HTMLCanvasElement {
  115548. requestPointerLock(): void;
  115549. msRequestPointerLock?(): void;
  115550. mozRequestPointerLock?(): void;
  115551. webkitRequestPointerLock?(): void;
  115552. /** Track wether a record is in progress */
  115553. isRecording: boolean;
  115554. /** Capture Stream method defined by some browsers */
  115555. captureStream(fps?: number): MediaStream;
  115556. }
  115557. interface CanvasRenderingContext2D {
  115558. msImageSmoothingEnabled: boolean;
  115559. }
  115560. interface MouseEvent {
  115561. mozMovementX: number;
  115562. mozMovementY: number;
  115563. webkitMovementX: number;
  115564. webkitMovementY: number;
  115565. msMovementX: number;
  115566. msMovementY: number;
  115567. }
  115568. interface Navigator {
  115569. mozGetVRDevices: (any: any) => any;
  115570. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115571. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115572. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115573. webkitGetGamepads(): Gamepad[];
  115574. msGetGamepads(): Gamepad[];
  115575. webkitGamepads(): Gamepad[];
  115576. }
  115577. interface HTMLVideoElement {
  115578. mozSrcObject: any;
  115579. }
  115580. interface Math {
  115581. fround(x: number): number;
  115582. imul(a: number, b: number): number;
  115583. }
  115584. interface WebGLProgram {
  115585. context?: WebGLRenderingContext;
  115586. vertexShader?: WebGLShader;
  115587. fragmentShader?: WebGLShader;
  115588. isParallelCompiled: boolean;
  115589. onCompiled?: () => void;
  115590. }
  115591. interface WebGLRenderingContext {
  115592. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  115593. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  115594. vertexAttribDivisor(index: number, divisor: number): void;
  115595. createVertexArray(): any;
  115596. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  115597. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  115598. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  115599. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  115600. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  115601. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  115602. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  115603. // Queries
  115604. createQuery(): WebGLQuery;
  115605. deleteQuery(query: WebGLQuery): void;
  115606. beginQuery(target: number, query: WebGLQuery): void;
  115607. endQuery(target: number): void;
  115608. getQueryParameter(query: WebGLQuery, pname: number): any;
  115609. getQuery(target: number, pname: number): any;
  115610. MAX_SAMPLES: number;
  115611. RGBA8: number;
  115612. READ_FRAMEBUFFER: number;
  115613. DRAW_FRAMEBUFFER: number;
  115614. UNIFORM_BUFFER: number;
  115615. HALF_FLOAT_OES: number;
  115616. RGBA16F: number;
  115617. RGBA32F: number;
  115618. R32F: number;
  115619. RG32F: number;
  115620. RGB32F: number;
  115621. R16F: number;
  115622. RG16F: number;
  115623. RGB16F: number;
  115624. RED: number;
  115625. RG: number;
  115626. R8: number;
  115627. RG8: number;
  115628. UNSIGNED_INT_24_8: number;
  115629. DEPTH24_STENCIL8: number;
  115630. /* Multiple Render Targets */
  115631. drawBuffers(buffers: number[]): void;
  115632. readBuffer(src: number): void;
  115633. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  115634. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  115635. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  115636. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  115637. // Occlusion Query
  115638. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  115639. ANY_SAMPLES_PASSED: number;
  115640. QUERY_RESULT_AVAILABLE: number;
  115641. QUERY_RESULT: number;
  115642. }
  115643. interface WebGLBuffer {
  115644. references: number;
  115645. capacity: number;
  115646. is32Bits: boolean;
  115647. }
  115648. interface WebGLProgram {
  115649. transformFeedback?: WebGLTransformFeedback | null;
  115650. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  115651. }
  115652. interface EXT_disjoint_timer_query {
  115653. QUERY_COUNTER_BITS_EXT: number;
  115654. TIME_ELAPSED_EXT: number;
  115655. TIMESTAMP_EXT: number;
  115656. GPU_DISJOINT_EXT: number;
  115657. QUERY_RESULT_EXT: number;
  115658. QUERY_RESULT_AVAILABLE_EXT: number;
  115659. queryCounterEXT(query: WebGLQuery, target: number): void;
  115660. createQueryEXT(): WebGLQuery;
  115661. beginQueryEXT(target: number, query: WebGLQuery): void;
  115662. endQueryEXT(target: number): void;
  115663. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  115664. deleteQueryEXT(query: WebGLQuery): void;
  115665. }
  115666. interface WebGLUniformLocation {
  115667. _currentState: any;
  115668. }
  115669. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  115670. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  115671. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  115672. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  115673. interface WebGLRenderingContext {
  115674. readonly RASTERIZER_DISCARD: number;
  115675. readonly DEPTH_COMPONENT24: number;
  115676. readonly TEXTURE_3D: number;
  115677. readonly TEXTURE_2D_ARRAY: number;
  115678. readonly TEXTURE_COMPARE_FUNC: number;
  115679. readonly TEXTURE_COMPARE_MODE: number;
  115680. readonly COMPARE_REF_TO_TEXTURE: number;
  115681. readonly TEXTURE_WRAP_R: number;
  115682. readonly HALF_FLOAT: number;
  115683. readonly RGB8: number;
  115684. readonly RED_INTEGER: number;
  115685. readonly RG_INTEGER: number;
  115686. readonly RGB_INTEGER: number;
  115687. readonly RGBA_INTEGER: number;
  115688. readonly R8_SNORM: number;
  115689. readonly RG8_SNORM: number;
  115690. readonly RGB8_SNORM: number;
  115691. readonly RGBA8_SNORM: number;
  115692. readonly R8I: number;
  115693. readonly RG8I: number;
  115694. readonly RGB8I: number;
  115695. readonly RGBA8I: number;
  115696. readonly R8UI: number;
  115697. readonly RG8UI: number;
  115698. readonly RGB8UI: number;
  115699. readonly RGBA8UI: number;
  115700. readonly R16I: number;
  115701. readonly RG16I: number;
  115702. readonly RGB16I: number;
  115703. readonly RGBA16I: number;
  115704. readonly R16UI: number;
  115705. readonly RG16UI: number;
  115706. readonly RGB16UI: number;
  115707. readonly RGBA16UI: number;
  115708. readonly R32I: number;
  115709. readonly RG32I: number;
  115710. readonly RGB32I: number;
  115711. readonly RGBA32I: number;
  115712. readonly R32UI: number;
  115713. readonly RG32UI: number;
  115714. readonly RGB32UI: number;
  115715. readonly RGBA32UI: number;
  115716. readonly RGB10_A2UI: number;
  115717. readonly R11F_G11F_B10F: number;
  115718. readonly RGB9_E5: number;
  115719. readonly RGB10_A2: number;
  115720. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  115721. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  115722. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  115723. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  115724. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  115725. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  115726. 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;
  115727. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  115728. readonly TRANSFORM_FEEDBACK: number;
  115729. readonly INTERLEAVED_ATTRIBS: number;
  115730. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  115731. createTransformFeedback(): WebGLTransformFeedback;
  115732. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  115733. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  115734. beginTransformFeedback(primitiveMode: number): void;
  115735. endTransformFeedback(): void;
  115736. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  115737. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115738. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115739. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115740. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  115741. }
  115742. interface ImageBitmap {
  115743. readonly width: number;
  115744. readonly height: number;
  115745. close(): void;
  115746. }
  115747. interface WebGLQuery extends WebGLObject {
  115748. }
  115749. declare var WebGLQuery: {
  115750. prototype: WebGLQuery;
  115751. new(): WebGLQuery;
  115752. };
  115753. interface WebGLSampler extends WebGLObject {
  115754. }
  115755. declare var WebGLSampler: {
  115756. prototype: WebGLSampler;
  115757. new(): WebGLSampler;
  115758. };
  115759. interface WebGLSync extends WebGLObject {
  115760. }
  115761. declare var WebGLSync: {
  115762. prototype: WebGLSync;
  115763. new(): WebGLSync;
  115764. };
  115765. interface WebGLTransformFeedback extends WebGLObject {
  115766. }
  115767. declare var WebGLTransformFeedback: {
  115768. prototype: WebGLTransformFeedback;
  115769. new(): WebGLTransformFeedback;
  115770. };
  115771. interface WebGLVertexArrayObject extends WebGLObject {
  115772. }
  115773. declare var WebGLVertexArrayObject: {
  115774. prototype: WebGLVertexArrayObject;
  115775. new(): WebGLVertexArrayObject;
  115776. };
  115777. // Type definitions for WebVR API
  115778. // Project: https://w3c.github.io/webvr/
  115779. // Definitions by: six a <https://github.com/lostfictions>
  115780. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  115781. interface VRDisplay extends EventTarget {
  115782. /**
  115783. * Dictionary of capabilities describing the VRDisplay.
  115784. */
  115785. readonly capabilities: VRDisplayCapabilities;
  115786. /**
  115787. * z-depth defining the far plane of the eye view frustum
  115788. * enables mapping of values in the render target depth
  115789. * attachment to scene coordinates. Initially set to 10000.0.
  115790. */
  115791. depthFar: number;
  115792. /**
  115793. * z-depth defining the near plane of the eye view frustum
  115794. * enables mapping of values in the render target depth
  115795. * attachment to scene coordinates. Initially set to 0.01.
  115796. */
  115797. depthNear: number;
  115798. /**
  115799. * An identifier for this distinct VRDisplay. Used as an
  115800. * association point in the Gamepad API.
  115801. */
  115802. readonly displayId: number;
  115803. /**
  115804. * A display name, a user-readable name identifying it.
  115805. */
  115806. readonly displayName: string;
  115807. readonly isConnected: boolean;
  115808. readonly isPresenting: boolean;
  115809. /**
  115810. * If this VRDisplay supports room-scale experiences, the optional
  115811. * stage attribute contains details on the room-scale parameters.
  115812. */
  115813. readonly stageParameters: VRStageParameters | null;
  115814. /**
  115815. * Passing the value returned by `requestAnimationFrame` to
  115816. * `cancelAnimationFrame` will unregister the callback.
  115817. * @param handle Define the hanle of the request to cancel
  115818. */
  115819. cancelAnimationFrame(handle: number): void;
  115820. /**
  115821. * Stops presenting to the VRDisplay.
  115822. * @returns a promise to know when it stopped
  115823. */
  115824. exitPresent(): Promise<void>;
  115825. /**
  115826. * Return the current VREyeParameters for the given eye.
  115827. * @param whichEye Define the eye we want the parameter for
  115828. * @returns the eye parameters
  115829. */
  115830. getEyeParameters(whichEye: string): VREyeParameters;
  115831. /**
  115832. * Populates the passed VRFrameData with the information required to render
  115833. * the current frame.
  115834. * @param frameData Define the data structure to populate
  115835. * @returns true if ok otherwise false
  115836. */
  115837. getFrameData(frameData: VRFrameData): boolean;
  115838. /**
  115839. * Get the layers currently being presented.
  115840. * @returns the list of VR layers
  115841. */
  115842. getLayers(): VRLayer[];
  115843. /**
  115844. * Return a VRPose containing the future predicted pose of the VRDisplay
  115845. * when the current frame will be presented. The value returned will not
  115846. * change until JavaScript has returned control to the browser.
  115847. *
  115848. * The VRPose will contain the position, orientation, velocity,
  115849. * and acceleration of each of these properties.
  115850. * @returns the pose object
  115851. */
  115852. getPose(): VRPose;
  115853. /**
  115854. * Return the current instantaneous pose of the VRDisplay, with no
  115855. * prediction applied.
  115856. * @returns the current instantaneous pose
  115857. */
  115858. getImmediatePose(): VRPose;
  115859. /**
  115860. * The callback passed to `requestAnimationFrame` will be called
  115861. * any time a new frame should be rendered. When the VRDisplay is
  115862. * presenting the callback will be called at the native refresh
  115863. * rate of the HMD. When not presenting this function acts
  115864. * identically to how window.requestAnimationFrame acts. Content should
  115865. * make no assumptions of frame rate or vsync behavior as the HMD runs
  115866. * asynchronously from other displays and at differing refresh rates.
  115867. * @param callback Define the eaction to run next frame
  115868. * @returns the request handle it
  115869. */
  115870. requestAnimationFrame(callback: FrameRequestCallback): number;
  115871. /**
  115872. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  115873. * Repeat calls while already presenting will update the VRLayers being displayed.
  115874. * @param layers Define the list of layer to present
  115875. * @returns a promise to know when the request has been fulfilled
  115876. */
  115877. requestPresent(layers: VRLayer[]): Promise<void>;
  115878. /**
  115879. * Reset the pose for this display, treating its current position and
  115880. * orientation as the "origin/zero" values. VRPose.position,
  115881. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  115882. * updated when calling resetPose(). This should be called in only
  115883. * sitting-space experiences.
  115884. */
  115885. resetPose(): void;
  115886. /**
  115887. * The VRLayer provided to the VRDisplay will be captured and presented
  115888. * in the HMD. Calling this function has the same effect on the source
  115889. * canvas as any other operation that uses its source image, and canvases
  115890. * created without preserveDrawingBuffer set to true will be cleared.
  115891. * @param pose Define the pose to submit
  115892. */
  115893. submitFrame(pose?: VRPose): void;
  115894. }
  115895. declare var VRDisplay: {
  115896. prototype: VRDisplay;
  115897. new(): VRDisplay;
  115898. };
  115899. interface VRLayer {
  115900. leftBounds?: number[] | Float32Array | null;
  115901. rightBounds?: number[] | Float32Array | null;
  115902. source?: HTMLCanvasElement | null;
  115903. }
  115904. interface VRDisplayCapabilities {
  115905. readonly canPresent: boolean;
  115906. readonly hasExternalDisplay: boolean;
  115907. readonly hasOrientation: boolean;
  115908. readonly hasPosition: boolean;
  115909. readonly maxLayers: number;
  115910. }
  115911. interface VREyeParameters {
  115912. /** @deprecated */
  115913. readonly fieldOfView: VRFieldOfView;
  115914. readonly offset: Float32Array;
  115915. readonly renderHeight: number;
  115916. readonly renderWidth: number;
  115917. }
  115918. interface VRFieldOfView {
  115919. readonly downDegrees: number;
  115920. readonly leftDegrees: number;
  115921. readonly rightDegrees: number;
  115922. readonly upDegrees: number;
  115923. }
  115924. interface VRFrameData {
  115925. readonly leftProjectionMatrix: Float32Array;
  115926. readonly leftViewMatrix: Float32Array;
  115927. readonly pose: VRPose;
  115928. readonly rightProjectionMatrix: Float32Array;
  115929. readonly rightViewMatrix: Float32Array;
  115930. readonly timestamp: number;
  115931. }
  115932. interface VRPose {
  115933. readonly angularAcceleration: Float32Array | null;
  115934. readonly angularVelocity: Float32Array | null;
  115935. readonly linearAcceleration: Float32Array | null;
  115936. readonly linearVelocity: Float32Array | null;
  115937. readonly orientation: Float32Array | null;
  115938. readonly position: Float32Array | null;
  115939. readonly timestamp: number;
  115940. }
  115941. interface VRStageParameters {
  115942. sittingToStandingTransform?: Float32Array;
  115943. sizeX?: number;
  115944. sizeY?: number;
  115945. }
  115946. interface Navigator {
  115947. getVRDisplays(): Promise<VRDisplay[]>;
  115948. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  115949. }
  115950. interface Window {
  115951. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  115952. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  115953. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  115954. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  115955. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  115956. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  115957. }
  115958. interface Gamepad {
  115959. readonly displayId: number;
  115960. }
  115961. interface XRDevice {
  115962. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  115963. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  115964. }
  115965. interface XRSession {
  115966. getInputSources(): Array<any>;
  115967. baseLayer: XRWebGLLayer;
  115968. requestFrameOfReference(type: string): Promise<void>;
  115969. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  115970. end(): Promise<void>;
  115971. requestAnimationFrame: Function;
  115972. addEventListener: Function;
  115973. }
  115974. interface XRSessionCreationOptions {
  115975. outputContext?: WebGLRenderingContext | null;
  115976. immersive?: boolean;
  115977. environmentIntegration?: boolean;
  115978. }
  115979. interface XRLayer {
  115980. getViewport: Function;
  115981. framebufferWidth: number;
  115982. framebufferHeight: number;
  115983. }
  115984. interface XRView {
  115985. projectionMatrix: Float32Array;
  115986. }
  115987. interface XRFrame {
  115988. getDevicePose: Function;
  115989. getInputPose: Function;
  115990. views: Array<XRView>;
  115991. baseLayer: XRLayer;
  115992. }
  115993. interface XRFrameOfReference {
  115994. }
  115995. interface XRWebGLLayer extends XRLayer {
  115996. framebuffer: WebGLFramebuffer;
  115997. }
  115998. declare var XRWebGLLayer: {
  115999. prototype: XRWebGLLayer;
  116000. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  116001. };